SMPATH fix
[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
16 require_once('calendar_data.php');
17 require_once('functions.php');
18 chdir('..');
19 require_once('../src/validate.php');
20 require_once('../functions/strings.php');
21 require_once('../functions/date.php');
22 require_once('../config/config.php');
23 require_once('../functions/page_header.php');
24 require_once('../src/load_prefs.php');
25 require_once('../functions/html.php');
26
27 //main form to gather event info
28 function show_event_form() {
29 global $color, $editor_size, $year, $day, $month, $hour;
30
31 echo "\n<FORM name=eventscreate action=\"event_create.php\" METHOD=POST >\n".
32 " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
33 " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
34 " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
35 html_tag( 'tr' ) .
36 html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" .
37 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
38 " <SELECT NAME=\"event_hour\">\n";
39 select_option_hour($hour);
40 echo " </SELECT>\n" .
41 " &nbsp;:&nbsp;\n" .
42 " <SELECT NAME=\"event_minute\">\n";
43 select_option_minute("00");
44 echo " </SELECT>\n".
45 " </td></tr>\n".
46 html_tag( 'tr' ) .
47 html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
48 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
49 " <SELECT NAME=\"event_length\">\n";
50 select_option_length("0");
51 echo " </SELECT>\n".
52 " </td></tr>\n".
53 html_tag( 'tr' ) .
54 html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
55 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
56 " <SELECT NAME=\"event_priority\">\n";
57 select_option_priority("0");
58 echo " </SELECT>\n".
59 " </td></tr>\n".
60 html_tag( 'tr' ) .
61 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
62 html_tag( 'td', '', 'left', $color[4] ) . "\n" .
63 " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n".
64 " </td></tr>\n".
65 html_tag( 'tr',
66 html_tag( 'td',
67 "<TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD></TEXTAREA>" ,
68 'left', $color[4], 'colspan="2"' )
69 ) ."\n" .
70 html_tag( 'tr',
71 html_tag( 'td',
72 "<INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
73 _("Set Event") . "\">" ,
74 'left', $color[4], 'colspan="2"' )
75 ) ."\n";
76 echo "</FORM>\n";
77 }
78
79
80 if ( !isset($month) || $month <= 0){
81 $month = date( 'm' );
82 }
83 if ( !isset($year) || $year <= 0){
84 $year = date( 'Y' );
85 }
86 if (!isset($day) || $day <= 0){
87 $day = date( 'd' );
88 }
89 if (!isset($hour) || $hour <= 0){
90 $hour = '08';
91 }
92
93 $calself=basename($PHP_SELF);
94
95
96 displayPageHeader($color, 'None');
97 //load calendar menu
98 calendar_header();
99
100 echo html_tag( 'tr', '', '', $color[0] ) .
101 html_tag( 'td', '', 'left' ) .
102 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
103 html_tag( 'tr',
104 html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' )
105 );
106 //if form has not been filled in
107 if(!isset($event_text)){
108 show_event_form();
109 } else {
110 readcalendardata();
111 //make sure that event text is fittting in one line
112 $event_text=nl2br($event_text);
113 $event_text=ereg_replace ("\n", "", $event_text);
114 $event_text=ereg_replace ("\r", "", $event_text);
115 $calendardata["$month$day$year"]["$event_hour$event_minute"] =
116 array( 'length' => $event_length,
117 'priority' => $event_priority,
118 'title' => $event_title,
119 'message' => $event_text,
120 'reminder' => '' );
121 //save
122 writecalendardata();
123 echo html_tag( 'table',
124 html_tag( 'tr',
125 html_tag( 'th', _("Event Has been added!") . "<br>\n", '', $color[4], 'colspan="2"' )
126 ) .
127 html_tag( 'tr',
128 html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
129 html_tag( 'td', $month .'/'.$day.'/'.$year, 'left', $color[4] ) . "\n"
130 ) .
131 html_tag( 'tr',
132 html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
133 html_tag( 'td', $event_hour.':'.$event_minute, 'left', $color[4] ) . "\n"
134 ) .
135 html_tag( 'tr',
136 html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
137 html_tag( 'td', $event_title, 'left', $color[4] ) . "\n"
138 ) .
139 html_tag( 'tr',
140 html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" .
141 html_tag( 'td', $event_text, 'left', $color[4] ) . "\n"
142 ) .
143 html_tag( 'tr',
144 html_tag( 'td',
145 "<a href=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</a>\n" ,
146 'left', $color[4], 'colspan="2"' ) . "\n"
147 ) ,
148 '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n";
149 }
150
151 ?>
152 </table></td></tr></table>
153 </body></html>