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