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