d61a01d4 |
1 | <?php /* Modified at 1 places by ri_once */ ?> |
2 | <?php |
3 | /* |
4 | * event_edit.php |
5 | * |
6 | * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org> |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Functions to edit an event. |
10 | * |
11 | * 18 Jan 2002 Adapted to official SM rules philippe@squirrelmail.org. |
12 | */ |
13 | |
14 | require_once('calendar_data.php'); |
15 | require_once('functions.php'); |
16 | chdir('..'); |
17 | require_once('../src/validate.php'); |
18 | require_once('../functions/strings.php'); |
19 | require_once('../functions/date.php'); |
20 | require_once('../config/config.php'); |
21 | require_once('../functions/page_header.php'); |
22 | require_once('../src/load_prefs.php'); |
23 | |
24 | // update event info |
25 | function 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". |
36 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Date:") . "</TD>\n". |
37 | " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n". |
38 | " <SELECT NAME=\"event_year\">\n"; |
39 | select_option_year($year); |
40 | echo " </SELECT>\n" . |
41 | " \n" . |
42 | " <SELECT NAME=\"event_month\">\n"; |
43 | select_option_month($month); |
44 | echo " </SELECT>\n". |
45 | " \n". |
46 | " <SELECT NAME=\"event_day\">\n"; |
47 | select_option_day($day); |
48 | echo " </SELECT>\n". |
49 | " </TD></TR>\n". |
50 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Time:") . "</TD>\n". |
51 | " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n". |
52 | " <SELECT NAME=\"event_hour\">\n"; |
53 | select_option_hour($hour); |
54 | echo " </SELECT>\n". |
55 | " : \n". |
56 | " <SELECT NAME=\"event_minute\">\n"; |
57 | select_option_minute($minute); |
58 | echo " </SELECT>\n". |
59 | " </TD></TR>\n". |
60 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Length:") . "</TD>\n". |
61 | " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n". |
62 | " <SELECT NAME=\"event_length\">\n"; |
63 | select_option_length($tmparray[length]); |
64 | echo " </SELECT>\n". |
65 | " </TD></TR>\n". |
66 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Priority:") . "</TD>\n". |
67 | " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n". |
68 | " <SELECT NAME=\"event_priority\">\n"; |
69 | select_option_priority($tmparray[priority]); |
70 | echo " </SELECT>\n". |
71 | " </TD></TR>\n". |
72 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Title:") . "</TD>\n". |
73 | " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n". |
74 | " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"$tmparray[title]\" SIZE=30 MAXLENGTH=50><BR>\n". |
75 | " </TD></TR>\n". |
76 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT COLSPAN=2>\n". |
77 | " <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD>$tmparray[message]</TEXTAREA>\n". |
78 | " </TD></TR>\n". |
79 | " <TR><TD ALIGN=LEFT BGCOLOR=\"$color[4]\" COLSPAN=2><INPUT TYPE=SUBMIT NAME=send VALUE=\"" . |
80 | _("Update Event") . "\"></TD></TR>\n". |
81 | "</FORM>\n"; |
82 | } |
83 | |
84 | // self explenatory |
85 | function confirm_update() { |
86 | 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; |
87 | |
88 | $tmparray = $calendardata["$month$day$year"]["$hour$minute"]; |
89 | |
90 | echo " <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n". |
91 | " <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n". |
92 | _("Do you really want to change this event from:") . "<br>\n". |
93 | " </TH></TR>\n". |
94 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n". |
95 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$month/$day/$year</TD></TR>\n". |
96 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n". |
97 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$hour:$minute</TD></TR>\n". |
98 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Priority:") . "</TD>\n". |
99 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[priority]</TD></TR>\n". |
100 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n". |
101 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[title]</TD></TR>\n". |
102 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n". |
103 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[message]</TD></TR>\n". |
104 | " <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n". |
105 | _("to:") . "<br>\n". |
106 | " </TH></TR>\n". |
107 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n". |
108 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_month/$event_day/$event_year</TD></TR>\n". |
109 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . ("Time:") . "</TD>\n". |
110 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_hour:$event_minute</TD></TR>\n". |
111 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Priority:") . "</TD>\n". |
112 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_priority</TD></TR>\n". |
113 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n". |
114 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_title</TD></TR>\n". |
115 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n". |
116 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_text</TD></TR>\n". |
117 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">\n". |
118 | " <FORM NAME=\"updateevent\" METHOD=POST ACTION=\"$calself\">\n". |
119 | " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n". |
120 | " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n". |
121 | " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n". |
122 | " <INPUT TYPE=HIDDEN NAME=\"hour\" VALUE=\"$hour\">\n". |
123 | " <INPUT TYPE=HIDDEN NAME=\"minute\" VALUE=\"$minute\">\n". |
124 | " <INPUT TYPE=HIDDEN NAME=\"event_year\" VALUE=\"$event_year\">\n". |
125 | " <INPUT TYPE=HIDDEN NAME=\"event_month\" VALUE=\"$event_month\">\n". |
126 | " <INPUT TYPE=HIDDEN NAME=\"event_day\" VALUE=\"$event_day\">\n". |
127 | " <INPUT TYPE=HIDDEN NAME=\"event_hour\" VALUE=\"$event_hour\">\n". |
128 | " <INPUT TYPE=HIDDEN NAME=\"event_minute\" VALUE=\"$event_minute\">\n". |
129 | " <INPUT TYPE=HIDDEN NAME=\"event_priority\" VALUE=\"$event_priority\">\n". |
130 | " <INPUT TYPE=HIDDEN NAME=\"event_length\" VALUE=\"$event_length\">\n". |
131 | " <INPUT TYPE=HIDDEN NAME=\"event_title\" VALUE=\"$event_title\">\n". |
132 | " <INPUT TYPE=HIDDEN NAME=\"event_text\" VALUE=\"$event_text\">\n". |
133 | " <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n". |
134 | " <INPUT TYPE=HIDDEN NAME=\"confirmed\" VALUE=\"yes\">\n". |
135 | ' <INPUT TYPE=SUBMIT VALUE="' . _("Yes") . "\">\n". |
136 | " </FORM>\n". |
137 | " </TD><TD ALIGN=LEFT BGCOLOR=\"$color[4]\">\n". |
138 | " <FORM NAME=\"nodelevent\" METHOD=POST ACTION=\"day.php\">\n". |
139 | " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n". |
140 | " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n". |
141 | " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n". |
142 | ' <INPUT TYPE=SUBMIT VALUE="' . _("No") . "\">\n". |
143 | " </FORM>\n". |
144 | " </TD></TR>\n". |
145 | " </TABLE>\n"; |
146 | |
147 | } |
148 | |
149 | if ($month <= 0){ |
150 | $month = date( 'm' ); |
151 | } |
152 | if ($year <= 0){ |
153 | $year = date( 'Y' ); |
154 | } |
155 | if ($day <= 0){ |
156 | $day = date( 'd' ); |
157 | } |
158 | if ($hour <= 0){ |
159 | $hour = '08'; |
160 | } |
161 | |
162 | $calself=basename($PHP_SELF); |
163 | |
164 | displayPageHeader($color, 'None'); |
165 | //load calendar menu |
166 | calendar_header(); |
167 | |
168 | echo "<TR BGCOLOR=\"$color[0]\"><TD>" . |
169 | "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">" . |
170 | '<tr><td COLSPAN=2>' . |
171 | date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)); |
172 | ?></td></tr><?php /* 'php' Added by ri_once */ |
173 | if (!isset($updated)){ |
174 | //get changes to event |
175 | readcalendardata(); |
176 | show_event_form(); |
177 | } else { |
178 | if (!isset($confirmed)){ |
179 | //confirm changes |
180 | readcalendardata(); |
181 | // strip event text so it fits in one line |
182 | $event_text=nl2br($event_text); |
183 | $event_text=ereg_replace ("\n", '', $event_text); |
184 | $event_text=ereg_replace ("\r", '', $event_text); |
185 | confirm_update(); |
186 | } else { |
187 | update_event("$month$day$year", "$hour$minute"); |
188 | echo "<tr><td>Event updated!</td></tr>\n"; |
189 | echo "<tr><td><A HREF=\"day.php?year=$year&month=$month&day=$day\">Day View</A></td></tr>\n"; |
190 | $fixdate = date( "mdY", mktime(0, 0, 0, $event_month, $event_day, $event_year)); |
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> |
208 | </body></html> |
209 | |