diff --git a/calendar/edit_entry.php b/calendar/edit_entry.php index 4c8a0d2250..4b60f0c7b9 100755 --- a/calendar/edit_entry.php +++ b/calendar/edit_entry.php @@ -1,4 +1,3 @@ - "calendar", "enable_calendar_class" => True, "enable_nextmatchs_class" => True); include("../header.inc.php"); + include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities_sbox.inc.php"); + $sb = new sbox; $cal_info = new calendar_item; + function display_item($field,$data) { + global $phpgw; + + $phpgw->template->set_var("field",$field); + $phpgw->template->set_var("data",$data); + $phpgw->template->parse("output","list",True); + } + if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { $hourformat = "h"; } else { @@ -72,6 +81,7 @@ $cal_info->edatetime = $cal_info->datetime; $cal_info->name = ""; $cal_info->description = ""; + $cal_info->priority = 2; $cal_info->rpt_end = $cal_info->datetime + 86400; } @@ -99,42 +109,18 @@ $phpgw->template->parse("out","edit_entry_begin"); // Brief Description - $phpgw->template->set_var("field",lang("Brief Description")); - $phpgw->template->set_var("data","name."\">"); - $phpgw->template->parse("output","list",True); + display_item(lang("Brief Description"),"name."\">"); // Full Description - $phpgw->template->set_var("field",lang("Full Description")); - $phpgw->template->set_var("data",""); - $phpgw->template->parse("output","list",True); + display_item(lang("Full Description"),""); // Date - $phpgw->template->set_var("field",lang("Start Date")); - - $day_html = ""; - - $month_html = ""; - - $year_html = ""; - - $phpgw->template->set_var("data",$phpgw->common->dateformatorder($year_html,$month_html,$day_html)); - $phpgw->template->parse("output","list",True); + $day_html = $sb->getDays("cal[day]",intval($phpgw->common->show_date($cal_info->datetime,"d"))); + $month_html = $sb->getMonthText("cal[month]",intval($phpgw->common->show_date($cal_info->datetime,"n"))); + $year_html = $sb->getYears("cal[year]",intval($phpgw->common->show_date($cal_info->datetime,"Y")),intval($phpgw->common->show_date($cal_info->datetime,"Y"))); + display_item(lang("Start Date"),$phpgw->common->dateformatorder($year_html,$month_html,$day_html)); // Time - $phpgw->template->set_var("field",lang("Time")); - $amsel = "checked"; $pmsel = ""; if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { if ($cal_info->ampm == "pm") { @@ -149,36 +135,16 @@ $str .= "pm"; } + display_item(lang("Start Time"),$str); + // End Date - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); - $phpgw->template->set_var("field",lang("End Date")); - - $day_html = ""; - - $month_html = ""; - - $year_html = ""; - - $phpgw->template->set_var("data",$phpgw->common->dateformatorder($year_html,$month_html,$day_html)); - $phpgw->template->parse("output","list",True); + $day_html = $sb->getDays("cal[end_day]",intval($phpgw->common->show_date($cal_info->edatetime,"d"))); + $month_html = $sb->getMonthText("cal[end_month]",intval($phpgw->common->show_date($cal_info->edatetime,"n"))); + $year_html = $sb->getYears("cal[end_year]",intval($phpgw->common->show_date($cal_info->edatetime,"Y")),intval($phpgw->common->show_date($cal_info->edatetime,"Y"))); + display_item(lang("End Date"),$phpgw->common->dateformatorder($year_html,$month_html,$day_html)); // End Time - $phpgw->template->set_var("field",lang("End Time")); - $amsel = "checked"; $pmsel = ""; if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { if ($cal_info->end_ampm == "pm") { @@ -193,63 +159,23 @@ $str .= "pm"; } - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + display_item(lang("End Time"),$str); // Priority - $phpgw->template->set_var("field",lang("Priority")); - $str = ""; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + display_item(lang("Priority"),$sb->getPriority("cal[priority]",$cal_info->priority)); - $phpgw->template->set_var("field",lang("Access")); - $str = ""; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); +// Access + display_item(lang("Access"),$sb->getAccessList("cal[access]",$cal_info->access)); // Groups - $phpgw->template->set_var("field",lang("Groups")); - $str = ""; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + + display_item(lang("Groups"),$sb->getGroups($user_groups,$cal_info->groups,"cal[groups][]")); // Participants - $phpgw->template->set_var("field",lang("Participants")); $db2 = $phpgw->db; $db2->query("select account_id,account_lastname,account_firstname,account_lid " . "from accounts where account_status !='L' and " @@ -273,12 +199,9 @@ $str .= ">".$phpgw->common->grab_owner_name($db2->f("account_id")).""; } $str .= ""; -// $str .= ""; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + display_item(lang("Participants"),$str); // I Participate - $phpgw->template->set_var("field",lang("I Participate")); $participate = False; if($id) { for($i=0;$iparticipants);$i++) { @@ -292,11 +215,9 @@ $str .= " checked"; } $str .= ">"; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + display_item(lang("I Participate"),$str); // Repeat Type - $phpgw->template->set_var("field",lang("Repeat Type")); $str = ""; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + display_item(lang("Repeat Type"),$str); $phpgw->template->set_var("field",lang("Repeat End Date")); $str = "rpt_use_end) $str .= " checked"; $str .= ">".lang("Use End Date")." "; - $day_html = ""; - - $month_html = ""; - - $year_html = ""; - + $day_html = $sb->getDays("cal[rpt_day]",intval($phpgw->common->show_date($cal_info->rpt_end,"d"))); + $month_html = $sb->getMonthText("cal[rpt_month]",intval($phpgw->common->show_date($cal_info->rpt_end,"n"))); + $year_html = $sb->getYears("cal[rpt_year]",intval($phpgw->common->show_date($cal_info->rpt_end,"Y")),intval($phpgw->common->show_date($cal_info->rpt_end,"Y"))); $str .= $phpgw->common->dateformatorder($year_html,$month_html,$day_html); - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); - $phpgw->template->set_var("field",lang("Repeat Day")."
".lang("(for weekly)")); + display_item(lang("Repeat End Date"),$str); + $str = "rpt_sun?"checked":"")."> ".lang("Sunday")." "; $str .= "rpt_mon?"checked":"")."> ".lang("Monday")." "; $str .= "rpt_tue?"checked":"")."> ".lang("Tuesday")." "; @@ -344,12 +248,10 @@ $str .= "rpt_thu?"checked":"")."> ".lang("Thursday")." "; $str .= "rpt_fri?"checked":"")."> ".lang("Friday")." "; $str .= "rpt_sat?"checked":"")."> ".lang("Saturday")." "; - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); - $phpgw->template->set_var("field",lang("Frequency")); - $phpgw->template->set_var("data","rpt_freq."\">"); - $phpgw->template->parse("output","list",True); + display_item(lang("Repeat Day")."
".lang("(for weekly)"),$str); + + display_item(lang("Frequency"),"rpt_freq."\">"); $phpgw->template->set_var("submit_button",lang("Submit")); diff --git a/calendar/inc/hook_preferences.inc.php b/calendar/inc/hook_preferences.inc.php index 84dffdc696..7546c89b3b 100644 --- a/calendar/inc/hook_preferences.inc.php +++ b/calendar/inc/hook_preferences.inc.php @@ -9,7 +9,7 @@ * Free Software Foundation; either version 2 of the License, or (at your * * option) any later version. * \**************************************************************************/ - /* $ Id $ */ + /* $Id$ */ { echo "

\n"; diff --git a/calendar/view.php b/calendar/view.php index e530aa668a..937dc87907 100755 --- a/calendar/view.php +++ b/calendar/view.php @@ -26,11 +26,20 @@ $repeat_days .= $day; } + function display_item($field,$data) { + global $phpgw; + + $phpgw->template->set_var("field",$field); + $phpgw->template->set_var("data",$data); + $phpgw->template->parse("output","list",True); + } + + if ($year) $thisyear = $year; if ($month) $thismonth = $month; $pri[1] = lang("Low"); - $pri[2] = lang("Medium"); + $pri[2] = lang("Normal"); $pri[3] = lang("High"); $db = $phpgw->db; @@ -62,27 +71,19 @@ // Some browser add a \n when its entered in the database. Not a big deal // this will be printed even though its not needed. if (nl2br($cal_info->description)) { - $phpgw->template->set_var("field",lang("Description")); - $phpgw->template->set_var("data",nl2br($cal_info->description)); - $phpgw->template->parse("output","list",True); + display_item(lang("Description"),nl2br($cal_info->description)); } - $phpgw->template->set_var("field",lang("Start Date/Time")); - $phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->datetime)); - $phpgw->template->parse("output","list",True); + display_item(lang("Start Date/Time"),$phpgw->common->show_date($cal_info->datetime)); // save date so the trailer links are for the same time period $thisyear = (int)$cal_info->year; $thismonth = (int)$cal_info->month; $thisday = (int)$cal_info->day; - $phpgw->template->set_var("field",lang("End Date/Time")); - $phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->edatetime)); - $phpgw->template->parse("output","list",True); + display_item(lang("End Date/Time"),$phpgw->common->show_date($cal_info->edatetime)); - $phpgw->template->set_var("field",lang("Priority")); - $phpgw->template->set_var("data",$pri[$cal_info->priority]); - $phpgw->template->parse("output","list",True); + display_item(lang("Priority"),$pri[$cal_info->priority]); $phpgw->template->set_var("field",lang("Created by")); $participate = False; @@ -92,16 +93,13 @@ } } if($is_my_event && $participate) - $phpgw->template->set_var("data","link("viewmatrix.php","participants=".$cal_info->owner."&date=".$cal_info->year.$cal_info->month.$cal_info->day."&matrixtype=free/busy") ."\">".$phpgw->common->grab_owner_name($cal_info->owner).""); else - $phpgw->template->set_var("data",$phpgw->common->grab_owner_name($cal_info->owner)); - $phpgw->template->parse("output","list",True); + display_item(lang("Created by"),$phpgw->common->grab_owner_name($cal_info->owner)); - $phpgw->template->set_var("field",lang("Updated")); - $phpgw->template->set_var("data",$phpgw->common->show_date($cal_info->mdatetime)); - $phpgw->template->parse("output","list",True); + display_item(lang("Updated"),$phpgw->common->show_date($cal_info->mdatetime)); if($cal_info->groups[0]) { $cal_grps = ""; @@ -111,9 +109,7 @@ $db->next_record(); $cal_grps .= $db->f("group_name"); } - $phpgw->template->set_var("field",lang("Groups")); - $phpgw->template->set_var("data",$cal_grps); - $phpgw->template->parse("output","list",True); + display_item(lang("Groups"),$cal_grps); } $str = ""; @@ -121,9 +117,7 @@ if($i) $str .= "
"; $str .= $phpgw->common->grab_owner_name($cal_info->participants[$i]); } - $phpgw->template->set_var("field",lang("Participants")); - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + display_item(lang("Participants"),$str); // Repeated Events $str = $cal_info->rpt_type; @@ -152,9 +146,7 @@ if($cal_info->rpt_freq) $str .= lang("frequency")." ".$cal_info->rpt_freq; $str .= ")"; - $phpgw->template->set_var("field",lang("Repetition")); - $phpgw->template->set_var("data",$str); - $phpgw->template->parse("output","list",True); + display_item(lang("Repetition"),$str); } if ($is_my_event) { diff --git a/phpgwapi/inc/phpgw_calendar.inc.php b/phpgwapi/inc/phpgw_calendar.inc.php index 0336f3f2ac..2f1d8c9b43 100644 --- a/phpgwapi/inc/phpgw_calendar.inc.php +++ b/phpgwapi/inc/phpgw_calendar.inc.php @@ -270,10 +270,12 @@ $sql = "SELECT DISTINCT calendar_entry.cal_id " . "FROM calendar_entry, calendar_entry_user, calendar_entry_repeats " - . "WHERE calendar_entry.cal_id = calendar_entry_user.cal_id " - . "AND (((".$starttime." <= calendar_entry.cal_datetime) AND (".$endtime." >= calendar_entry.cal_datetime) AND (".$endtime." <= calendar_entry.cal_edatetime)) " - . "OR ((".$starttime." >= calendar_entry.cal_datetime) AND (".$starttime." <= calendar_entry.cal_edatetime) AND (".$endtime." >= calendar_entry.cal_edatetime)) " - . "OR ((".$starttime." <= calendar_entry.cal_datetime) AND (".$endtime." >= calendar_entry.cal_edatetime)))"; + . "WHERE ((calendar_entry_user.cal_id = calendar_entry.cal_id) AND " + . "(calendar_entry_repeats.cal_id = calendar_entry.cal_id)) AND " + . " (((".$starttime." <= calendar_entry.cal_datetime) AND (".$endtime." >= calendar_entry.cal_datetime) AND (".$endtime." <= calendar_entry.cal_edatetime)) " + . "OR ((".$starttime." >= calendar_entry.cal_datetime) AND (".$starttime." <= calendar_entry.cal_edatetime) AND (".$endtime." >= calendar_entry.cal_edatetime)) " + . "OR ((".$starttime." <= calendar_entry.cal_datetime) AND (".$endtime." >= calendar_entry.cal_edatetime))) AND " + . "(calendar_entry_repeats.cal_type <> 'monthlyByDay') "; if(count($participants) || is_array($groups)) { $p_g = ""; @@ -588,7 +590,7 @@ if ((($date["year"] - $start["year"]) * 12 + $date["month"] - $start["month"]) % intval($rep_events->rpt_freq)) continue; if (($start["dow"] == $date["dow"]) && - (floor($start["day"]/7) == floor($date["day"]/7))) { + (ceil($start["day"]/7) == ceil($date["day"]/7))) { $link[$this->checked_re] = $i; $this->checked_re++; }