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