6 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
8 * functions to create a event for calendar.
10 * @copyright © 2002-2005 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 * @subpackage calendar
20 define('SM_PATH','../../');
22 /* Calender plugin required files. */
23 require_once(SM_PATH
. 'plugins/calendar/calendar_data.php');
24 require_once(SM_PATH
. 'plugins/calendar/functions.php');
26 /* SquirrelMail required files. */
27 require_once(SM_PATH
. 'include/validate.php');
28 require_once(SM_PATH
. 'functions/strings.php');
29 require_once(SM_PATH
. 'functions/date.php');
30 require_once(SM_PATH
. 'config/config.php');
31 require_once(SM_PATH
. 'functions/page_header.php');
32 require_once(SM_PATH
. 'include/load_prefs.php');
33 require_once(SM_PATH
. 'functions/html.php');
37 // undo rg = on effects
38 if (isset($month)) unset($month);
39 if (isset($year)) unset($year);
40 if (isset($day)) unset($day);
41 if (isset($hour)) unset($hour);
42 if (isset($minute)) unset($minute);
43 if (isset($event_hour)) unset($event_hour);
44 if (isset($event_minute)) unset($event_minute);
45 if (isset($event_length)) unset($event_length);
46 if (isset($event_priority)) unset($event_priority);
49 if (isset($_GET['year']) && is_numeric($_GET['year'])) {
50 $year = $_GET['year'];
52 elseif (isset($_POST['year']) && is_numeric($_POST['year'])) {
53 $year = $_POST['year'];
55 if (isset($_GET['month']) && is_numeric($_GET['month'])) {
56 $month = $_GET['month'];
58 elseif (isset($_POST['month']) && is_numeric($_POST['month'])) {
59 $month = $_POST['month'];
61 if (isset($_GET['day']) && is_numeric($_GET['day'])) {
64 elseif (isset($_POST['day']) && is_numeric($_POST['day'])) {
68 if (isset($_POST['hour']) && is_numeric($_POST['hour'])) {
69 $hour = $_POST['hour'];
71 elseif (isset($_GET['hour']) && is_numeric($_GET['hour'])) {
72 $hour = $_GET['hour'];
74 if (isset($_POST['event_hour']) && is_numeric($_POST['event_hour'])) {
75 $event_hour = $_POST['event_hour'];
77 if (isset($_POST['event_minute']) && is_numeric($_POST['event_minute'])) {
78 $event_minute = $_POST['event_minute'];
80 if (isset($_POST['event_length']) && is_numeric($_POST['event_length'])) {
81 $event_length = $_POST['event_length'];
83 if (isset($_POST['event_priority']) && is_numeric($_POST['event_priority'])) {
84 $event_priority = $_POST['event_priority'];
86 if (isset($_POST['event_title'])) {
87 $event_title = $_POST['event_title'];
89 if (isset($_POST['event_text'])) {
90 $event_text = $_POST['event_text'];
92 if (isset($_POST['send'])) {
93 $send = $_POST['send'];
97 //main form to gather event info
98 function show_event_form() {
99 global $color, $editor_size, $year, $day, $month, $hour;
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".
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" .
112 " <select name=\"event_minute\">\n";
113 select_option_minute("00");
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");
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");
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".
137 "<textarea name=\"event_text\" rows=\"5\" cols=\"$editor_size\" wrap=\"hard\"></textarea>" ,
138 'left', $color[4], 'colspan="2"' )
142 '<input type="submit" name="send" value="' .
143 _("Set Event") . '" />' ,
144 'left', $color[4], 'colspan="2"' )
150 if ( !isset($month) ||
$month <= 0){
151 $month = date( 'm' );
153 if ( !isset($year) ||
$year <= 0){
156 if (!isset($day) ||
$day <= 0){
159 if (!isset($hour) ||
$hour <= 0){
163 $calself=basename($PHP_SELF);
166 displayPageHeader($color, 'None');
170 echo html_tag( 'tr', '', '', $color[0] ) .
171 html_tag( 'td', '', 'left' ) .
172 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
174 html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' )
176 //if form has not been filled in
177 if(!isset($event_text)){
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,
193 echo html_tag( 'table',
195 html_tag( 'th', _("Event Has been added!") . "<br />\n", '', $color[4], 'colspan="2"' )
198 html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
199 html_tag( 'td', $month .'/'.$day.'/'.$year, 'left', $color[4] ) . "\n"
202 html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
203 html_tag( 'td', $event_hour.':'.$event_minute, 'left', $color[4] ) . "\n"
206 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
207 html_tag( 'td', htmlspecialchars($event_title,ENT_NOQUOTES
), 'left', $color[4] ) . "\n"
210 html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" .
211 html_tag( 'td', htmlspecialchars($event_text,ENT_NOQUOTES
), 'left', $color[4] ) . "\n"
215 "<a href=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</a>\n" ,
216 'left', $color[4], 'colspan="2"' ) . "\n"
218 '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n";
222 </table
></td
></tr
></table
>