Typo
[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');
22
23// update event info
24function show_event_form() {
25 global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
26
27 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
28 echo "\n<FORM name=eventupdate action=\"event_edit.php\" METHOD=POST >\n".
29 " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
30 " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
31 " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
32 " <INPUT TYPE=hidden NAME=\"hour\" VALUE=\"$hour\">\n".
33 " <INPUT TYPE=hidden NAME=\"minute\" VALUE=\"$minute\">\n".
34 " <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
35 " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Date:") . "</TD>\n".
36 " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
37 " <SELECT NAME=\"event_year\">\n";
38 select_option_year($year);
39 echo " </SELECT>\n" .
40 " &nbsp;&nbsp;\n" .
41 " <SELECT NAME=\"event_month\">\n";
42 select_option_month($month);
43 echo " </SELECT>\n".
44 " &nbsp;&nbsp;\n".
45 " <SELECT NAME=\"event_day\">\n";
46 select_option_day($day);
47 echo " </SELECT>\n".
48 " </TD></TR>\n".
49 " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Time:") . "</TD>\n".
50 " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
51 " <SELECT NAME=\"event_hour\">\n";
52 select_option_hour($hour);
53 echo " </SELECT>\n".
54 " &nbsp;:&nbsp;\n".
55 " <SELECT NAME=\"event_minute\">\n";
56 select_option_minute($minute);
57 echo " </SELECT>\n".
58 " </TD></TR>\n".
59 " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Length:") . "</TD>\n".
60 " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
61 " <SELECT NAME=\"event_length\">\n";
62 select_option_length($tmparray[length]);
63 echo " </SELECT>\n".
64 " </TD></TR>\n".
65 " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Priority:") . "</TD>\n".
66 " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
67 " <SELECT NAME=\"event_priority\">\n";
68 select_option_priority($tmparray[priority]);
69 echo " </SELECT>\n".
70 " </TD></TR>\n".
71 " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Title:") . "</TD>\n".
72 " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
73 " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"$tmparray[title]\" SIZE=30 MAXLENGTH=50><BR>\n".
74 " </TD></TR>\n".
75 " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT COLSPAN=2>\n".
76 " <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD>$tmparray[message]</TEXTAREA>\n".
77 " </TD></TR>\n".
78 " <TR><TD ALIGN=LEFT BGCOLOR=\"$color[4]\" COLSPAN=2><INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
79 _("Update Event") . "\"></TD></TR>\n".
80 "</FORM>\n";
81}
82
83// self explenatory
84function confirm_update() {
85 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;
86
87 $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
88
89 echo " <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n".
90 " <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
91 _("Do you really want to change this event from:") . "<br>\n".
92 " </TH></TR>\n".
93 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
94 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$month/$day/$year</TD></TR>\n".
95 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n".
96 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$hour:$minute</TD></TR>\n".
97 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Priority:") . "</TD>\n".
98 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[priority]</TD></TR>\n".
99 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n".
100 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[title]</TD></TR>\n".
101 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n".
102 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[message]</TD></TR>\n".
103 " <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
104 _("to:") . "<br>\n".
105 " </TH></TR>\n".
106 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
107 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_month/$event_day/$event_year</TD></TR>\n".
108 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . ("Time:") . "</TD>\n".
109 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_hour:$event_minute</TD></TR>\n".
110 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Priority:") . "</TD>\n".
111 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_priority</TD></TR>\n".
112 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n".
113 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_title</TD></TR>\n".
114 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n".
115 " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_text</TD></TR>\n".
116 " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">\n".
117 " <FORM NAME=\"updateevent\" METHOD=POST ACTION=\"$calself\">\n".
118 " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
119 " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
120 " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
121 " <INPUT TYPE=HIDDEN NAME=\"hour\" VALUE=\"$hour\">\n".
122 " <INPUT TYPE=HIDDEN NAME=\"minute\" VALUE=\"$minute\">\n".
123 " <INPUT TYPE=HIDDEN NAME=\"event_year\" VALUE=\"$event_year\">\n".
124 " <INPUT TYPE=HIDDEN NAME=\"event_month\" VALUE=\"$event_month\">\n".
125 " <INPUT TYPE=HIDDEN NAME=\"event_day\" VALUE=\"$event_day\">\n".
126 " <INPUT TYPE=HIDDEN NAME=\"event_hour\" VALUE=\"$event_hour\">\n".
127 " <INPUT TYPE=HIDDEN NAME=\"event_minute\" VALUE=\"$event_minute\">\n".
128 " <INPUT TYPE=HIDDEN NAME=\"event_priority\" VALUE=\"$event_priority\">\n".
129 " <INPUT TYPE=HIDDEN NAME=\"event_length\" VALUE=\"$event_length\">\n".
130 " <INPUT TYPE=HIDDEN NAME=\"event_title\" VALUE=\"$event_title\">\n".
131 " <INPUT TYPE=HIDDEN NAME=\"event_text\" VALUE=\"$event_text\">\n".
132 " <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
133 " <INPUT TYPE=HIDDEN NAME=\"confirmed\" VALUE=\"yes\">\n".
134 ' <INPUT TYPE=SUBMIT VALUE="' . _("Yes") . "\">\n".
135 " </FORM>\n".
136 " </TD><TD ALIGN=LEFT BGCOLOR=\"$color[4]\">\n".
137 " <FORM NAME=\"nodelevent\" METHOD=POST ACTION=\"day.php\">\n".
138 " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
139 " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
140 " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
141 ' <INPUT TYPE=SUBMIT VALUE="' . _("No") . "\">\n".
142 " </FORM>\n".
143 " </TD></TR>\n".
144 " </TABLE>\n";
145
146}
147
148if ($month <= 0){
149 $month = date( 'm' );
150}
151if ($year <= 0){
152 $year = date( 'Y' );
153}
154if ($day <= 0){
155 $day = date( 'd' );
156}
157if ($hour <= 0){
158 $hour = '08';
159}
160
161$calself=basename($PHP_SELF);
162
163displayPageHeader($color, 'None');
164//load calendar menu
165calendar_header();
166
167echo "<TR BGCOLOR=\"$color[0]\"><TD>" .
168 "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">" .
169 '<tr><td COLSPAN=2>' .
2c85de8f 170 date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) .
171 '</td></tr>';
d61a01d4 172if (!isset($updated)){
173 //get changes to event
174 readcalendardata();
175 show_event_form();
176} else {
177 if (!isset($confirmed)){
178 //confirm changes
179 readcalendardata();
180 // strip event text so it fits in one line
181 $event_text=nl2br($event_text);
182 $event_text=ereg_replace ("\n", '', $event_text);
183 $event_text=ereg_replace ("\r", '', $event_text);
184 confirm_update();
185 } else {
186 update_event("$month$day$year", "$hour$minute");
beb218e0 187 echo "<tr><td>" . _("Event updated!") . "</td></tr>\n";
2c85de8f 188 echo "<tr><td><A HREF=\"day.php?year=$year&month=$month&day=$day\">" .
189 _("Day View") ."</A></td></tr>\n";
190 $fixdate = date( 'mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year));
d61a01d4 191 //if event has been moved to different year then act accordingly
192 if ($year==$event_year){
193 $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
194 writecalendardata();
195 } else {
196 writecalendardata();
197 $year=$event_year;
198 $calendardata = array();
199 readcalendardata();
200 $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
201 writecalendardata();
202 }
203 }
204}
205
206?>
207</table></td></tr></table>
beb218e0 208</body></html>