Fix the save message button, using new functionality marc introduced yesterday.
[squirrelmail.git] / plugins / calendar / event_create.php
... / ...
CommitLineData
1<?php
2
3/**
4 * event_create.php
5 *
6 * Copyright (c) 2002-2003 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 */
15define('SM_PATH','../../');
16
17/* Calender plugin required files. */
18require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
19require_once(SM_PATH . 'plugins/calendar/functions.php');
20
21/* SquirrelMail required files. */
22require_once(SM_PATH . 'include/validate.php');
23require_once(SM_PATH . 'functions/strings.php');
24require_once(SM_PATH . 'functions/date.php');
25require_once(SM_PATH . 'config/config.php');
26require_once(SM_PATH . 'functions/page_header.php');
27require_once(SM_PATH . 'include/load_prefs.php');
28require_once(SM_PATH . 'functions/html.php');
29
30/* get globals */
31
32if (isset($_POST['year'])) {
33 $year = $_POST['year'];
34}
35elseif (isset($_GET['year'])) {
36 $year = $_GET['year'];
37}
38if (isset($_POST['month'])) {
39 $month = $_POST['month'];
40}
41elseif (isset($_GET['month'])) {
42 $month = $_GET['month'];
43}
44if (isset($_POST['day'])) {
45 $day = $_POST['day'];
46}
47elseif (isset($_GET['day'])) {
48 $day = $_GET['day'];
49}
50if (isset($_POST['hour'])) {
51 $hour = $_POST['hour'];
52}
53elseif (isset($_GET['hour'])) {
54 $hour = $_GET['hour'];
55}
56if (isset($_POST['event_hour'])) {
57 $event_hour = $_POST['event_hour'];
58}
59if (isset($_POST['event_minute'])) {
60 $event_minute = $_POST['event_minute'];
61}
62if (isset($_POST['event_length'])) {
63 $event_length = $_POST['event_length'];
64}
65if (isset($_POST['event_priority'])) {
66 $event_priority = $_POST['event_priority'];
67}
68if (isset($_POST['event_title'])) {
69 $event_title = $_POST['event_title'];
70}
71if (isset($_POST['event_text'])) {
72 $event_text = $_POST['event_text'];
73}
74if (isset($_POST['send'])) {
75 $send = $_POST['send'];
76}
77/* got 'em */
78
79//main form to gather event info
80function 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
132if ( !isset($month) || $month <= 0){
133 $month = date( 'm' );
134}
135if ( !isset($year) || $year <= 0){
136 $year = date( 'Y' );
137}
138if (!isset($day) || $day <= 0){
139 $day = date( 'd' );
140}
141if (!isset($hour) || $hour <= 0){
142 $hour = '08';
143}
144
145$calself=basename($PHP_SELF);
146
147
148displayPageHeader($color, 'None');
149//load calendar menu
150calendar_header();
151
152echo 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
159if(!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>