From f7e410e9b8be828fd8cee64120f3dd9549ab3fce Mon Sep 17 00:00:00 2001 From: skeeter Date: Thu, 23 Nov 2000 01:37:50 +0000 Subject: [PATCH] edit_entry now a template --- calendar/edit_entry.php | 468 ++++++++---------- calendar/templates/default/edit.tpl | 47 ++ .../templates/default/form_button_script.tpl | 6 + calendar/templates/default/view.tpl | 2 +- calendar/view.php | 23 +- 5 files changed, 273 insertions(+), 273 deletions(-) create mode 100755 calendar/templates/default/edit.tpl create mode 100755 calendar/templates/default/form_button_script.tpl diff --git a/calendar/edit_entry.php b/calendar/edit_entry.php index f6489854af..1f80bfdc98 100755 --- a/calendar/edit_entry.php +++ b/calendar/edit_entry.php @@ -21,18 +21,21 @@ $cal_info = new calendar_item; if ($id > 0) { - $can_edit = false; - $phpgw->db->query("SELECT cal_id FROM webcal_entry_user WHERE cal_login=" - . $phpgw_info["user"]["account_id"] . " AND cal_id = $id"); - $phpgw->db->next_record(); - if ($phpgw->db->f("cal_id") > 0) - $can_edit = true; - $cal = $phpgw->calendar->getevent((int)$id); - $cal_info = $cal[0]; + $can_edit = false; + if($cal_info->owner == $phpgw_info["user"]["account_id"]) + $can_edit = true; + + if(!$cal_info->rpt_end_use) { + $rpt_date = $phpgw->calendar->splitdate(mktime(0,0,0,$cal_info->month,$cal_info->day + 1,$cal_info->year)); + $cal_info->rpt_year = $rpt_date["year"]; + $cal_info->rpt_month = $rpt_date["month"]; + $cal_info->rpt_day = $rpt_date["day"]; + } } else { + $can_edit = true; if (!isset($day) || !$day) $thisday = (int)$phpgw->calendar->today["day"]; @@ -76,297 +79,230 @@ $cal_info["hour"] = $cal_info["hour"] - 12; $cal_info["ampm"] = "pm"; } - $can_edit = true; } -?> - - - + $phpgw->template->set_file(array("edit_entry_begin" => "edit.tpl", + "list" => "list.tpl", + "edit_entry_end" => "edit.tpl", + "form_button" => "form_button_script.tpl")); -

template->set_block("edit_entry_begin","list","edit_entry_end","form_button"); -?>

+ $phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_text"]); + $phpgw->template->set_var("name_error",lang("You have not entered a\\nBrief Description")."."); + $phpgw->template->set_var("time_error",lang("You have not entered a\\nvalid time of day.")); + if($id) + $phpgw->template->set_var("calendar_action",lang("Calendar - Edit")); + else + $phpgw->template->set_var("calendar_action",lang("Calendar - Add")); - -
" METHOD="POST" name="addform"> + if($can_edit) { + $phpgw->template->set_var("action_url",$phpgw->link("edit_entry_handler.php")); -\n"; ?> + if($id) { + $common_hidden = "\n"; + } else { + $common_hidden = ""; + } - - - - - + $phpgw->template->set_var("common_hidden",$common_hidden); - - - - + $phpgw->template->parse("out","edit_entry_begin"); - - - - + $phpgw->template->set_var("field",lang("Time")); - - -ampm == "pm") { - $amsel = ""; $pmsel = "CHECKED"; - } else { - $amsel = "CHECKED"; $pmsel = ""; - } - } -?> - + $amsel = "checked"; $pmsel = ""; + if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { + if ($cal_info->ampm == "pm") { + $amsel = ""; $pmsel = "checked"; + } else { + $amsel = "checked"; $pmsel = ""; + } + } + $str = "hour."\" maxlength=\"2\">:minute>=0 && (int)$cal_info->minute<=9?"0".(int)$cal_info->minute:$cal_info->minute)."\" maxlength=\"2\">"; + if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") { + $str .= "am"; + $str .= "pm"; + } - - - - + $phpgw->template->set_var("data",$str); + $phpgw->template->parse("output","list",True); - - - - + $phpgw->template->set_var("field",lang("Duration")); + $phpgw->template->set_var("data","duration?0:$cal_info->duration)."\"> ".lang("minutes")); + $phpgw->template->parse("output","list",True); - - - - - + $phpgw->template->set_var("field",lang("Priority")); + $str = ""; + $phpgw->template->set_var("data",$str); + $phpgw->template->parse("output","list",True); - - - + $str .= ""; + $phpgw->template->set_var("data",$str); + $phpgw->template->parse("output","list",True); + $phpgw->template->set_var("field",lang("Participants")); + $phpgw->db->query("select account_id,account_lastname,account_firstname,account_lid " + . "from accounts where account_status !='L' and " + . "account_id != ".$phpgw_info["user"]["account_id"]." " + . "and account_permissions like '%:calendar:%' " + . "order by account_lastname,account_firstname,account_lid"); -db->query("select account_id,account_lid,account_lastname, account_firstname from " - . "accounts where account_status !='L' and account_lid != '" - . $phpgw_info["user"]["userid"] . "' and account_permissions like '%:calendar:%' " - . "order by account_lastname,account_firstname,account_lid"); + if ($phpgw->db->num_rows() > 50) + $size = 15; + else if ($phpgw->db->num_rows() > 5) + $size = 5; + else + $size = $phpgw->db->num_rows(); + $str = ""; + $str .= ""; + $phpgw->template->set_var("data",$str); + $phpgw->template->parse("output","list",True); - if ($phpgw->db->num_rows() > 50) - $size = 15; - else if ($phpgw->db->num_rows() > 5) - $size = 5; - else - $size = $phpgw->db->num_rows(); + $phpgw->template->set_var("field",lang("Repeat Type")); + $str = ""; + $phpgw->template->set_var("data",$str); + $phpgw->template->parse("output","list",True); - echo "" - . "\n"; + $year_html = ""; -?> + $str .= $phpgw->common->dateformatorder($year_html,$month_html,$day_html); + $phpgw->template->set_var("data",$str); + $phpgw->template->parse("output","list",True); - - - - - - - - - - - - - - - - -
: - -
: - -
: -"; - for ($i = 1; $i <= 31; $i++) - $day_html .= "
: - :minute<"9"?"0".$cal_info->minute:$cal_info->minute; ?>" MAXLENGTH=2> -am\n"; - echo "pm\n"; - } -?> -
:
:
: -
:"; + $str .= ""; + $str .= ""; + $str .= ""; + $str .= ""; + $phpgw->template->set_var("data",$str); + $phpgw->template->parse("output","list",True); + + $phpgw->template->set_var("field",lang("Access")); + $str = "
" . lang("Participants") . ":\nrpt_end_use) $str .= " checked"; + $str .= ">".lang("Use End Date")." "; - while ($phpgw->db->next_record()) { - echo "\n"; - } + $month_html = ""; - echo "" - . "
:rpt_sun?"checked":"")."> ".lang("Sunday")." "; + $str .= "rpt_mon?"checked":"")."> ".lang("Monday")." "; + $str .= "rpt_tue?"checked":"")."> ".lang("Tuesday")." "; + $str .= "rpt_wed?"checked":"")."> ".lang("Wednesday")." "; + $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); - echo ""; + $phpgw->template->set_var("field",lang("Frequency")); + $phpgw->template->set_var("data","rpt_freq."\">"); + $phpgw->template->parse("output","list",True); - echo ""; + $phpgw->template->set_var("submit_button",lang("Submit")); - echo ""; - - echo ""; - - echo ""; -?> - -
:rpt_end?"checked":""); ?>> - -"; - for ($i = 1; $i <= 31; $i++) { - $day_html .= "\n"; - } - $day_html .= ""; - - $month_html = ""; - - $year_html = ""; - - echo $phpgw->common->dateformatorder($year_html,$month_html,$day_html); -?> - -
: rpt_sun?"checked":"") . "> " . lang("Sunday"); - echo "rpt_mon?"checked":"") . "> " . lang("Monday"); - echo "rpt_tue?"checked":"") . "> " . lang("Tuesday"); - echo "rpt_wed?"checked":"") . "> " . lang("Wednesday"); - echo "rpt_thu?"checked":"") . "> " . lang("Thursday"); - echo "rpt_fri?"checked":"") . "> " . lang("Friday"); - echo "rpt_sat?"checked":"") . "> " . lang("Saturday"); - ?>
: - -
- - - - - - -
- - 0) { - echo "link("delete.php","id=$id") . "\" onClick=\"return confirm('" - . lang("Are you sure\\nyou want to\\ndelete this entry ?") . "');\">" - . lang("Delete") . "
"; - } - } // ***** This might be out of place. I was getting tons of parse errors - // from if ($can_edit) { This needs to be rewritten, because if you do - // not own the entry. You should not get into this portion of the program. + if ($id > 0) { + $phpgw->template->set_var("action_url",$phpgw->link("delete.php","id=$id")); + $phpgw->template->set_var("action_text",lang("Delete")); + $phpgw->template->parse("delete_button","form_button"); + $phpgw->template->pparse("out","edit_entry_end"); + } else { + $phpgw->template->set_var("delete_button",""); + $phpgw->template->pparse("out","edit_entry_end"); + } $phpgw->common->phpgw_footer(); + } ?> diff --git a/calendar/templates/default/edit.tpl b/calendar/templates/default/edit.tpl new file mode 100755 index 0000000000..a68a0bb93a --- /dev/null +++ b/calendar/templates/default/edit.tpl @@ -0,0 +1,47 @@ + + + + + +
+

{calendar_action}

+ +
+{common_hidden} + + + +{output} + + +
+ + + +
+ +{delete_button} +
+ + diff --git a/calendar/templates/default/form_button_script.tpl b/calendar/templates/default/form_button_script.tpl new file mode 100755 index 0000000000..4d78330454 --- /dev/null +++ b/calendar/templates/default/form_button_script.tpl @@ -0,0 +1,6 @@ + + +
+ +
+ diff --git a/calendar/templates/default/view.tpl b/calendar/templates/default/view.tpl index f5e83f522f..bf95d8863a 100755 --- a/calendar/templates/default/view.tpl +++ b/calendar/templates/default/view.tpl @@ -14,7 +14,7 @@

-{edit}      {delete} +{edit_button}      {delete_button} diff --git a/calendar/view.php b/calendar/view.php index 5a1fb81207..2722656941 100755 --- a/calendar/view.php +++ b/calendar/view.php @@ -48,9 +48,10 @@ $phpgw->template->set_file(array("view_begin" => "view.tpl", "list" => "list.tpl", - "view_end" => "view.tpl")); + "view_end" => "view.tpl", + "form_button"=> "form_button_script.tpl")); - $phpgw->template->set_block("view_begin","list","view_end"); + $phpgw->template->set_block("view_begin","list","view_end","form_button"); $phpgw->template->set_var("bg_color",$phpgw_info["theme"]["bg_text"]); $phpgw->template->set_var("name",$cal_info->name); @@ -155,11 +156,21 @@ } if ($is_my_event) { - $phpgw->template->set_var("edit","link("edit_entry.php","id=$id")."\">".lang("Edit").""); - $phpgw->template->set_var("delete","link("delete.php","id=$id")."\" onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."');\">".lang("Delete").""); + $phpgw->template->set_var("action_url",$phpgw->link("edit_entry.php","id=$id")); + $phpgw->template->set_var("action_text"," ".lang("Edit")." "); + $phpgw->template->set_var("action_confirm",""); + $phpgw->template->parse("edit_button","form_button"); + + $phpgw->template->set_var("action_url",$phpgw->link("delete.php","id=$id")); + $phpgw->template->set_var("action_text",lang("Delete")); + $phpgw->template->set_var("action_confirm","onClick=\"confirm(".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."\")"); + $phpgw->template->parse("delete_button","form_button"); + +// $phpgw->template->set_var("edit","link("edit_entry.php","id=$id")."\">".lang("Edit").""); +// $phpgw->template->set_var("delete","link("delete.php","id=$id")."\" onClick=\"return confirm('".lang("Are you sure\\nyou want to\\ndelete this entry ?\\n\\nThis will delete\\nthis entry for all users.")."');\">".lang("Delete").""); } else { - $phpgw->template->set_var("edit",""); - $phpgw->template->set_var("delete",""); + $phpgw->template->set_var("edit_button",""); + $phpgw->template->set_var("delete_button",""); } $phpgw->template->pparse("out","view_end"); $phpgw->common->phpgw_footer();