d61a01d4 |
1 | <?php |
7c67a5e8 |
2 | |
3 | /** |
4 | * event_create.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 create a event for calendar. |
d61a01d4 |
12 | * |
2c85de8f |
13 | * $Id$ |
d61a01d4 |
14 | */ |
92219031 |
15 | define('SM_PATH','../../'); |
cf1efdce |
16 | |
8d6a115b |
17 | /* Calender plugin required files. */ |
18 | require_once(SM_PATH . 'plugins/calendar/calendar_data.php'); |
19 | require_once(SM_PATH . 'plugins/calendar/functions.php'); |
20 | |
cf1efdce |
21 | /* SquirrelMail required files. */ |
22 | require_once(SM_PATH . 'include/validate.php'); |
23 | require_once(SM_PATH . 'functions/strings.php'); |
24 | require_once(SM_PATH . 'functions/date.php'); |
25 | require_once(SM_PATH . 'config/config.php'); |
26 | require_once(SM_PATH . 'functions/page_header.php'); |
aa7fb30c |
27 | require_once(SM_PATH . 'include/load_prefs.php'); |
cf1efdce |
28 | require_once(SM_PATH . 'functions/html.php'); |
d61a01d4 |
29 | |
95dcee50 |
30 | /* get globals */ |
31 | |
32 | if (isset($_POST['year'])) { |
33 | $year = $_POST['year']; |
34 | } |
35 | elseif (isset($_GET['year'])) { |
36 | $year = $_GET['year']; |
37 | } |
38 | if (isset($_POST['month'])) { |
39 | $month = $_POST['month']; |
40 | } |
41 | elseif (isset($_GET['month'])) { |
42 | $month = $_GET['month']; |
43 | } |
44 | if (isset($_POST['day'])) { |
45 | $day = $_POST['day']; |
46 | } |
47 | elseif (isset($_GET['day'])) { |
48 | $day = $_GET['day']; |
49 | } |
50 | if (isset($_POST['hour'])) { |
51 | $hour = $_POST['hour']; |
52 | } |
53 | elseif (isset($_GET['hour'])) { |
54 | $hour = $_GET['hour']; |
55 | } |
56 | if (isset($_POST['event_hour'])) { |
57 | $event_hour = $_POST['event_hour']; |
58 | } |
59 | if (isset($_POST['event_minute'])) { |
60 | $event_minute = $_POST['event_minute']; |
61 | } |
62 | if (isset($_POST['event_length'])) { |
63 | $event_length = $_POST['event_length']; |
64 | } |
65 | if (isset($_POST['event_priority'])) { |
66 | $event_priority = $_POST['event_priority']; |
67 | } |
68 | if (isset($_POST['event_title'])) { |
69 | $event_title = $_POST['event_title']; |
70 | } |
71 | if (isset($_POST['event_text'])) { |
72 | $event_text = $_POST['event_text']; |
73 | } |
74 | if (isset($_POST['send'])) { |
75 | $send = $_POST['send']; |
76 | } |
77 | /* got 'em */ |
78 | |
d61a01d4 |
79 | //main form to gather event info |
80 | function show_event_form() { |
81 | global $color, $editor_size, $year, $day, $month, $hour; |
82 | |
83 | echo "\n<FORM name=eventscreate action=\"event_create.php\" METHOD=POST >\n". |
84 | " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n". |
85 | " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n". |
86 | " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n". |
b01b21d0 |
87 | html_tag( 'tr' ) . |
88 | html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" . |
89 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
d61a01d4 |
90 | " <SELECT NAME=\"event_hour\">\n"; |
91 | select_option_hour($hour); |
92 | echo " </SELECT>\n" . |
93 | " : \n" . |
94 | " <SELECT NAME=\"event_minute\">\n"; |
95 | select_option_minute("00"); |
96 | echo " </SELECT>\n". |
b01b21d0 |
97 | " </td></tr>\n". |
98 | html_tag( 'tr' ) . |
99 | html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" . |
100 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
d61a01d4 |
101 | " <SELECT NAME=\"event_length\">\n"; |
102 | select_option_length("0"); |
103 | echo " </SELECT>\n". |
b01b21d0 |
104 | " </td></tr>\n". |
105 | html_tag( 'tr' ) . |
106 | html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" . |
107 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
d61a01d4 |
108 | " <SELECT NAME=\"event_priority\">\n"; |
109 | select_option_priority("0"); |
110 | echo " </SELECT>\n". |
b01b21d0 |
111 | " </td></tr>\n". |
112 | html_tag( 'tr' ) . |
113 | html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" . |
114 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
d61a01d4 |
115 | " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n". |
b01b21d0 |
116 | " </td></tr>\n". |
117 | html_tag( 'tr', |
118 | html_tag( 'td', |
119 | "<TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD></TEXTAREA>" , |
120 | 'left', $color[4], 'colspan="2"' ) |
121 | ) ."\n" . |
122 | html_tag( 'tr', |
123 | html_tag( 'td', |
124 | "<INPUT TYPE=SUBMIT NAME=send VALUE=\"" . |
125 | _("Set Event") . "\">" , |
126 | 'left', $color[4], 'colspan="2"' ) |
127 | ) ."\n"; |
d61a01d4 |
128 | echo "</FORM>\n"; |
129 | } |
130 | |
131 | |
88cb1b4d |
132 | if ( !isset($month) || $month <= 0){ |
d61a01d4 |
133 | $month = date( 'm' ); |
134 | } |
88cb1b4d |
135 | if ( !isset($year) || $year <= 0){ |
d61a01d4 |
136 | $year = date( 'Y' ); |
137 | } |
88cb1b4d |
138 | if (!isset($day) || $day <= 0){ |
d61a01d4 |
139 | $day = date( 'd' ); |
140 | } |
88cb1b4d |
141 | if (!isset($hour) || $hour <= 0){ |
d61a01d4 |
142 | $hour = '08'; |
143 | } |
144 | |
145 | $calself=basename($PHP_SELF); |
146 | |
147 | |
148 | displayPageHeader($color, 'None'); |
149 | //load calendar menu |
150 | calendar_header(); |
151 | |
b01b21d0 |
152 | echo html_tag( 'tr', '', '', $color[0] ) . |
153 | html_tag( 'td', '', 'left' ) . |
154 | html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) . |
155 | html_tag( 'tr', |
f3409980 |
156 | html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' ) |
b01b21d0 |
157 | ); |
d61a01d4 |
158 | //if form has not been filled in |
159 | if(!isset($event_text)){ |
160 | show_event_form(); |
161 | } else { |
162 | readcalendardata(); |
163 | //make sure that event text is fittting in one line |
164 | $event_text=nl2br($event_text); |
165 | $event_text=ereg_replace ("\n", "", $event_text); |
166 | $event_text=ereg_replace ("\r", "", $event_text); |
88cb1b4d |
167 | $calendardata["$month$day$year"]["$event_hour$event_minute"] = |
168 | array( 'length' => $event_length, |
169 | 'priority' => $event_priority, |
170 | 'title' => $event_title, |
171 | 'message' => $event_text, |
172 | 'reminder' => '' ); |
d61a01d4 |
173 | //save |
174 | writecalendardata(); |
b01b21d0 |
175 | echo html_tag( 'table', |
176 | html_tag( 'tr', |
177 | html_tag( 'th', _("Event Has been added!") . "<br>\n", '', $color[4], 'colspan="2"' ) |
178 | ) . |
179 | html_tag( 'tr', |
180 | html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" . |
181 | html_tag( 'td', $month .'/'.$day.'/'.$year, 'left', $color[4] ) . "\n" |
182 | ) . |
183 | html_tag( 'tr', |
184 | html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" . |
185 | html_tag( 'td', $event_hour.':'.$event_minute, 'left', $color[4] ) . "\n" |
186 | ) . |
187 | html_tag( 'tr', |
188 | html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" . |
94e0aaf9 |
189 | html_tag( 'td', htmlentities($event_title,ENT_NOQUOTES), 'left', $color[4] ) . "\n" |
b01b21d0 |
190 | ) . |
191 | html_tag( 'tr', |
192 | html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" . |
94e0aaf9 |
193 | html_tag( 'td', htmlentities($event_text,ENT_NOQUOTES), 'left', $color[4] ) . "\n" |
b01b21d0 |
194 | ) . |
195 | html_tag( 'tr', |
196 | html_tag( 'td', |
1ba8cd6b |
197 | "<a href=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</a>\n" , |
b01b21d0 |
198 | 'left', $color[4], 'colspan="2"' ) . "\n" |
199 | ) , |
200 | '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n"; |
d61a01d4 |
201 | } |
202 | |
203 | ?> |
204 | </table></td></tr></table> |
f3409980 |
205 | </body></html> |