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