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