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