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