Use sqsession_* instead of session_*
[squirrelmail.git] / plugins / calendar / event_create.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
7c67a5e8 4 * functions to create a event for calendar.
d61a01d4 5 *
c0d96801 6 * @copyright 2002-2012 The SquirrelMail Project Team
4b4abf93 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
ea5f4b8e 9 * @package plugins
10 * @subpackage calendar
11 */
202bcbcc 12/**
13 * Include the SquirrelMail initialization file.
14 */
15require('../../include/init.php');
ea5f4b8e 16
1c7143ad 17/* date_intl() */
18include_once(SM_PATH . 'functions/date.php');
a6d3eff6 19
1c7143ad 20/* Calendar plugin required files. */
21include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
22include_once(SM_PATH . 'plugins/calendar/functions.php');
a6d3eff6 23
1c7143ad 24/* get globals */
25if (! sqGetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
26 unset($year);
95dcee50 27}
1c7143ad 28if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
29 unset($month);
95dcee50 30}
1c7143ad 31if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) {
32 unset($day);
95dcee50 33}
1c7143ad 34if (! sqGetGlobalVar('hour',$hour,SQ_FORM) || ! is_numeric($hour)) {
35 unset($hour);
95dcee50 36}
1c7143ad 37if (! sqGetGlobalVar('event_hour',$event_hour,SQ_POST) || ! is_numeric($event_hour)) {
38 unset($event_hour);
95dcee50 39}
1c7143ad 40if (! sqGetGlobalVar('event_minute',$event_minute,SQ_POST) || ! is_numeric($event_minute)) {
41 unset($event_minute);
95dcee50 42}
1c7143ad 43if (! sqGetGlobalVar('event_length',$event_length,SQ_POST) || ! is_numeric($event_length)) {
44 unset($event_length);
95dcee50 45}
1c7143ad 46if (! sqGetGlobalVar('event_priority',$event_priority,SQ_POST) || ! is_numeric($event_priority)) {
47 unset($event_priority);
95dcee50 48}
1c7143ad 49
50sqGetGlobalVar('event_title',$event_title,SQ_POST);
51sqGetGlobalVar('event_text',$event_text,SQ_POST);
52sqGetGlobalVar('send',$send,SQ_POST);
53
95dcee50 54/* got 'em */
55
d61a01d4 56//main form to gather event info
57function show_event_form() {
58 global $color, $editor_size, $year, $day, $month, $hour;
59
6fd95361 60 echo "\n<form name=\"eventscreate\" action=\"event_create.php\" method=\"post\">\n".
61 " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n".
62 " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n".
63 " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n".
b01b21d0 64 html_tag( 'tr' ) .
65 html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" .
66 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
6fd95361 67 " <select name=\"event_hour\">\n";
d61a01d4 68 select_option_hour($hour);
6fd95361 69 echo " </select>\n" .
d61a01d4 70 " &nbsp;:&nbsp;\n" .
6fd95361 71 " <select name=\"event_minute\">\n";
d61a01d4 72 select_option_minute("00");
6fd95361 73 echo " </select>\n".
b01b21d0 74 " </td></tr>\n".
75 html_tag( 'tr' ) .
76 html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
77 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
6fd95361 78 " <select name=\"event_length\">\n";
d61a01d4 79 select_option_length("0");
6fd95361 80 echo " </select>\n".
b01b21d0 81 " </td></tr>\n".
82 html_tag( 'tr' ) .
83 html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
84 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
6fd95361 85 " <select name=\"event_priority\">\n";
d61a01d4 86 select_option_priority("0");
6fd95361 87 echo " </select>\n".
b01b21d0 88 " </td></tr>\n".
89 html_tag( 'tr' ) .
90 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
91 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
6fd95361 92 " <input type=\"text\" name=\"event_title\" value=\"\" size=\"30\" maxlength=\"50\" /><br />\n".
b01b21d0 93 " </td></tr>\n".
94 html_tag( 'tr',
95 html_tag( 'td',
6f34ed5a 96 "<textarea name=\"event_text\" rows=\"5\" cols=\"$editor_size\"></textarea>" ,
b01b21d0 97 'left', $color[4], 'colspan="2"' )
98 ) ."\n" .
99 html_tag( 'tr',
100 html_tag( 'td',
6fd95361 101 '<input type="submit" name="send" value="' .
102 _("Set Event") . '" />' ,
b01b21d0 103 'left', $color[4], 'colspan="2"' )
104 ) ."\n";
6fd95361 105 echo "</form>\n";
d61a01d4 106}
107
108
88cb1b4d 109if ( !isset($month) || $month <= 0){
d61a01d4 110 $month = date( 'm' );
111}
88cb1b4d 112if ( !isset($year) || $year <= 0){
d61a01d4 113 $year = date( 'Y' );
114}
88cb1b4d 115if (!isset($day) || $day <= 0){
d61a01d4 116 $day = date( 'd' );
117}
88cb1b4d 118if (!isset($hour) || $hour <= 0){
d61a01d4 119 $hour = '08';
120}
121
122$calself=basename($PHP_SELF);
123
124
876fdb60 125displayPageHeader($color);
d61a01d4 126//load calendar menu
127calendar_header();
128
b01b21d0 129echo html_tag( 'tr', '', '', $color[0] ) .
130 html_tag( 'td', '', 'left' ) .
131 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
132 html_tag( 'tr',
f3409980 133 html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' )
b01b21d0 134 );
d61a01d4 135//if form has not been filled in
136if(!isset($event_text)){
137 show_event_form();
138} else {
139 readcalendardata();
88cb1b4d 140 $calendardata["$month$day$year"]["$event_hour$event_minute"] =
1c7143ad 141 array( 'length' => $event_length,
88cb1b4d 142 'priority' => $event_priority,
1c7143ad 143 'title' => $event_title,
144 'message' => $event_text,
88cb1b4d 145 'reminder' => '' );
d61a01d4 146 //save
147 writecalendardata();
b01b21d0 148 echo html_tag( 'table',
149 html_tag( 'tr',
6fd95361 150 html_tag( 'th', _("Event Has been added!") . "<br />\n", '', $color[4], 'colspan="2"' )
b01b21d0 151 ) .
152 html_tag( 'tr',
153 html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
f1d482ae 154 html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$month,$day,$year)), 'left', $color[4] ) . "\n"
b01b21d0 155 ) .
156 html_tag( 'tr',
157 html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
f1d482ae 158 html_tag( 'td', date_intl(_("H:i"),mktime($event_hour,$event_minute,0,$month,$day,$year)), 'left', $color[4] ) . "\n"
b01b21d0 159 ) .
160 html_tag( 'tr',
161 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
e842b215 162 html_tag( 'td', htmlspecialchars($event_title,ENT_NOQUOTES), 'left', $color[4] ) . "\n"
b01b21d0 163 ) .
164 html_tag( 'tr',
165 html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" .
1c7143ad 166 html_tag( 'td', nl2br(htmlspecialchars($event_text,ENT_NOQUOTES)), 'left', $color[4] ) . "\n"
b01b21d0 167 ) .
168 html_tag( 'tr',
169 html_tag( 'td',
1ba8cd6b 170 "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" . _("Day View") . "</a>\n" ,
b01b21d0 171 'left', $color[4], 'colspan="2"' ) . "\n"
172 ) ,
173 '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n";
d61a01d4 174}
175
176?>
177</table></td></tr></table>
876fdb60 178</body></html>