r2l by Yoav
[squirrelmail.git] / plugins / calendar / event_edit.php
CommitLineData
d61a01d4 1<?php
2/*
3 * event_edit.php
4 *
5 * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * Functions to edit an event.
9 *
2c85de8f 10 * $Id$
d61a01d4 11 */
12
13require_once('calendar_data.php');
14require_once('functions.php');
15chdir('..');
16require_once('../src/validate.php');
17require_once('../functions/strings.php');
18require_once('../functions/date.php');
19require_once('../config/config.php');
20require_once('../functions/page_header.php');
21require_once('../src/load_prefs.php');
b01b21d0 22require_once('../functions/html.php');
d61a01d4 23
24// update event info
25function show_event_form() {
26 global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
27
28 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
29 echo "\n<FORM name=eventupdate action=\"event_edit.php\" METHOD=POST >\n".
30 " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
31 " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
32 " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
33 " <INPUT TYPE=hidden NAME=\"hour\" VALUE=\"$hour\">\n".
34 " <INPUT TYPE=hidden NAME=\"minute\" VALUE=\"$minute\">\n".
35 " <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
b01b21d0 36 html_tag( 'tr' ) .
37 html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
38 html_tag( 'td', '', 'left', $color[4] ) .
d61a01d4 39 " <SELECT NAME=\"event_year\">\n";
40 select_option_year($year);
41 echo " </SELECT>\n" .
42 " &nbsp;&nbsp;\n" .
43 " <SELECT NAME=\"event_month\">\n";
44 select_option_month($month);
45 echo " </SELECT>\n".
46 " &nbsp;&nbsp;\n".
47 " <SELECT NAME=\"event_day\">\n";
48 select_option_day($day);
49 echo " </SELECT>\n".
b01b21d0 50 " </td></tr>\n".
51 html_tag( 'tr' ) .
52 html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
53 html_tag( 'td', '', 'left', $color[4] ) .
d61a01d4 54 " <SELECT NAME=\"event_hour\">\n";
55 select_option_hour($hour);
56 echo " </SELECT>\n".
57 " &nbsp;:&nbsp;\n".
58 " <SELECT NAME=\"event_minute\">\n";
59 select_option_minute($minute);
60 echo " </SELECT>\n".
b01b21d0 61 " </td></tr>\n".
62 html_tag( 'tr' ) .
63 html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
64 html_tag( 'td', '', 'left', $color[4] ) .
d61a01d4 65 " <SELECT NAME=\"event_length\">\n";
66 select_option_length($tmparray[length]);
67 echo " </SELECT>\n".
b01b21d0 68 " </td></tr>\n".
69 html_tag( 'tr' ) .
70 html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
71 html_tag( 'td', '', 'left', $color[4] ) .
d61a01d4 72 " <SELECT NAME=\"event_priority\">\n";
73 select_option_priority($tmparray[priority]);
74 echo " </SELECT>\n".
b01b21d0 75 " </td></tr>\n".
76 html_tag( 'tr' ) .
77 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
78 html_tag( 'td', '', 'left', $color[4] ) .
d61a01d4 79 " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"$tmparray[title]\" SIZE=30 MAXLENGTH=50><BR>\n".
b01b21d0 80 " </td></tr>\n".
81 html_tag( 'td',
82 " <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD>$tmparray[message]</TEXTAREA>\n" ,
83 'left', $color[4], 'colspan="2"' ) .
84 '</tr>' . html_tag( 'tr' ) .
85 html_tag( 'td',
86 "<INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
87 _("Update Event") . "\">\n" ,
88 'left', $color[4], 'colspan="2"' ) .
89 "</tr></FORM>\n";
d61a01d4 90}
91
92// self explenatory
93function confirm_update() {
94 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;
95
96 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
97
b01b21d0 98 echo html_tag( 'table',
99 html_tag( 'tr',
100 html_tag( 'th', _("Do you really want to change this event from:") . "<br>\n", '', $color[4], 'colspan="2"' ) ."\n"
101 ) .
102 html_tag( 'tr',
103 html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
104 html_tag( 'td', $month.'/'.$day.'/'.$year , 'left', $color[4] ) ."\n"
105 ) .
106 html_tag( 'tr',
107 html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
108 html_tag( 'td', $hour.':'.$minute , 'left', $color[4] ) ."\n"
109 ) .
110 html_tag( 'tr',
111 html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
112 html_tag( 'td', $tmparray[priority] , 'left', $color[4] ) ."\n"
113 ) .
114 html_tag( 'tr',
115 html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
116 html_tag( 'td', $tmparray[title] , 'left', $color[4] ) ."\n"
117 ) .
118 html_tag( 'tr',
119 html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
120 html_tag( 'td', $tmparray[message] , 'left', $color[4] ) ."\n"
121 ) .
122 html_tag( 'tr',
123 html_tag( 'th', _("to:") . "<br>\n", '', $color[4], 'colspan="2"' ) ."\n"
124 ) .
d61a01d4 125
b01b21d0 126 html_tag( 'tr',
127 html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
128 html_tag( 'td', $event_month.'/'.$event_day.'/'.$event_year , 'left', $color[4] ) ."\n"
129 ) .
130 html_tag( 'tr',
131 html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
132 html_tag( 'td', $event_hour.':'.$event_minute , 'left', $color[4] ) ."\n"
133 ) .
134 html_tag( 'tr',
135 html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
136 html_tag( 'td', $event_priority , 'left', $color[4] ) ."\n"
137 ) .
138 html_tag( 'tr',
139 html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
140 html_tag( 'td', $event_title , 'left', $color[4] ) ."\n"
141 ) .
142 html_tag( 'tr',
143 html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
144 html_tag( 'td', $event_text , 'left', $color[4] ) ."\n"
145 ) .
146 html_tag( 'tr',
147 html_tag( 'td',
148 " <FORM NAME=\"updateevent\" METHOD=POST ACTION=\"$calself\">\n".
149 " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
150 " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
151 " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
152 " <INPUT TYPE=HIDDEN NAME=\"hour\" VALUE=\"$hour\">\n".
153 " <INPUT TYPE=HIDDEN NAME=\"minute\" VALUE=\"$minute\">\n".
154 " <INPUT TYPE=HIDDEN NAME=\"event_year\" VALUE=\"$event_year\">\n".
155 " <INPUT TYPE=HIDDEN NAME=\"event_month\" VALUE=\"$event_month\">\n".
156 " <INPUT TYPE=HIDDEN NAME=\"event_day\" VALUE=\"$event_day\">\n".
157 " <INPUT TYPE=HIDDEN NAME=\"event_hour\" VALUE=\"$event_hour\">\n".
158 " <INPUT TYPE=HIDDEN NAME=\"event_minute\" VALUE=\"$event_minute\">\n".
159 " <INPUT TYPE=HIDDEN NAME=\"event_priority\" VALUE=\"$event_priority\">\n".
160 " <INPUT TYPE=HIDDEN NAME=\"event_length\" VALUE=\"$event_length\">\n".
161 " <INPUT TYPE=HIDDEN NAME=\"event_title\" VALUE=\"$event_title\">\n".
162 " <INPUT TYPE=HIDDEN NAME=\"event_text\" VALUE=\"$event_text\">\n".
163 " <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
164 " <INPUT TYPE=HIDDEN NAME=\"confirmed\" VALUE=\"yes\">\n".
165 ' <INPUT TYPE=SUBMIT VALUE="' . _("Yes") . "\">\n".
166 " </FORM>\n" ,
167 'right', $color[4] ) ."\n" .
168 html_tag( 'td',
169 " <FORM NAME=\"nodelevent\" METHOD=POST ACTION=\"day.php\">\n".
170 " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
171 " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
172 " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
173 ' <INPUT TYPE=SUBMIT VALUE="' . _("No") . "\">\n".
174 " </FORM>\n" ,
175 'left', $color[4] ) ."\n"
176 ) ,
177 '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' );
d61a01d4 178}
179
180if ($month <= 0){
181 $month = date( 'm' );
182}
183if ($year <= 0){
184 $year = date( 'Y' );
185}
186if ($day <= 0){
187 $day = date( 'd' );
188}
189if ($hour <= 0){
190 $hour = '08';
191}
192
193$calself=basename($PHP_SELF);
194
195displayPageHeader($color, 'None');
196//load calendar menu
197calendar_header();
198
b01b21d0 199echo html_tag( 'tr', '', '', $color[0] ) .
200 html_tag( 'td', '', 'left' ) .
201 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
202 html_tag( 'tr' ) .
203 html_tag( 'td',
204 date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) ,
205 'left', '', 'colspan="2"' );
d61a01d4 206if (!isset($updated)){
207 //get changes to event
208 readcalendardata();
209 show_event_form();
210} else {
211 if (!isset($confirmed)){
212 //confirm changes
213 readcalendardata();
214 // strip event text so it fits in one line
215 $event_text=nl2br($event_text);
216 $event_text=ereg_replace ("\n", '', $event_text);
217 $event_text=ereg_replace ("\r", '', $event_text);
218 confirm_update();
219 } else {
220 update_event("$month$day$year", "$hour$minute");
b01b21d0 221 echo html_tag( 'tr',
222 html_tag( 'td', _("Event updated!"), 'left' )
223 ) . "\n";
224 echo html_tag( 'tr',
225 html_tag( 'td',
226 "<a href=\"day.php?year=$year&month=$month&day=$day\">" .
227 _("Day View") ."</a>",
228 'left' )
229 ) . "\n";
230
2c85de8f 231 $fixdate = date( 'mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year));
d61a01d4 232 //if event has been moved to different year then act accordingly
233 if ($year==$event_year){
234 $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
235 writecalendardata();
236 } else {
237 writecalendardata();
238 $year=$event_year;
239 $calendardata = array();
240 readcalendardata();
241 $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
242 writecalendardata();
243 }
244 }
245}
246
247?>
248</table></td></tr></table>
beb218e0 249</body></html>