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 | */ |
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'); |
b01b21d0 |
25 | require_once('../functions/html.php'); |
d61a01d4 |
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". |
b01b21d0 |
35 | html_tag( 'tr' ) . |
36 | html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" . |
37 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
d61a01d4 |
38 | " <SELECT NAME=\"event_hour\">\n"; |
39 | select_option_hour($hour); |
40 | echo " </SELECT>\n" . |
41 | " : \n" . |
42 | " <SELECT NAME=\"event_minute\">\n"; |
43 | select_option_minute("00"); |
44 | echo " </SELECT>\n". |
b01b21d0 |
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" . |
d61a01d4 |
49 | " <SELECT NAME=\"event_length\">\n"; |
50 | select_option_length("0"); |
51 | echo " </SELECT>\n". |
b01b21d0 |
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" . |
d61a01d4 |
56 | " <SELECT NAME=\"event_priority\">\n"; |
57 | select_option_priority("0"); |
58 | echo " </SELECT>\n". |
b01b21d0 |
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" . |
d61a01d4 |
63 | " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n". |
b01b21d0 |
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"; |
d61a01d4 |
76 | echo "</FORM>\n"; |
77 | } |
78 | |
79 | |
88cb1b4d |
80 | if ( !isset($month) || $month <= 0){ |
d61a01d4 |
81 | $month = date( 'm' ); |
82 | } |
88cb1b4d |
83 | if ( !isset($year) || $year <= 0){ |
d61a01d4 |
84 | $year = date( 'Y' ); |
85 | } |
88cb1b4d |
86 | if (!isset($day) || $day <= 0){ |
d61a01d4 |
87 | $day = date( 'd' ); |
88 | } |
88cb1b4d |
89 | if (!isset($hour) || $hour <= 0){ |
d61a01d4 |
90 | $hour = '08'; |
91 | } |
92 | |
93 | $calself=basename($PHP_SELF); |
94 | |
95 | |
96 | displayPageHeader($color, 'None'); |
97 | //load calendar menu |
98 | calendar_header(); |
99 | |
b01b21d0 |
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', |
f3409980 |
104 | html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' ) |
b01b21d0 |
105 | ); |
d61a01d4 |
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); |
88cb1b4d |
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' => '' ); |
d61a01d4 |
121 | //save |
122 | writecalendardata(); |
b01b21d0 |
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"; |
d61a01d4 |
149 | } |
150 | |
151 | ?> |
152 | </table></td></tr></table> |
f3409980 |
153 | </body></html> |