prevent output in plugins/*/setup.php files.
[squirrelmail.git] / plugins / calendar / event_create.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
4 * event_create.php
5 *
7c67a5e8 6 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
d61a01d4 7 *
7c67a5e8 8 * functions to create a event for calendar.
d61a01d4 9 *
4b4abf93 10 * @copyright &copy; 2002-2005 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @version $Id$
ea5f4b8e 13 * @package plugins
14 * @subpackage calendar
15 */
16
17/**
18 * @ignore
d61a01d4 19 */
92219031 20define('SM_PATH','../../');
cf1efdce 21
8d6a115b 22/* Calender plugin required files. */
23require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
24require_once(SM_PATH . 'plugins/calendar/functions.php');
25
cf1efdce 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');
aa7fb30c 32require_once(SM_PATH . 'include/load_prefs.php');
cf1efdce 33require_once(SM_PATH . 'functions/html.php');
d61a01d4 34
95dcee50 35/* get globals */
36
a6d3eff6 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'])) {
95dcee50 50 $year = $_GET['year'];
51}
a6d3eff6 52elseif (isset($_POST['year']) && is_numeric($_POST['year'])) {
53 $year = $_POST['year'];
95dcee50 54}
a6d3eff6 55if (isset($_GET['month']) && is_numeric($_GET['month'])) {
95dcee50 56 $month = $_GET['month'];
57}
a6d3eff6 58elseif (isset($_POST['month']) && is_numeric($_POST['month'])) {
59 $month = $_POST['month'];
95dcee50 60}
a6d3eff6 61if (isset($_GET['day']) && is_numeric($_GET['day'])) {
95dcee50 62 $day = $_GET['day'];
63}
a6d3eff6 64elseif (isset($_POST['day']) && is_numeric($_POST['day'])) {
65 $day = $_POST['day'];
66}
67
68if (isset($_POST['hour']) && is_numeric($_POST['hour'])) {
95dcee50 69 $hour = $_POST['hour'];
70}
a6d3eff6 71elseif (isset($_GET['hour']) && is_numeric($_GET['hour'])) {
95dcee50 72 $hour = $_GET['hour'];
73}
a6d3eff6 74if (isset($_POST['event_hour']) && is_numeric($_POST['event_hour'])) {
95dcee50 75 $event_hour = $_POST['event_hour'];
76}
a6d3eff6 77if (isset($_POST['event_minute']) && is_numeric($_POST['event_minute'])) {
95dcee50 78 $event_minute = $_POST['event_minute'];
79}
a6d3eff6 80if (isset($_POST['event_length']) && is_numeric($_POST['event_length'])) {
95dcee50 81 $event_length = $_POST['event_length'];
82}
a6d3eff6 83if (isset($_POST['event_priority']) && is_numeric($_POST['event_priority'])) {
95dcee50 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
d61a01d4 97//main form to gather event info
98function show_event_form() {
99 global $color, $editor_size, $year, $day, $month, $hour;
100
6fd95361 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".
b01b21d0 105 html_tag( 'tr' ) .
106 html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" .
107 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
6fd95361 108 " <select name=\"event_hour\">\n";
d61a01d4 109 select_option_hour($hour);
6fd95361 110 echo " </select>\n" .
d61a01d4 111 " &nbsp;:&nbsp;\n" .
6fd95361 112 " <select name=\"event_minute\">\n";
d61a01d4 113 select_option_minute("00");
6fd95361 114 echo " </select>\n".
b01b21d0 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" .
6fd95361 119 " <select name=\"event_length\">\n";
d61a01d4 120 select_option_length("0");
6fd95361 121 echo " </select>\n".
b01b21d0 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" .
6fd95361 126 " <select name=\"event_priority\">\n";
d61a01d4 127 select_option_priority("0");
6fd95361 128 echo " </select>\n".
b01b21d0 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" .
6fd95361 133 " <input type=\"text\" name=\"event_title\" value=\"\" size=\"30\" maxlength=\"50\" /><br />\n".
b01b21d0 134 " </td></tr>\n".
135 html_tag( 'tr',
136 html_tag( 'td',
6fd95361 137 "<textarea name=\"event_text\" rows=\"5\" cols=\"$editor_size\" wrap=\"hard\"></textarea>" ,
b01b21d0 138 'left', $color[4], 'colspan="2"' )
139 ) ."\n" .
140 html_tag( 'tr',
141 html_tag( 'td',
6fd95361 142 '<input type="submit" name="send" value="' .
143 _("Set Event") . '" />' ,
b01b21d0 144 'left', $color[4], 'colspan="2"' )
145 ) ."\n";
6fd95361 146 echo "</form>\n";
d61a01d4 147}
148
149
88cb1b4d 150if ( !isset($month) || $month <= 0){
d61a01d4 151 $month = date( 'm' );
152}
88cb1b4d 153if ( !isset($year) || $year <= 0){
d61a01d4 154 $year = date( 'Y' );
155}
88cb1b4d 156if (!isset($day) || $day <= 0){
d61a01d4 157 $day = date( 'd' );
158}
88cb1b4d 159if (!isset($hour) || $hour <= 0){
d61a01d4 160 $hour = '08';
161}
162
163$calself=basename($PHP_SELF);
164
165
166displayPageHeader($color, 'None');
167//load calendar menu
168calendar_header();
169
b01b21d0 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',
f3409980 174 html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' )
b01b21d0 175 );
d61a01d4 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);
88cb1b4d 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' => '' );
d61a01d4 191 //save
192 writecalendardata();
b01b21d0 193 echo html_tag( 'table',
194 html_tag( 'tr',
6fd95361 195 html_tag( 'th', _("Event Has been added!") . "<br />\n", '', $color[4], 'colspan="2"' )
b01b21d0 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" .
e842b215 207 html_tag( 'td', htmlspecialchars($event_title,ENT_NOQUOTES), 'left', $color[4] ) . "\n"
b01b21d0 208 ) .
209 html_tag( 'tr',
210 html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" .
e842b215 211 html_tag( 'td', htmlspecialchars($event_text,ENT_NOQUOTES), 'left', $color[4] ) . "\n"
b01b21d0 212 ) .
213 html_tag( 'tr',
214 html_tag( 'td',
1ba8cd6b 215 "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" . _("Day View") . "</a>\n" ,
b01b21d0 216 'left', $color[4], 'colspan="2"' ) . "\n"
217 ) ,
218 '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n";
d61a01d4 219}
220
221?>
222</table></td></tr></table>
91e0dccc 223</body></html>