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