d61a01d4 |
1 | <?php |
7c67a5e8 |
2 | |
3 | /** |
7c67a5e8 |
4 | * functions to create a event for calendar. |
d61a01d4 |
5 | * |
1c7143ad |
6 | * @copyright © 2002-2006 The SquirrelMail Project Team |
4b4abf93 |
7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
8 | * @version $Id$ |
ea5f4b8e |
9 | * @package plugins |
10 | * @subpackage calendar |
11 | */ |
12 | |
1c7143ad |
13 | /** @ignore */ |
92219031 |
14 | define('SM_PATH','../../'); |
cf1efdce |
15 | |
16 | /* SquirrelMail required files. */ |
1c7143ad |
17 | include_once(SM_PATH . 'include/validate.php'); |
18 | /* date_intl() */ |
19 | include_once(SM_PATH . 'functions/date.php'); |
a6d3eff6 |
20 | |
1c7143ad |
21 | /* Calendar plugin required files. */ |
22 | include_once(SM_PATH . 'plugins/calendar/calendar_data.php'); |
23 | include_once(SM_PATH . 'plugins/calendar/functions.php'); |
a6d3eff6 |
24 | |
1c7143ad |
25 | /* get globals */ |
26 | if (! sqGetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) { |
27 | unset($year); |
95dcee50 |
28 | } |
1c7143ad |
29 | if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) { |
30 | unset($month); |
95dcee50 |
31 | } |
1c7143ad |
32 | if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) { |
33 | unset($day); |
95dcee50 |
34 | } |
1c7143ad |
35 | if (! sqGetGlobalVar('hour',$hour,SQ_FORM) || ! is_numeric($hour)) { |
36 | unset($hour); |
95dcee50 |
37 | } |
1c7143ad |
38 | if (! sqGetGlobalVar('event_hour',$event_hour,SQ_POST) || ! is_numeric($event_hour)) { |
39 | unset($event_hour); |
95dcee50 |
40 | } |
1c7143ad |
41 | if (! sqGetGlobalVar('event_minute',$event_minute,SQ_POST) || ! is_numeric($event_minute)) { |
42 | unset($event_minute); |
95dcee50 |
43 | } |
1c7143ad |
44 | if (! sqGetGlobalVar('event_length',$event_length,SQ_POST) || ! is_numeric($event_length)) { |
45 | unset($event_length); |
95dcee50 |
46 | } |
1c7143ad |
47 | if (! sqGetGlobalVar('event_priority',$event_priority,SQ_POST) || ! is_numeric($event_priority)) { |
48 | unset($event_priority); |
95dcee50 |
49 | } |
1c7143ad |
50 | |
51 | sqGetGlobalVar('event_title',$event_title,SQ_POST); |
52 | sqGetGlobalVar('event_text',$event_text,SQ_POST); |
53 | sqGetGlobalVar('send',$send,SQ_POST); |
54 | |
95dcee50 |
55 | /* got 'em */ |
56 | |
d61a01d4 |
57 | //main form to gather event info |
58 | function show_event_form() { |
59 | global $color, $editor_size, $year, $day, $month, $hour; |
60 | |
6fd95361 |
61 | echo "\n<form name=\"eventscreate\" action=\"event_create.php\" method=\"post\">\n". |
62 | " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n". |
63 | " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n". |
64 | " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n". |
b01b21d0 |
65 | html_tag( 'tr' ) . |
66 | html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" . |
67 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
6fd95361 |
68 | " <select name=\"event_hour\">\n"; |
d61a01d4 |
69 | select_option_hour($hour); |
6fd95361 |
70 | echo " </select>\n" . |
d61a01d4 |
71 | " : \n" . |
6fd95361 |
72 | " <select name=\"event_minute\">\n"; |
d61a01d4 |
73 | select_option_minute("00"); |
6fd95361 |
74 | echo " </select>\n". |
b01b21d0 |
75 | " </td></tr>\n". |
76 | html_tag( 'tr' ) . |
77 | html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" . |
78 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
6fd95361 |
79 | " <select name=\"event_length\">\n"; |
d61a01d4 |
80 | select_option_length("0"); |
6fd95361 |
81 | echo " </select>\n". |
b01b21d0 |
82 | " </td></tr>\n". |
83 | html_tag( 'tr' ) . |
84 | html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" . |
85 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
6fd95361 |
86 | " <select name=\"event_priority\">\n"; |
d61a01d4 |
87 | select_option_priority("0"); |
6fd95361 |
88 | echo " </select>\n". |
b01b21d0 |
89 | " </td></tr>\n". |
90 | html_tag( 'tr' ) . |
91 | html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" . |
92 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
6fd95361 |
93 | " <input type=\"text\" name=\"event_title\" value=\"\" size=\"30\" maxlength=\"50\" /><br />\n". |
b01b21d0 |
94 | " </td></tr>\n". |
95 | html_tag( 'tr', |
96 | html_tag( 'td', |
6fd95361 |
97 | "<textarea name=\"event_text\" rows=\"5\" cols=\"$editor_size\" wrap=\"hard\"></textarea>" , |
b01b21d0 |
98 | 'left', $color[4], 'colspan="2"' ) |
99 | ) ."\n" . |
100 | html_tag( 'tr', |
101 | html_tag( 'td', |
6fd95361 |
102 | '<input type="submit" name="send" value="' . |
103 | _("Set Event") . '" />' , |
b01b21d0 |
104 | 'left', $color[4], 'colspan="2"' ) |
105 | ) ."\n"; |
6fd95361 |
106 | echo "</form>\n"; |
d61a01d4 |
107 | } |
108 | |
109 | |
88cb1b4d |
110 | if ( !isset($month) || $month <= 0){ |
d61a01d4 |
111 | $month = date( 'm' ); |
112 | } |
88cb1b4d |
113 | if ( !isset($year) || $year <= 0){ |
d61a01d4 |
114 | $year = date( 'Y' ); |
115 | } |
88cb1b4d |
116 | if (!isset($day) || $day <= 0){ |
d61a01d4 |
117 | $day = date( 'd' ); |
118 | } |
88cb1b4d |
119 | if (!isset($hour) || $hour <= 0){ |
d61a01d4 |
120 | $hour = '08'; |
121 | } |
122 | |
123 | $calself=basename($PHP_SELF); |
124 | |
125 | |
126 | displayPageHeader($color, 'None'); |
127 | //load calendar menu |
128 | calendar_header(); |
129 | |
b01b21d0 |
130 | echo html_tag( 'tr', '', '', $color[0] ) . |
131 | html_tag( 'td', '', 'left' ) . |
132 | html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) . |
133 | html_tag( 'tr', |
f3409980 |
134 | html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' ) |
b01b21d0 |
135 | ); |
d61a01d4 |
136 | //if form has not been filled in |
137 | if(!isset($event_text)){ |
138 | show_event_form(); |
139 | } else { |
140 | readcalendardata(); |
88cb1b4d |
141 | $calendardata["$month$day$year"]["$event_hour$event_minute"] = |
1c7143ad |
142 | array( 'length' => $event_length, |
88cb1b4d |
143 | 'priority' => $event_priority, |
1c7143ad |
144 | 'title' => $event_title, |
145 | 'message' => $event_text, |
88cb1b4d |
146 | 'reminder' => '' ); |
d61a01d4 |
147 | //save |
148 | writecalendardata(); |
b01b21d0 |
149 | echo html_tag( 'table', |
150 | html_tag( 'tr', |
6fd95361 |
151 | html_tag( 'th', _("Event Has been added!") . "<br />\n", '', $color[4], 'colspan="2"' ) |
b01b21d0 |
152 | ) . |
153 | html_tag( 'tr', |
154 | html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" . |
f1d482ae |
155 | html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$month,$day,$year)), 'left', $color[4] ) . "\n" |
b01b21d0 |
156 | ) . |
157 | html_tag( 'tr', |
158 | html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" . |
f1d482ae |
159 | html_tag( 'td', date_intl(_("H:i"),mktime($event_hour,$event_minute,0,$month,$day,$year)), 'left', $color[4] ) . "\n" |
b01b21d0 |
160 | ) . |
161 | html_tag( 'tr', |
162 | html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" . |
e842b215 |
163 | html_tag( 'td', htmlspecialchars($event_title,ENT_NOQUOTES), 'left', $color[4] ) . "\n" |
b01b21d0 |
164 | ) . |
165 | html_tag( 'tr', |
166 | html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" . |
1c7143ad |
167 | html_tag( 'td', nl2br(htmlspecialchars($event_text,ENT_NOQUOTES)), 'left', $color[4] ) . "\n" |
b01b21d0 |
168 | ) . |
169 | html_tag( 'tr', |
170 | html_tag( 'td', |
1ba8cd6b |
171 | "<a href=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</a>\n" , |
b01b21d0 |
172 | 'left', $color[4], 'colspan="2"' ) . "\n" |
173 | ) , |
174 | '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n"; |
d61a01d4 |
175 | } |
176 | |
177 | ?> |
178 | </table></td></tr></table> |
91e0dccc |
179 | </body></html> |