4 * Functions to edit an event.
6 * @copyright © 2002-2006 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
10 * @subpackage calendar
14 define('SM_PATH','../../');
16 /* SquirrelMail required files. */
17 include_once(SM_PATH
. 'include/validate.php');
19 include_once(SM_PATH
. 'functions/date.php');
21 include_once(SM_PATH
. 'functions/forms.php');
23 /* Calendar plugin required files. */
24 include_once(SM_PATH
. 'plugins/calendar/calendar_data.php');
25 include_once(SM_PATH
. 'plugins/calendar/functions.php');
29 sqGetGlobalVar('updated',$updated,SQ_POST
);
31 /* get date values and make sure that they are numeric */
32 if (! sqGetGlobalVar('event_year',$event_year,SQ_POST
) ||
! is_numeric($event_year)) {
35 if (! sqGetGlobalVar('event_month',$event_month,SQ_POST
) ||
! is_numeric($event_month)) {
38 if (! sqGetGlobalVar('event_day',$event_day,SQ_POST
) ||
! is_numeric($event_day)) {
41 if (! sqGetGlobalVar('event_hour',$event_hour,SQ_POST
) ||
! is_numeric($event_hour)) {
44 if (! sqGetGlobalVar('event_minute',$event_minute,SQ_POST
) ||
! is_numeric($event_minute)) {
47 if (! sqGetGlobalVar('event_length',$event_length,SQ_POST
) ||
! is_numeric($event_length)) {
50 sqGetGlobalVar('event_title',$event_title,SQ_POST
);
51 sqGetGlobalVar('event_text',$event_text,SQ_POST
);
52 sqGetGlobalVar('send',$send,SQ_POST
);
54 if (! sqGetGlobalVar('event_priority',$event_priority,SQ_POST
) ||
! is_numeric($event_priority)) {
55 unset($event_priority);
58 sqGetGlobalVar('confirmed',$confirmed,SQ_POST
);
60 if (! sqGetGlobalVar('year',$year,SQ_FORM
) ||
! is_numeric($year)) {
63 if (! sqGetGlobalVar('month',$month,SQ_FORM
) ||
! is_numeric($month)) {
66 if (! sqGetGlobalVar('day',$day,SQ_FORM
) ||
! is_numeric($day)) {
69 if (! sqGetGlobalVar('hour',$hour,SQ_FORM
) ||
! is_numeric($hour)) {
72 if (! sqGetGlobalVar('minute',$minute,SQ_FORM
) ||
! is_numeric($minute)) {
82 function update_event_form() {
83 global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
85 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
87 echo "\n<form name=\"eventupdate\" action=\"event_edit.php\" method=\"post\">\n".
88 $tab . addHidden('year',$year).
89 $tab . addHidden('month',$month).
90 $tab . addHidden('day',$day).
91 $tab . addHidden('hour',$hour).
92 $tab . addHidden('minute',$minute).
93 $tab . addHidden('updated','yes').
95 html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
96 html_tag( 'td', '', 'left', $color[4] ) .
97 " <select name=\"event_year\">\n";
98 select_option_year($year);
101 " <select name=\"event_month\">\n";
102 select_option_month($month);
105 " <select name=\"event_day\">\n";
106 select_option_day($day);
110 html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
111 html_tag( 'td', '', 'left', $color[4] ) .
112 " <select name=\"event_hour\">\n";
113 select_option_hour($hour);
116 " <select name=\"event_minute\">\n";
117 select_option_minute($minute);
121 html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
122 html_tag( 'td', '', 'left', $color[4] ) .
123 " <select name=\"event_length\">\n";
124 select_option_length($tmparray['length']);
128 html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
129 html_tag( 'td', '', 'left', $color[4] ) .
130 " <select name=\"event_priority\">\n";
131 select_option_priority($tmparray['priority']);
135 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
136 html_tag( 'td', addInput('event_title',$tmparray['title'],30,50), 'left', $color[4]) .
139 html_tag( 'td', addTextArea('event_text',$tmparray['message'],$editor_size,5),
140 'left', $color[4], 'colspan="2"' ) .
141 '</tr>' . html_tag( 'tr' ) .
142 html_tag( 'td', addSubmit(_("Update Event"),'send'), 'left', $color[4], 'colspan="2"' ) .
147 * Confirms event update
151 function confirm_update() {
152 global $calself, $year, $month, $day, $hour, $minute, $calendardata,
153 $color, $event_year, $event_month, $event_day, $event_hour,
154 $event_minute, $event_length, $event_priority, $event_title, $event_text;
156 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
159 echo html_tag( 'table',
161 html_tag( 'th', _("Do you really want to change this event from:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n"
164 html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
165 html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$month,$day,$year)), 'left', $color[4] ) ."\n"
168 html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
169 html_tag( 'td', date_intl(_("H:i"),mktime($hour,$minute,0,$month,$day,$year)) , 'left', $color[4] ) ."\n"
172 html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
173 html_tag( 'td', $tmparray['priority'] , 'left', $color[4] ) ."\n"
176 html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
177 html_tag( 'td', htmlspecialchars($tmparray['title']) , 'left', $color[4] ) ."\n"
180 html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
181 html_tag( 'td', nl2br(htmlspecialchars($tmparray['message'])) , 'left', $color[4] ) ."\n"
184 html_tag( 'th', _("to:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n"
188 html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
189 html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$event_month,$event_day,$event_year)), 'left', $color[4] ) ."\n"
192 html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
193 html_tag( 'td', date_intl(_("H:i"),mktime($event_hour,$event_minute,0,$event_month,$event_day,$event_year)), 'left', $color[4] ) ."\n"
196 html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
197 html_tag( 'td', $event_priority , 'left', $color[4] ) ."\n"
200 html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
201 html_tag( 'td', htmlspecialchars($event_title) , 'left', $color[4] ) ."\n"
204 html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
205 html_tag( 'td', nl2br(htmlspecialchars($event_text)) , 'left', $color[4] ) ."\n"
209 "<form name=\"updateevent\" method=\"post\" action=\"$calself\">\n".
210 $tab . addHidden('year',$year).
211 $tab . addHidden('month',$month).
212 $tab . addHidden('day',$day).
213 $tab . addHidden('hour',$hour).
214 $tab . addHidden('minute',$minute).
215 $tab . addHidden('event_year',$event_year).
216 $tab . addHidden('event_month',$event_month).
217 $tab . addHidden('event_day',$event_day).
218 $tab . addHidden('event_hour',$event_hour).
219 $tab . addHidden('event_minute',$event_minute).
220 $tab . addHidden('event_priority',$event_priority).
221 $tab . addHidden('event_length',$event_length).
222 $tab . addHidden('event_title',$event_title).
223 $tab . addHidden('event_text',$event_text).
224 $tab . addHidden('updated','yes').
225 $tab . addHidden('confirmed','yes').
226 $tab . addSubmit(_("Yes")).
228 'right', $color[4] ) ."\n" .
230 "<form name=\"nodelevent\" method=\"post\" action=\"day.php\">\n".
231 $tab . addHidden('year',$year).
232 $tab . addHidden('month',$month).
233 $tab . addHidden('day',$day).
234 $tab . addSubmit(_("No")).
236 'left', $color[4] ) ."\n"
238 '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' );
242 $month = date( 'm' );
254 $calself=basename($PHP_SELF);
256 displayPageHeader($color, 'None');
260 echo html_tag( 'tr', '', '', $color[0] ) .
261 html_tag( 'td', '', 'left' ) .
262 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
265 date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
266 'left', '', 'colspan="2"' );
267 if (!isset($updated)){
268 //get changes to event
272 if (!isset($confirmed)){
277 update_event("$month$day$year", "$hour$minute");
279 html_tag( 'td', _("Event updated!"), 'left' )
283 "<a href=\"day.php?year=$year&month=$month&day=$day\">" .
284 _("Day View") ."</a>",
288 $fixdate = date( 'mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year));
289 //if event has been moved to different year then act accordingly
290 if ($year==$event_year){
291 $calendardata["$fixdate"]["$event_hour$event_minute"] = array('length' => $event_length,
292 'priority' => $event_priority,
293 'title' => $event_title,
294 'message' => $event_text);
299 $calendardata = array();
301 $calendardata["$fixdate"]["$event_hour$event_minute"] = array('length' => $event_length,
302 'priority' => $event_priority,
303 'title' => $event_title,
304 'message' => $event_text);
311 </table
></td
></tr
></table
>