prevent output in plugins/*/setup.php files.
[squirrelmail.git] / plugins / calendar / event_create.php
... / ...
CommitLineData
1<?php
2
3/**
4 * event_create.php
5 *
6 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
7 *
8 * functions to create a event for calendar.
9 *
10 * @copyright &copy; 2002-2005 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @version $Id$
13 * @package plugins
14 * @subpackage calendar
15 */
16
17/**
18 * @ignore
19 */
20define('SM_PATH','../../');
21
22/* Calender plugin required files. */
23require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
24require_once(SM_PATH . 'plugins/calendar/functions.php');
25
26/* SquirrelMail required files. */
27require_once(SM_PATH . 'include/validate.php');
28require_once(SM_PATH . 'functions/strings.php');
29require_once(SM_PATH . 'functions/date.php');
30require_once(SM_PATH . 'config/config.php');
31require_once(SM_PATH . 'functions/page_header.php');
32require_once(SM_PATH . 'include/load_prefs.php');
33require_once(SM_PATH . 'functions/html.php');
34
35/* get globals */
36
37// undo rg = on effects
38if (isset($month)) unset($month);
39if (isset($year)) unset($year);
40if (isset($day)) unset($day);
41if (isset($hour)) unset($hour);
42if (isset($minute)) unset($minute);
43if (isset($event_hour)) unset($event_hour);
44if (isset($event_minute)) unset($event_minute);
45if (isset($event_length)) unset($event_length);
46if (isset($event_priority)) unset($event_priority);
47
48
49if (isset($_GET['year']) && is_numeric($_GET['year'])) {
50 $year = $_GET['year'];
51}
52elseif (isset($_POST['year']) && is_numeric($_POST['year'])) {
53 $year = $_POST['year'];
54}
55if (isset($_GET['month']) && is_numeric($_GET['month'])) {
56 $month = $_GET['month'];
57}
58elseif (isset($_POST['month']) && is_numeric($_POST['month'])) {
59 $month = $_POST['month'];
60}
61if (isset($_GET['day']) && is_numeric($_GET['day'])) {
62 $day = $_GET['day'];
63}
64elseif (isset($_POST['day']) && is_numeric($_POST['day'])) {
65 $day = $_POST['day'];
66}
67
68if (isset($_POST['hour']) && is_numeric($_POST['hour'])) {
69 $hour = $_POST['hour'];
70}
71elseif (isset($_GET['hour']) && is_numeric($_GET['hour'])) {
72 $hour = $_GET['hour'];
73}
74if (isset($_POST['event_hour']) && is_numeric($_POST['event_hour'])) {
75 $event_hour = $_POST['event_hour'];
76}
77if (isset($_POST['event_minute']) && is_numeric($_POST['event_minute'])) {
78 $event_minute = $_POST['event_minute'];
79}
80if (isset($_POST['event_length']) && is_numeric($_POST['event_length'])) {
81 $event_length = $_POST['event_length'];
82}
83if (isset($_POST['event_priority']) && is_numeric($_POST['event_priority'])) {
84 $event_priority = $_POST['event_priority'];
85}
86if (isset($_POST['event_title'])) {
87 $event_title = $_POST['event_title'];
88}
89if (isset($_POST['event_text'])) {
90 $event_text = $_POST['event_text'];
91}
92if (isset($_POST['send'])) {
93 $send = $_POST['send'];
94}
95/* got 'em */
96
97//main form to gather event info
98function show_event_form() {
99 global $color, $editor_size, $year, $day, $month, $hour;
100
101 echo "\n<form name=\"eventscreate\" action=\"event_create.php\" method=\"post\">\n".
102 " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n".
103 " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n".
104 " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n".
105 html_tag( 'tr' ) .
106 html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" .
107 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
108 " <select name=\"event_hour\">\n";
109 select_option_hour($hour);
110 echo " </select>\n" .
111 " &nbsp;:&nbsp;\n" .
112 " <select name=\"event_minute\">\n";
113 select_option_minute("00");
114 echo " </select>\n".
115 " </td></tr>\n".
116 html_tag( 'tr' ) .
117 html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
118 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
119 " <select name=\"event_length\">\n";
120 select_option_length("0");
121 echo " </select>\n".
122 " </td></tr>\n".
123 html_tag( 'tr' ) .
124 html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
125 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
126 " <select name=\"event_priority\">\n";
127 select_option_priority("0");
128 echo " </select>\n".
129 " </td></tr>\n".
130 html_tag( 'tr' ) .
131 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
132 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
133 " <input type=\"text\" name=\"event_title\" value=\"\" size=\"30\" maxlength=\"50\" /><br />\n".
134 " </td></tr>\n".
135 html_tag( 'tr',
136 html_tag( 'td',
137 "<textarea name=\"event_text\" rows=\"5\" cols=\"$editor_size\" wrap=\"hard\"></textarea>" ,
138 'left', $color[4], 'colspan="2"' )
139 ) ."\n" .
140 html_tag( 'tr',
141 html_tag( 'td',
142 '<input type="submit" name="send" value="' .
143 _("Set Event") . '" />' ,
144 'left', $color[4], 'colspan="2"' )
145 ) ."\n";
146 echo "</form>\n";
147}
148
149
150if ( !isset($month) || $month <= 0){
151 $month = date( 'm' );
152}
153if ( !isset($year) || $year <= 0){
154 $year = date( 'Y' );
155}
156if (!isset($day) || $day <= 0){
157 $day = date( 'd' );
158}
159if (!isset($hour) || $hour <= 0){
160 $hour = '08';
161}
162
163$calself=basename($PHP_SELF);
164
165
166displayPageHeader($color, 'None');
167//load calendar menu
168calendar_header();
169
170echo html_tag( 'tr', '', '', $color[0] ) .
171 html_tag( 'td', '', 'left' ) .
172 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
173 html_tag( 'tr',
174 html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' )
175 );
176//if form has not been filled in
177if(!isset($event_text)){
178 show_event_form();
179} else {
180 readcalendardata();
181 //make sure that event text is fittting 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 $calendardata["$month$day$year"]["$event_hour$event_minute"] =
186 array( 'length' => $event_length,
187 'priority' => $event_priority,
188 'title' => $event_title,
189 'message' => $event_text,
190 'reminder' => '' );
191 //save
192 writecalendardata();
193 echo html_tag( 'table',
194 html_tag( 'tr',
195 html_tag( 'th', _("Event Has been added!") . "<br />\n", '', $color[4], 'colspan="2"' )
196 ) .
197 html_tag( 'tr',
198 html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
199 html_tag( 'td', $month .'/'.$day.'/'.$year, 'left', $color[4] ) . "\n"
200 ) .
201 html_tag( 'tr',
202 html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
203 html_tag( 'td', $event_hour.':'.$event_minute, 'left', $color[4] ) . "\n"
204 ) .
205 html_tag( 'tr',
206 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
207 html_tag( 'td', htmlspecialchars($event_title,ENT_NOQUOTES), 'left', $color[4] ) . "\n"
208 ) .
209 html_tag( 'tr',
210 html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" .
211 html_tag( 'td', htmlspecialchars($event_text,ENT_NOQUOTES), 'left', $color[4] ) . "\n"
212 ) .
213 html_tag( 'tr',
214 html_tag( 'td',
215 "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" . _("Day View") . "</a>\n" ,
216 'left', $color[4], 'colspan="2"' ) . "\n"
217 ) ,
218 '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n";
219}
220
221?>
222</table></td></tr></table>
223</body></html>