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