Happy New Year
[squirrelmail.git] / plugins / calendar / event_edit.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
7c67a5e8 4 * Functions to edit an event.
d61a01d4 5 *
c4faef33 6 * @copyright 2002-2020 The SquirrelMail Project Team
4b4abf93 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
ea5f4b8e 9 * @package plugins
10 * @subpackage calendar
d61a01d4 11 */
ea5f4b8e 12
202bcbcc 13/**
14 * Include the SquirrelMail initialization file.
15 */
16require('../../include/init.php');
cf1efdce 17
18/* SquirrelMail required files. */
202bcbcc 19
1c7143ad 20/* date_intl() */
21include_once(SM_PATH . 'functions/date.php');
22/* form functions */
23include_once(SM_PATH . 'functions/forms.php');
d61a01d4 24
1c7143ad 25/* Calendar plugin required files. */
26include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
27include_once(SM_PATH . 'plugins/calendar/functions.php');
95dcee50 28
29/* get globals */
30
1c7143ad 31sqGetGlobalVar('updated',$updated,SQ_POST);
a6d3eff6 32
1c7143ad 33/* get date values and make sure that they are numeric */
34if (! sqGetGlobalVar('event_year',$event_year,SQ_POST) || ! is_numeric($event_year)) {
35 unset($event_year);
95dcee50 36}
1c7143ad 37if (! sqGetGlobalVar('event_month',$event_month,SQ_POST) || ! is_numeric($event_month)) {
38 unset($event_month);
95dcee50 39}
1c7143ad 40if (! sqGetGlobalVar('event_day',$event_day,SQ_POST) || ! is_numeric($event_day)) {
41 unset($event_day);
95dcee50 42}
1c7143ad 43if (! sqGetGlobalVar('event_hour',$event_hour,SQ_POST) || ! is_numeric($event_hour)) {
44 unset($event_hour);
95dcee50 45}
1c7143ad 46if (! sqGetGlobalVar('event_minute',$event_minute,SQ_POST) || ! is_numeric($event_minute)) {
47 unset($event_minute);
95dcee50 48}
1c7143ad 49if (! sqGetGlobalVar('event_length',$event_length,SQ_POST) || ! is_numeric($event_length)) {
50 unset($event_length);
95dcee50 51}
1c7143ad 52sqGetGlobalVar('event_title',$event_title,SQ_POST);
53sqGetGlobalVar('event_text',$event_text,SQ_POST);
54sqGetGlobalVar('send',$send,SQ_POST);
a6d3eff6 55
1c7143ad 56if (! sqGetGlobalVar('event_priority',$event_priority,SQ_POST) || ! is_numeric($event_priority)) {
57 unset($event_priority);
95dcee50 58}
1c7143ad 59
60sqGetGlobalVar('confirmed',$confirmed,SQ_POST);
61
62if (! sqGetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
63 unset($year);
95dcee50 64}
1c7143ad 65if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
66 unset($month);
95dcee50 67}
1c7143ad 68if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) {
69 unset($day);
95dcee50 70}
1c7143ad 71if (! sqGetGlobalVar('hour',$hour,SQ_FORM) || ! is_numeric($hour)) {
72 unset($hour);
95dcee50 73}
1c7143ad 74if (! sqGetGlobalVar('minute',$minute,SQ_FORM) || ! is_numeric($minute)) {
75 unset($minute);
95dcee50 76}
77/* got 'em */
78
1c7143ad 79/**
80 * update event info
81 * @return void
82 * @access private
83 */
9754afac 84function update_event_form() {
d61a01d4 85 global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
86
87 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
1c7143ad 88 $tab = ' ';
6fd95361 89 echo "\n<form name=\"eventupdate\" action=\"event_edit.php\" method=\"post\">\n".
1c7143ad 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').
b01b21d0 96 html_tag( 'tr' ) .
97 html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
98 html_tag( 'td', '', 'left', $color[4] ) .
6fd95361 99 " <select name=\"event_year\">\n";
d61a01d4 100 select_option_year($year);
6fd95361 101 echo " </select>\n" .
d61a01d4 102 " &nbsp;&nbsp;\n" .
6fd95361 103 " <select name=\"event_month\">\n";
d61a01d4 104 select_option_month($month);
6fd95361 105 echo " </select>\n".
d61a01d4 106 " &nbsp;&nbsp;\n".
6fd95361 107 " <select name=\"event_day\">\n";
d61a01d4 108 select_option_day($day);
6fd95361 109 echo " </select>\n".
b01b21d0 110 " </td></tr>\n".
111 html_tag( 'tr' ) .
112 html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
113 html_tag( 'td', '', 'left', $color[4] ) .
6fd95361 114 " <select name=\"event_hour\">\n";
d61a01d4 115 select_option_hour($hour);
6fd95361 116 echo " </select>\n".
d61a01d4 117 " &nbsp;:&nbsp;\n".
6fd95361 118 " <select name=\"event_minute\">\n";
d61a01d4 119 select_option_minute($minute);
6fd95361 120 echo " </select>\n".
b01b21d0 121 " </td></tr>\n".
122 html_tag( 'tr' ) .
123 html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
124 html_tag( 'td', '', 'left', $color[4] ) .
6fd95361 125 " <select name=\"event_length\">\n";
c02aafdc 126 select_option_length($tmparray['length']);
6fd95361 127 echo " </select>\n".
b01b21d0 128 " </td></tr>\n".
129 html_tag( 'tr' ) .
130 html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
131 html_tag( 'td', '', 'left', $color[4] ) .
6fd95361 132 " <select name=\"event_priority\">\n";
c02aafdc 133 select_option_priority($tmparray['priority']);
6fd95361 134 echo " </select>\n".
b01b21d0 135 " </td></tr>\n".
136 html_tag( 'tr' ) .
137 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
1c7143ad 138 html_tag( 'td', addInput('event_title',$tmparray['title'],30,50), 'left', $color[4]) .
139 "\n</tr>\n".
140 html_tag( 'tr' ) .
141 html_tag( 'td', addTextArea('event_text',$tmparray['message'],$editor_size,5),
142 'left', $color[4], 'colspan="2"' ) .
b01b21d0 143 '</tr>' . html_tag( 'tr' ) .
1c7143ad 144 html_tag( 'td', addSubmit(_("Update Event"),'send'), 'left', $color[4], 'colspan="2"' ) .
6fd95361 145 "</tr></form>\n";
d61a01d4 146}
147
1c7143ad 148/**
149 * Confirms event update
150 * @return void
151 * @access private
152 */
d61a01d4 153function confirm_update() {
1c7143ad 154 global $calself, $year, $month, $day, $hour, $minute, $calendardata,
202bcbcc 155 $color, $event_year, $event_month, $event_day, $event_hour,
1c7143ad 156 $event_minute, $event_length, $event_priority, $event_title, $event_text;
d61a01d4 157
158 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
1c7143ad 159 $tab = ' ';
d61a01d4 160
b01b21d0 161 echo html_tag( 'table',
162 html_tag( 'tr',
6fd95361 163 html_tag( 'th', _("Do you really want to change this event from:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n"
b01b21d0 164 ) .
165 html_tag( 'tr',
166 html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
f1d482ae 167 html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$month,$day,$year)), 'left', $color[4] ) ."\n"
b01b21d0 168 ) .
169 html_tag( 'tr',
170 html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
f1d482ae 171 html_tag( 'td', date_intl(_("H:i"),mktime($hour,$minute,0,$month,$day,$year)) , 'left', $color[4] ) ."\n"
b01b21d0 172 ) .
173 html_tag( 'tr',
174 html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
5d01bcce 175 html_tag( 'td', $tmparray['priority'] , 'left', $color[4] ) ."\n"
b01b21d0 176 ) .
177 html_tag( 'tr',
178 html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
3047e291 179 html_tag( 'td', sm_encode_html_special_chars($tmparray['title']) , 'left', $color[4] ) ."\n"
b01b21d0 180 ) .
181 html_tag( 'tr',
182 html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
3047e291 183 html_tag( 'td', nl2br(sm_encode_html_special_chars($tmparray['message'])) , 'left', $color[4] ) ."\n"
b01b21d0 184 ) .
185 html_tag( 'tr',
6fd95361 186 html_tag( 'th', _("to:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n"
b01b21d0 187 ) .
d61a01d4 188
b01b21d0 189 html_tag( 'tr',
190 html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
f1d482ae 191 html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$event_month,$event_day,$event_year)), 'left', $color[4] ) ."\n"
b01b21d0 192 ) .
193 html_tag( 'tr',
194 html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
f1d482ae 195 html_tag( 'td', date_intl(_("H:i"),mktime($event_hour,$event_minute,0,$event_month,$event_day,$event_year)), 'left', $color[4] ) ."\n"
b01b21d0 196 ) .
197 html_tag( 'tr',
198 html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
199 html_tag( 'td', $event_priority , 'left', $color[4] ) ."\n"
200 ) .
201 html_tag( 'tr',
202 html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
3047e291 203 html_tag( 'td', sm_encode_html_special_chars($event_title) , 'left', $color[4] ) ."\n"
b01b21d0 204 ) .
205 html_tag( 'tr',
206 html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
3047e291 207 html_tag( 'td', nl2br(sm_encode_html_special_chars($event_text)) , 'left', $color[4] ) ."\n"
b01b21d0 208 ) .
209 html_tag( 'tr',
210 html_tag( 'td',
1c7143ad 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")).
229 "</form>\n" ,
b01b21d0 230 'right', $color[4] ) ."\n" .
231 html_tag( 'td',
1c7143ad 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")).
237 "</form>\n" ,
b01b21d0 238 'left', $color[4] ) ."\n"
239 ) ,
240 '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' );
d61a01d4 241}
242
243if ($month <= 0){
244 $month = date( 'm' );
245}
246if ($year <= 0){
247 $year = date( 'Y' );
248}
249if ($day <= 0){
250 $day = date( 'd' );
251}
252if ($hour <= 0){
253 $hour = '08';
254}
255
256$calself=basename($PHP_SELF);
257
876fdb60 258displayPageHeader($color);
d61a01d4 259//load calendar menu
260calendar_header();
261
b01b21d0 262echo html_tag( 'tr', '', '', $color[0] ) .
263 html_tag( 'td', '', 'left' ) .
264 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
265 html_tag( 'tr' ) .
266 html_tag( 'td',
f3409980 267 date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
b01b21d0 268 'left', '', 'colspan="2"' );
d61a01d4 269if (!isset($updated)){
270 //get changes to event
271 readcalendardata();
9754afac 272 update_event_form();
d61a01d4 273} else {
274 if (!isset($confirmed)){
275 //confirm changes
276 readcalendardata();
d61a01d4 277 confirm_update();
278 } else {
279 update_event("$month$day$year", "$hour$minute");
b01b21d0 280 echo html_tag( 'tr',
281 html_tag( 'td', _("Event updated!"), 'left' )
282 ) . "\n";
283 echo html_tag( 'tr',
284 html_tag( 'td',
91e0dccc 285 "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" .
b01b21d0 286 _("Day View") ."</a>",
287 'left' )
288 ) . "\n";
289
2c85de8f 290 $fixdate = date( 'mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year));
d61a01d4 291 //if event has been moved to different year then act accordingly
292 if ($year==$event_year){
1c7143ad 293 $calendardata["$fixdate"]["$event_hour$event_minute"] = array('length' => $event_length,
294 'priority' => $event_priority,
295 'title' => $event_title,
296 'message' => $event_text);
d61a01d4 297 writecalendardata();
298 } else {
299 writecalendardata();
300 $year=$event_year;
301 $calendardata = array();
302 readcalendardata();
1c7143ad 303 $calendardata["$fixdate"]["$event_hour$event_minute"] = array('length' => $event_length,
304 'priority' => $event_priority,
305 'title' => $event_title,
306 'message' => $event_text);
d61a01d4 307 writecalendardata();
308 }
309 }
310}
311
312?>
313</table></td></tr></table>
876fdb60 314</body></html>