d61a01d4 |
1 | <?php |
7c67a5e8 |
2 | |
3 | /** |
4 | * event_edit.php |
5 | * |
6c84ba1e |
6 | * Copyright (c) 2002-2005 The SquirrelMail Project Team |
7c67a5e8 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
d61a01d4 |
8 | * |
7c67a5e8 |
9 | * Originally contrubuted by Michal Szczotka <michal@tuxy.org> |
d61a01d4 |
10 | * |
7c67a5e8 |
11 | * Functions to edit an event. |
d61a01d4 |
12 | * |
2c85de8f |
13 | * $Id$ |
ea5f4b8e |
14 | * @package plugins |
15 | * @subpackage calendar |
d61a01d4 |
16 | */ |
ea5f4b8e |
17 | |
18 | /** @ignore */ |
92219031 |
19 | define('SM_PATH','../../'); |
cf1efdce |
20 | |
8d6a115b |
21 | /* Calender plugin required files. */ |
22 | require_once(SM_PATH . 'plugins/calendar/calendar_data.php'); |
23 | require_once(SM_PATH . 'plugins/calendar/functions.php'); |
24 | |
cf1efdce |
25 | /* SquirrelMail required files. */ |
26 | require_once(SM_PATH . 'include/validate.php'); |
27 | require_once(SM_PATH . 'functions/strings.php'); |
28 | require_once(SM_PATH . 'functions/date.php'); |
29 | require_once(SM_PATH . 'config/config.php'); |
30 | require_once(SM_PATH . 'functions/page_header.php'); |
aa7fb30c |
31 | require_once(SM_PATH . 'include/load_prefs.php'); |
cf1efdce |
32 | require_once(SM_PATH . 'functions/html.php'); |
d61a01d4 |
33 | |
95dcee50 |
34 | |
35 | /* get globals */ |
36 | |
a6d3eff6 |
37 | // undo rg = on effects |
38 | if (isset($month)) unset($month); |
39 | if (isset($year)) unset($year); |
40 | if (isset($day)) unset($day); |
41 | if (isset($hour)) unset($hour); |
42 | if (isset($minute)) unset($minute); |
43 | if (isset($event_year)) unset($event_year); |
44 | if (isset($event_month)) unset($event_month); |
45 | if (isset($event_day)) unset($event_day); |
46 | if (isset($event_hour)) unset($event_hour); |
47 | if (isset($event_minute)) unset($event_minute); |
48 | if (isset($event_length)) unset($event_length); |
49 | if (isset($event_priority)) unset($event_priority); |
50 | |
95dcee50 |
51 | if (isset($_POST['updated'])) { |
52 | $updated = $_POST['updated']; |
53 | } |
a6d3eff6 |
54 | |
55 | if (isset($_POST['event_year']) && is_numeric($_POST['event_year'])) { |
95dcee50 |
56 | $event_year = $_POST['event_year']; |
57 | } |
a6d3eff6 |
58 | if (isset($_POST['event_month']) && is_numeric($_POST['event_month'])) { |
95dcee50 |
59 | $event_month = $_POST['event_month']; |
60 | } |
a6d3eff6 |
61 | if (isset($_POST['event_day']) && is_numeric($_POST['event_day'])) { |
95dcee50 |
62 | $event_day = $_POST['event_day']; |
63 | } |
a6d3eff6 |
64 | if (isset($_POST['event_hour']) && is_numeric($_POST['event_hour'])) { |
95dcee50 |
65 | $event_hour = $_POST['event_hour']; |
66 | } |
a6d3eff6 |
67 | if (isset($_POST['event_minute']) && is_numeric($_POST['event_minute'])) { |
95dcee50 |
68 | $event_minute = $_POST['event_minute']; |
69 | } |
a6d3eff6 |
70 | if (isset($_POST['event_length']) && is_numeric($_POST['event_length'])) { |
95dcee50 |
71 | $event_length = $_POST['event_length']; |
72 | } |
73 | if (isset($_POST['event_title'])) { |
74 | $event_title = $_POST['event_title']; |
75 | } |
76 | if (isset($_POST['event_text'])) { |
77 | $event_text = $_POST['event_text']; |
78 | } |
79 | if (isset($_POST['send'])) { |
80 | $send = $_POST['send']; |
81 | } |
a6d3eff6 |
82 | if (isset($_POST['event_priority']) && is_numeric($_POST['event_priority'])) { |
95dcee50 |
83 | $event_priority = $_POST['event_priority']; |
84 | } |
85 | if (isset($_POST['confirmed'])) { |
86 | $confirmed = $_POST['confirmed']; |
87 | } |
a6d3eff6 |
88 | |
89 | if (isset($_POST['year']) && is_numeric($_POST['year'])) { |
95dcee50 |
90 | $year = $_POST['year']; |
a6d3eff6 |
91 | } elseif (isset($_GET['year']) && is_numeric($_GET['year'])) { |
95dcee50 |
92 | $year = $_GET['year']; |
93 | } |
a6d3eff6 |
94 | if (isset($_POST['month']) && is_numeric($_POST['month'])) { |
95dcee50 |
95 | $month = $_POST['month']; |
a6d3eff6 |
96 | } elseif (isset($_GET['month']) && is_numeric($_GET['month'])) { |
95dcee50 |
97 | $month = $_GET['month']; |
98 | } |
a6d3eff6 |
99 | if (isset($_POST['day']) && is_numeric($_POST['day'])) { |
95dcee50 |
100 | $day = $_POST['day']; |
a6d3eff6 |
101 | } elseif (isset($_GET['day']) && is_numeric($_GET['day'])) { |
95dcee50 |
102 | $day = $_GET['day']; |
103 | } |
a6d3eff6 |
104 | if (isset($_POST['hour']) && is_numeric($_POST['hour'])) { |
95dcee50 |
105 | $hour = $_POST['hour']; |
a6d3eff6 |
106 | } elseif (isset($_GET['hour']) && is_numeric($_GET['hour'])) { |
95dcee50 |
107 | $hour = $_GET['hour']; |
108 | } |
a6d3eff6 |
109 | if (isset($_POST['minute']) && is_numeric($_POST['minute'])) { |
95dcee50 |
110 | $minute = $_POST['minute']; |
111 | } |
a6d3eff6 |
112 | elseif (isset($_GET['minute']) && is_numeric($_GET['minute'])) { |
95dcee50 |
113 | $minute = $_GET['minute']; |
114 | } |
115 | /* got 'em */ |
116 | |
d61a01d4 |
117 | // update event info |
9754afac |
118 | function update_event_form() { |
d61a01d4 |
119 | global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata; |
120 | |
121 | $tmparray = $calendardata["$month$day$year"]["$hour$minute"]; |
6fd95361 |
122 | echo "\n<form name=\"eventupdate\" action=\"event_edit.php\" method=\"post\">\n". |
123 | " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n". |
124 | " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n". |
125 | " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n". |
126 | " <input type=\"hidden\" name=\"hour\" value=\"$hour\" />\n". |
127 | " <input type=\"hidden\" name=\"minute\" value=\"$minute\" />\n". |
128 | " <input type=\"hidden\" name=\"updated\" value=\"yes\" />\n". |
b01b21d0 |
129 | html_tag( 'tr' ) . |
130 | html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" . |
131 | html_tag( 'td', '', 'left', $color[4] ) . |
6fd95361 |
132 | " <select name=\"event_year\">\n"; |
d61a01d4 |
133 | select_option_year($year); |
6fd95361 |
134 | echo " </select>\n" . |
d61a01d4 |
135 | " \n" . |
6fd95361 |
136 | " <select name=\"event_month\">\n"; |
d61a01d4 |
137 | select_option_month($month); |
6fd95361 |
138 | echo " </select>\n". |
d61a01d4 |
139 | " \n". |
6fd95361 |
140 | " <select name=\"event_day\">\n"; |
d61a01d4 |
141 | select_option_day($day); |
6fd95361 |
142 | echo " </select>\n". |
b01b21d0 |
143 | " </td></tr>\n". |
144 | html_tag( 'tr' ) . |
145 | html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" . |
146 | html_tag( 'td', '', 'left', $color[4] ) . |
6fd95361 |
147 | " <select name=\"event_hour\">\n"; |
d61a01d4 |
148 | select_option_hour($hour); |
6fd95361 |
149 | echo " </select>\n". |
d61a01d4 |
150 | " : \n". |
6fd95361 |
151 | " <select name=\"event_minute\">\n"; |
d61a01d4 |
152 | select_option_minute($minute); |
6fd95361 |
153 | echo " </select>\n". |
b01b21d0 |
154 | " </td></tr>\n". |
155 | html_tag( 'tr' ) . |
156 | html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" . |
157 | html_tag( 'td', '', 'left', $color[4] ) . |
6fd95361 |
158 | " <select name=\"event_length\">\n"; |
c02aafdc |
159 | select_option_length($tmparray['length']); |
6fd95361 |
160 | echo " </select>\n". |
b01b21d0 |
161 | " </td></tr>\n". |
162 | html_tag( 'tr' ) . |
163 | html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" . |
164 | html_tag( 'td', '', 'left', $color[4] ) . |
6fd95361 |
165 | " <select name=\"event_priority\">\n"; |
c02aafdc |
166 | select_option_priority($tmparray['priority']); |
6fd95361 |
167 | echo " </select>\n". |
b01b21d0 |
168 | " </td></tr>\n". |
169 | html_tag( 'tr' ) . |
170 | html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" . |
171 | html_tag( 'td', '', 'left', $color[4] ) . |
6fd95361 |
172 | " <input type=\"text\" name=\"event_title\" value=\"$tmparray[title]\" size=\"30\" maxlenght=\"50\" /><br />\n". |
b01b21d0 |
173 | " </td></tr>\n". |
174 | html_tag( 'td', |
6fd95361 |
175 | " <textarea name=\"event_text\" rows=\"5\" cols=\"$editor_size\" wrap=\"hard\">$tmparray[message]</textarea>\n" , |
b01b21d0 |
176 | 'left', $color[4], 'colspan="2"' ) . |
177 | '</tr>' . html_tag( 'tr' ) . |
178 | html_tag( 'td', |
6fd95361 |
179 | '<input type="submit" name="send" value="' . |
180 | _("Update Event") . "\" />\n" , |
b01b21d0 |
181 | 'left', $color[4], 'colspan="2"' ) . |
6fd95361 |
182 | "</tr></form>\n"; |
d61a01d4 |
183 | } |
184 | |
185 | // self explenatory |
186 | function confirm_update() { |
187 | global $calself, $year, $month, $day, $hour, $minute, $calendardata, $color, $event_year, $event_month, $event_day, $event_hour, $event_minute, $event_length, $event_priority, $event_title, $event_text; |
188 | |
189 | $tmparray = $calendardata["$month$day$year"]["$hour$minute"]; |
190 | |
b01b21d0 |
191 | echo html_tag( 'table', |
192 | html_tag( 'tr', |
6fd95361 |
193 | html_tag( 'th', _("Do you really want to change this event from:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n" |
b01b21d0 |
194 | ) . |
195 | html_tag( 'tr', |
196 | html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" . |
197 | html_tag( 'td', $month.'/'.$day.'/'.$year , 'left', $color[4] ) ."\n" |
198 | ) . |
199 | html_tag( 'tr', |
200 | html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" . |
201 | html_tag( 'td', $hour.':'.$minute , 'left', $color[4] ) ."\n" |
202 | ) . |
203 | html_tag( 'tr', |
204 | html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" . |
5d01bcce |
205 | html_tag( 'td', $tmparray['priority'] , 'left', $color[4] ) ."\n" |
b01b21d0 |
206 | ) . |
207 | html_tag( 'tr', |
208 | html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" . |
5d01bcce |
209 | html_tag( 'td', $tmparray['title'] , 'left', $color[4] ) ."\n" |
b01b21d0 |
210 | ) . |
211 | html_tag( 'tr', |
212 | html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" . |
5d01bcce |
213 | html_tag( 'td', $tmparray['message'] , 'left', $color[4] ) ."\n" |
b01b21d0 |
214 | ) . |
215 | html_tag( 'tr', |
6fd95361 |
216 | html_tag( 'th', _("to:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n" |
b01b21d0 |
217 | ) . |
d61a01d4 |
218 | |
b01b21d0 |
219 | html_tag( 'tr', |
220 | html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" . |
221 | html_tag( 'td', $event_month.'/'.$event_day.'/'.$event_year , 'left', $color[4] ) ."\n" |
222 | ) . |
223 | html_tag( 'tr', |
224 | html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" . |
225 | html_tag( 'td', $event_hour.':'.$event_minute , 'left', $color[4] ) ."\n" |
226 | ) . |
227 | html_tag( 'tr', |
228 | html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" . |
229 | html_tag( 'td', $event_priority , 'left', $color[4] ) ."\n" |
230 | ) . |
231 | html_tag( 'tr', |
232 | html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" . |
233 | html_tag( 'td', $event_title , 'left', $color[4] ) ."\n" |
234 | ) . |
235 | html_tag( 'tr', |
236 | html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" . |
237 | html_tag( 'td', $event_text , 'left', $color[4] ) ."\n" |
238 | ) . |
239 | html_tag( 'tr', |
240 | html_tag( 'td', |
6fd95361 |
241 | " <form name=\"updateevent\" method=\"post\" action=\"$calself\">\n". |
242 | " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n". |
243 | " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n". |
244 | " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n". |
245 | " <input type=\"hidden\" name=\"hour\" value=\"$hour\" />\n". |
246 | " <input type=\"hidden\" name=\"minute\" value=\"$minute\" />\n". |
247 | " <input type=\"hidden\" name=\"event_year\" value=\"$event_year\" />\n". |
248 | " <input type=\"hidden\" name=\"event_month\" value=\"$event_month\" />\n". |
249 | " <input type=\"hidden\" name=\"event_day\" value=\"$event_day\" />\n". |
250 | " <input type=\"hidden\" name=\"event_hour\" value=\"$event_hour\" />\n". |
251 | " <input type=\"hidden\" name=\"event_minute\" value=\"$event_minute\" />\n". |
252 | " <input type=\"hidden\" name=\"event_priority\" value=\"$event_priority\" />\n". |
253 | " <input type=\"hidden\" name=\"event_length\" value=\"$event_length\" />\n". |
254 | " <input type=\"hidden\" name=\"event_title\" value=\"$event_title\" />\n". |
255 | " <input type=\"hidden\" name=\"event_text\" value=\"$event_text\" />\n". |
256 | " <input type=\"hidden\" name=\"updated\" value=\"yes\" />\n". |
257 | " <input type=\"hidden\" name=\"confirmed\" value=\"yes\" />\n". |
258 | ' <input type="submit" value="' . _("Yes") . "\" />\n". |
259 | " </form>\n" , |
b01b21d0 |
260 | 'right', $color[4] ) ."\n" . |
261 | html_tag( 'td', |
6fd95361 |
262 | " <form name=\"nodelevent\" method=\"post\" action=\"day.php\">\n". |
263 | " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n". |
264 | " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n". |
265 | " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n". |
266 | ' <input type="submit" value="' . _("No") . "\" />\n". |
267 | " </form>\n" , |
b01b21d0 |
268 | 'left', $color[4] ) ."\n" |
269 | ) , |
270 | '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' ); |
d61a01d4 |
271 | } |
272 | |
273 | if ($month <= 0){ |
274 | $month = date( 'm' ); |
275 | } |
276 | if ($year <= 0){ |
277 | $year = date( 'Y' ); |
278 | } |
279 | if ($day <= 0){ |
280 | $day = date( 'd' ); |
281 | } |
282 | if ($hour <= 0){ |
283 | $hour = '08'; |
284 | } |
285 | |
286 | $calself=basename($PHP_SELF); |
287 | |
288 | displayPageHeader($color, 'None'); |
289 | //load calendar menu |
290 | calendar_header(); |
291 | |
b01b21d0 |
292 | echo html_tag( 'tr', '', '', $color[0] ) . |
293 | html_tag( 'td', '', 'left' ) . |
294 | html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) . |
295 | html_tag( 'tr' ) . |
296 | html_tag( 'td', |
f3409980 |
297 | date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) , |
b01b21d0 |
298 | 'left', '', 'colspan="2"' ); |
d61a01d4 |
299 | if (!isset($updated)){ |
300 | //get changes to event |
301 | readcalendardata(); |
9754afac |
302 | update_event_form(); |
d61a01d4 |
303 | } else { |
304 | if (!isset($confirmed)){ |
305 | //confirm changes |
306 | readcalendardata(); |
307 | // strip event text so it fits in one line |
308 | $event_text=nl2br($event_text); |
309 | $event_text=ereg_replace ("\n", '', $event_text); |
310 | $event_text=ereg_replace ("\r", '', $event_text); |
311 | confirm_update(); |
312 | } else { |
313 | update_event("$month$day$year", "$hour$minute"); |
b01b21d0 |
314 | echo html_tag( 'tr', |
315 | html_tag( 'td', _("Event updated!"), 'left' ) |
316 | ) . "\n"; |
317 | echo html_tag( 'tr', |
318 | html_tag( 'td', |
91e0dccc |
319 | "<a href=\"day.php?year=$year&month=$month&day=$day\">" . |
b01b21d0 |
320 | _("Day View") ."</a>", |
321 | 'left' ) |
322 | ) . "\n"; |
323 | |
2c85de8f |
324 | $fixdate = date( 'mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year)); |
d61a01d4 |
325 | //if event has been moved to different year then act accordingly |
326 | if ($year==$event_year){ |
327 | $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text"); |
328 | writecalendardata(); |
329 | } else { |
330 | writecalendardata(); |
331 | $year=$event_year; |
332 | $calendardata = array(); |
333 | readcalendardata(); |
334 | $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text"); |
335 | writecalendardata(); |
336 | } |
337 | } |
338 | } |
339 | |
340 | ?> |
341 | </table></td></tr></table> |
91e0dccc |
342 | </body></html> |