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 * Include the SquirrelMail initialization file.
16 require('../../include/init.php');
18 /* SquirrelMail required files. */
21 include_once(SM_PATH
. 'functions/date.php');
23 include_once(SM_PATH
. 'functions/forms.php');
25 /* Calendar plugin required files. */
26 include_once(SM_PATH
. 'plugins/calendar/calendar_data.php');
27 include_once(SM_PATH
. 'plugins/calendar/functions.php');
31 sqGetGlobalVar('updated',$updated,SQ_POST
);
33 /* get date values and make sure that they are numeric */
34 if (! sqGetGlobalVar('event_year',$event_year,SQ_POST
) ||
! is_numeric($event_year)) {
37 if (! sqGetGlobalVar('event_month',$event_month,SQ_POST
) ||
! is_numeric($event_month)) {
40 if (! sqGetGlobalVar('event_day',$event_day,SQ_POST
) ||
! is_numeric($event_day)) {
43 if (! sqGetGlobalVar('event_hour',$event_hour,SQ_POST
) ||
! is_numeric($event_hour)) {
46 if (! sqGetGlobalVar('event_minute',$event_minute,SQ_POST
) ||
! is_numeric($event_minute)) {
49 if (! sqGetGlobalVar('event_length',$event_length,SQ_POST
) ||
! is_numeric($event_length)) {
52 sqGetGlobalVar('event_title',$event_title,SQ_POST
);
53 sqGetGlobalVar('event_text',$event_text,SQ_POST
);
54 sqGetGlobalVar('send',$send,SQ_POST
);
56 if (! sqGetGlobalVar('event_priority',$event_priority,SQ_POST
) ||
! is_numeric($event_priority)) {
57 unset($event_priority);
60 sqGetGlobalVar('confirmed',$confirmed,SQ_POST
);
62 if (! sqGetGlobalVar('year',$year,SQ_FORM
) ||
! is_numeric($year)) {
65 if (! sqGetGlobalVar('month',$month,SQ_FORM
) ||
! is_numeric($month)) {
68 if (! sqGetGlobalVar('day',$day,SQ_FORM
) ||
! is_numeric($day)) {
71 if (! sqGetGlobalVar('hour',$hour,SQ_FORM
) ||
! is_numeric($hour)) {
74 if (! sqGetGlobalVar('minute',$minute,SQ_FORM
) ||
! is_numeric($minute)) {
84 function update_event_form() {
85 global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
87 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
89 echo "\n<form name=\"eventupdate\" action=\"event_edit.php\" method=\"post\">\n".
90 $tab . addHidden('year',$year).
91 $tab . addHidden('month',$month).
92 $tab . addHidden('day',$day).
93 $tab . addHidden('hour',$hour).
94 $tab . addHidden('minute',$minute).
95 $tab . addHidden('updated','yes').
97 html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
98 html_tag( 'td', '', 'left', $color[4] ) .
99 " <select name=\"event_year\">\n";
100 select_option_year($year);
101 echo " </select>\n" .
103 " <select name=\"event_month\">\n";
104 select_option_month($month);
107 " <select name=\"event_day\">\n";
108 select_option_day($day);
112 html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
113 html_tag( 'td', '', 'left', $color[4] ) .
114 " <select name=\"event_hour\">\n";
115 select_option_hour($hour);
118 " <select name=\"event_minute\">\n";
119 select_option_minute($minute);
123 html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
124 html_tag( 'td', '', 'left', $color[4] ) .
125 " <select name=\"event_length\">\n";
126 select_option_length($tmparray['length']);
130 html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
131 html_tag( 'td', '', 'left', $color[4] ) .
132 " <select name=\"event_priority\">\n";
133 select_option_priority($tmparray['priority']);
137 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
138 html_tag( 'td', addInput('event_title',$tmparray['title'],30,50), 'left', $color[4]) .
141 html_tag( 'td', addTextArea('event_text',$tmparray['message'],$editor_size,5),
142 'left', $color[4], 'colspan="2"' ) .
143 '</tr>' . html_tag( 'tr' ) .
144 html_tag( 'td', addSubmit(_("Update Event"),'send'), 'left', $color[4], 'colspan="2"' ) .
149 * Confirms event update
153 function confirm_update() {
154 global $calself, $year, $month, $day, $hour, $minute, $calendardata,
155 $color, $event_year, $event_month, $event_day, $event_hour,
156 $event_minute, $event_length, $event_priority, $event_title, $event_text;
158 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
161 echo html_tag( 'table',
163 html_tag( 'th', _("Do you really want to change this event from:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n"
166 html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
167 html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$month,$day,$year)), 'left', $color[4] ) ."\n"
170 html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
171 html_tag( 'td', date_intl(_("H:i"),mktime($hour,$minute,0,$month,$day,$year)) , 'left', $color[4] ) ."\n"
174 html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
175 html_tag( 'td', $tmparray['priority'] , 'left', $color[4] ) ."\n"
178 html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
179 html_tag( 'td', htmlspecialchars($tmparray['title']) , 'left', $color[4] ) ."\n"
182 html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
183 html_tag( 'td', nl2br(htmlspecialchars($tmparray['message'])) , 'left', $color[4] ) ."\n"
186 html_tag( 'th', _("to:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n"
190 html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
191 html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$event_month,$event_day,$event_year)), 'left', $color[4] ) ."\n"
194 html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
195 html_tag( 'td', date_intl(_("H:i"),mktime($event_hour,$event_minute,0,$event_month,$event_day,$event_year)), 'left', $color[4] ) ."\n"
198 html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
199 html_tag( 'td', $event_priority , 'left', $color[4] ) ."\n"
202 html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
203 html_tag( 'td', htmlspecialchars($event_title) , 'left', $color[4] ) ."\n"
206 html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
207 html_tag( 'td', nl2br(htmlspecialchars($event_text)) , 'left', $color[4] ) ."\n"
211 "<form name=\"updateevent\" method=\"post\" action=\"$calself\">\n".
212 $tab . addHidden('year',$year).
213 $tab . addHidden('month',$month).
214 $tab . addHidden('day',$day).
215 $tab . addHidden('hour',$hour).
216 $tab . addHidden('minute',$minute).
217 $tab . addHidden('event_year',$event_year).
218 $tab . addHidden('event_month',$event_month).
219 $tab . addHidden('event_day',$event_day).
220 $tab . addHidden('event_hour',$event_hour).
221 $tab . addHidden('event_minute',$event_minute).
222 $tab . addHidden('event_priority',$event_priority).
223 $tab . addHidden('event_length',$event_length).
224 $tab . addHidden('event_title',$event_title).
225 $tab . addHidden('event_text',$event_text).
226 $tab . addHidden('updated','yes').
227 $tab . addHidden('confirmed','yes').
228 $tab . addSubmit(_("Yes")).
230 'right', $color[4] ) ."\n" .
232 "<form name=\"nodelevent\" method=\"post\" action=\"day.php\">\n".
233 $tab . addHidden('year',$year).
234 $tab . addHidden('month',$month).
235 $tab . addHidden('day',$day).
236 $tab . addSubmit(_("No")).
238 'left', $color[4] ) ."\n"
240 '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' );
244 $month = date( 'm' );
256 $calself=basename($PHP_SELF);
258 displayPageHeader($color, 'None');
262 echo html_tag( 'tr', '', '', $color[0] ) .
263 html_tag( 'td', '', 'left' ) .
264 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
267 date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
268 'left', '', 'colspan="2"' );
269 if (!isset($updated)){
270 //get changes to event
274 if (!isset($confirmed)){
279 update_event("$month$day$year", "$hour$minute");
281 html_tag( 'td', _("Event updated!"), 'left' )
285 "<a href=\"day.php?year=$year&month=$month&day=$day\">" .
286 _("Day View") ."</a>",
290 $fixdate = date( 'mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year));
291 //if event has been moved to different year then act accordingly
292 if ($year==$event_year){
293 $calendardata["$fixdate"]["$event_hour$event_minute"] = array('length' => $event_length,
294 'priority' => $event_priority,
295 'title' => $event_title,
296 'message' => $event_text);
301 $calendardata = array();
303 $calendardata["$fixdate"]["$event_hour$event_minute"] = array('length' => $event_length,
304 'priority' => $event_priority,
305 'title' => $event_title,
306 'message' => $event_text);
313 </table
></td
></tr
></table
>