A start for a new change_password master plugin. This is not finished
[squirrelmail.git] / plugins / calendar / event_edit.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
4 * event_edit.php
5 *
76911253 6 * Copyright (c) 2002-2003 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
106function show_event_form() {
107 global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
108
109 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
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] ) .
d61a01d4 120 " <SELECT NAME=\"event_year\">\n";
121 select_option_year($year);
122 echo " </SELECT>\n" .
123 " &nbsp;&nbsp;\n" .
124 " <SELECT NAME=\"event_month\">\n";
125 select_option_month($month);
126 echo " </SELECT>\n".
127 " &nbsp;&nbsp;\n".
128 " <SELECT NAME=\"event_day\">\n";
129 select_option_day($day);
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] ) .
d61a01d4 135 " <SELECT NAME=\"event_hour\">\n";
136 select_option_hour($hour);
137 echo " </SELECT>\n".
138 " &nbsp;:&nbsp;\n".
139 " <SELECT NAME=\"event_minute\">\n";
140 select_option_minute($minute);
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] ) .
d61a01d4 146 " <SELECT NAME=\"event_length\">\n";
c02aafdc 147 select_option_length($tmparray['length']);
d61a01d4 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] ) .
d61a01d4 153 " <SELECT NAME=\"event_priority\">\n";
c02aafdc 154 select_option_priority($tmparray['priority']);
d61a01d4 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] ) .
d61a01d4 160 " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"$tmparray[title]\" SIZE=30 MAXLENGTH=50><BR>\n".
b01b21d0 161 " </td></tr>\n".
162 html_tag( 'td',
163 " <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD>$tmparray[message]</TEXTAREA>\n" ,
164 'left', $color[4], 'colspan="2"' ) .
165 '</tr>' . html_tag( 'tr' ) .
166 html_tag( 'td',
167 "<INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
168 _("Update Event") . "\">\n" ,
169 'left', $color[4], 'colspan="2"' ) .
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',
181 html_tag( 'th', _("Do you really want to change this event from:") . "<br>\n", '', $color[4], 'colspan="2"' ) ."\n"
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',
204 html_tag( 'th', _("to:") . "<br>\n", '', $color[4], 'colspan="2"' ) ."\n"
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',
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" ,
248 'right', $color[4] ) ."\n" .
249 html_tag( 'td',
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" ,
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();
290 show_event_form();
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',
1ba8cd6b 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>
beb218e0 330</body></html>