5ce78fb7db2ca5de1eb3bfb2f99dfd77b3991e89
[squirrelmail.git] / plugins / calendar / event_create.php
1 <?php
2
3 /**
4 * event_create.php
5 *
6 * Copyright (c) 2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
10 *
11 * functions to create a event for calendar.
12 *
13 * $Id$
14 */
15 define('SM_PATH','../../');
16
17 /* Calender plugin required files. */
18 require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
19 require_once(SM_PATH . 'plugins/calendar/functions.php');
20
21 /* SquirrelMail required files. */
22 require_once(SM_PATH . 'include/validate.php');
23 require_once(SM_PATH . 'functions/strings.php');
24 require_once(SM_PATH . 'functions/date.php');
25 require_once(SM_PATH . 'config/config.php');
26 require_once(SM_PATH . 'functions/page_header.php');
27 require_once(SM_PATH . 'include/load_prefs.php');
28 require_once(SM_PATH . 'functions/html.php');
29
30 /* get globals */
31
32 if (isset($_POST['year'])) {
33 $year = $_POST['year'];
34 }
35 elseif (isset($_GET['year'])) {
36 $year = $_GET['year'];
37 }
38 if (isset($_POST['month'])) {
39 $month = $_POST['month'];
40 }
41 elseif (isset($_GET['month'])) {
42 $month = $_GET['month'];
43 }
44 if (isset($_POST['day'])) {
45 $day = $_POST['day'];
46 }
47 elseif (isset($_GET['day'])) {
48 $day = $_GET['day'];
49 }
50 if (isset($_POST['hour'])) {
51 $hour = $_POST['hour'];
52 }
53 elseif (isset($_GET['hour'])) {
54 $hour = $_GET['hour'];
55 }
56 if (isset($_POST['event_hour'])) {
57 $event_hour = $_POST['event_hour'];
58 }
59 if (isset($_POST['event_minute'])) {
60 $event_minute = $_POST['event_minute'];
61 }
62 if (isset($_POST['event_length'])) {
63 $event_length = $_POST['event_length'];
64 }
65 if (isset($_POST['event_priority'])) {
66 $event_priority = $_POST['event_priority'];
67 }
68 if (isset($_POST['event_title'])) {
69 $event_title = $_POST['event_title'];
70 }
71 if (isset($_POST['event_text'])) {
72 $event_text = $_POST['event_text'];
73 }
74 if (isset($_POST['send'])) {
75 $send = $_POST['send'];
76 }
77 /* got 'em */
78
79 //main form to gather event info
80 function show_event_form() {
81 global $color, $editor_size, $year, $day, $month, $hour;
82
83 echo "\n<FORM name=eventscreate action=\"event_create.php\" METHOD=POST >\n".
84 " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
85 " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
86 " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
87 html_tag( 'tr' ) .
88 html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" .
89 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
90 " <SELECT NAME=\"event_hour\">\n";
91 select_option_hour($hour);
92 echo " </SELECT>\n" .
93 " &nbsp;:&nbsp;\n" .
94 " <SELECT NAME=\"event_minute\">\n";
95 select_option_minute("00");
96 echo " </SELECT>\n".
97 " </td></tr>\n".
98 html_tag( 'tr' ) .
99 html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
100 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
101 " <SELECT NAME=\"event_length\">\n";
102 select_option_length("0");
103 echo " </SELECT>\n".
104 " </td></tr>\n".
105 html_tag( 'tr' ) .
106 html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
107 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
108 " <SELECT NAME=\"event_priority\">\n";
109 select_option_priority("0");
110 echo " </SELECT>\n".
111 " </td></tr>\n".
112 html_tag( 'tr' ) .
113 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
114 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
115 " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n".
116 " </td></tr>\n".
117 html_tag( 'tr',
118 html_tag( 'td',
119 "<TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD></TEXTAREA>" ,
120 'left', $color[4], 'colspan="2"' )
121 ) ."\n" .
122 html_tag( 'tr',
123 html_tag( 'td',
124 "<INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
125 _("Set Event") . "\">" ,
126 'left', $color[4], 'colspan="2"' )
127 ) ."\n";
128 echo "</FORM>\n";
129 }
130
131
132 if ( !isset($month) || $month <= 0){
133 $month = date( 'm' );
134 }
135 if ( !isset($year) || $year <= 0){
136 $year = date( 'Y' );
137 }
138 if (!isset($day) || $day <= 0){
139 $day = date( 'd' );
140 }
141 if (!isset($hour) || $hour <= 0){
142 $hour = '08';
143 }
144
145 $calself=basename($PHP_SELF);
146
147
148 displayPageHeader($color, 'None');
149 //load calendar menu
150 calendar_header();
151
152 echo html_tag( 'tr', '', '', $color[0] ) .
153 html_tag( 'td', '', 'left' ) .
154 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
155 html_tag( 'tr',
156 html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' )
157 );
158 //if form has not been filled in
159 if(!isset($event_text)){
160 show_event_form();
161 } else {
162 readcalendardata();
163 //make sure that event text is fittting in one line
164 $event_text=nl2br($event_text);
165 $event_text=ereg_replace ("\n", "", $event_text);
166 $event_text=ereg_replace ("\r", "", $event_text);
167 $calendardata["$month$day$year"]["$event_hour$event_minute"] =
168 array( 'length' => $event_length,
169 'priority' => $event_priority,
170 'title' => $event_title,
171 'message' => $event_text,
172 'reminder' => '' );
173 //save
174 writecalendardata();
175 echo html_tag( 'table',
176 html_tag( 'tr',
177 html_tag( 'th', _("Event Has been added!") . "<br>\n", '', $color[4], 'colspan="2"' )
178 ) .
179 html_tag( 'tr',
180 html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
181 html_tag( 'td', $month .'/'.$day.'/'.$year, 'left', $color[4] ) . "\n"
182 ) .
183 html_tag( 'tr',
184 html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
185 html_tag( 'td', $event_hour.':'.$event_minute, 'left', $color[4] ) . "\n"
186 ) .
187 html_tag( 'tr',
188 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
189 html_tag( 'td', $event_title, 'left', $color[4] ) . "\n"
190 ) .
191 html_tag( 'tr',
192 html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" .
193 html_tag( 'td', $event_text, 'left', $color[4] ) . "\n"
194 ) .
195 html_tag( 'tr',
196 html_tag( 'td',
197 "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" . _("Day View") . "</a>\n" ,
198 'left', $color[4], 'colspan="2"' ) . "\n"
199 ) ,
200 '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n";
201 }
202
203 ?>
204 </table></td></tr></table>
205 </body></html>