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