d61a01d4 |
1 | <?php |
2 | /* |
3 | * event_create.php |
4 | * |
5 | * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org> |
6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | * |
8 | * functions to create a event for calendar. |
9 | * |
2c85de8f |
10 | * $Id$ |
d61a01d4 |
11 | */ |
12 | |
13 | require_once('calendar_data.php'); |
14 | require_once('functions.php'); |
15 | chdir('..'); |
16 | require_once('../src/validate.php'); |
17 | require_once('../functions/strings.php'); |
18 | require_once('../functions/date.php'); |
19 | require_once('../config/config.php'); |
20 | require_once('../functions/page_header.php'); |
21 | require_once('../src/load_prefs.php'); |
22 | |
23 | //main form to gather event info |
24 | function show_event_form() { |
25 | global $color, $editor_size, $year, $day, $month, $hour; |
26 | |
27 | echo "\n<FORM name=eventscreate action=\"event_create.php\" METHOD=POST >\n". |
28 | " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n". |
29 | " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n". |
30 | " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n". |
ba14ec05 |
31 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Start time:") . "</TD>\n". |
d61a01d4 |
32 | " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n". |
33 | " <SELECT NAME=\"event_hour\">\n"; |
34 | select_option_hour($hour); |
35 | echo " </SELECT>\n" . |
36 | " : \n" . |
37 | " <SELECT NAME=\"event_minute\">\n"; |
38 | select_option_minute("00"); |
39 | echo " </SELECT>\n". |
40 | " </TD></TR>\n". |
41 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Length:") . "</TD>\n". |
42 | " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n". |
43 | " <SELECT NAME=\"event_length\">\n"; |
44 | select_option_length("0"); |
45 | echo " </SELECT>\n". |
46 | " </TD></TR>\n". |
47 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Priority:") . "</TD>\n". |
48 | " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n". |
49 | " <SELECT NAME=\"event_priority\">\n"; |
50 | select_option_priority("0"); |
51 | echo " </SELECT>\n". |
52 | " </TD></TR>\n". |
53 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Title:") . "</TD>\n". |
54 | " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n". |
55 | " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n". |
56 | " </TD></TR>\n". |
57 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT COLSPAN=2>\n". |
58 | " <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD></TEXTAREA>\n". |
59 | " </TD></TR>\n". |
60 | " <TR><TD ALIGN=LEFT BGCOLOR=\"$color[4]\" COLSPAN=2><INPUT TYPE=SUBMIT NAME=send VALUE=\"" . |
61 | _("Set Event") . "\"></TD></TR>\n"; |
62 | echo "</FORM>\n"; |
63 | } |
64 | |
65 | |
88cb1b4d |
66 | if ( !isset($month) || $month <= 0){ |
d61a01d4 |
67 | $month = date( 'm' ); |
68 | } |
88cb1b4d |
69 | if ( !isset($year) || $year <= 0){ |
d61a01d4 |
70 | $year = date( 'Y' ); |
71 | } |
88cb1b4d |
72 | if (!isset($day) || $day <= 0){ |
d61a01d4 |
73 | $day = date( 'd' ); |
74 | } |
88cb1b4d |
75 | if (!isset($hour) || $hour <= 0){ |
d61a01d4 |
76 | $hour = '08'; |
77 | } |
78 | |
79 | $calself=basename($PHP_SELF); |
80 | |
81 | |
82 | displayPageHeader($color, 'None'); |
83 | //load calendar menu |
84 | calendar_header(); |
85 | |
86 | |
87 | echo "<TR BGCOLOR=\"$color[0]\"><TD>" . |
88 | "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">" . |
89 | '<tr><td COLSPAN=2>' . |
90 | date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) . |
91 | '</td></tr>'; |
92 | //if form has not been filled in |
93 | if(!isset($event_text)){ |
94 | show_event_form(); |
95 | } else { |
96 | readcalendardata(); |
97 | //make sure that event text is fittting in one line |
98 | $event_text=nl2br($event_text); |
99 | $event_text=ereg_replace ("\n", "", $event_text); |
100 | $event_text=ereg_replace ("\r", "", $event_text); |
88cb1b4d |
101 | $calendardata["$month$day$year"]["$event_hour$event_minute"] = |
102 | array( 'length' => $event_length, |
103 | 'priority' => $event_priority, |
104 | 'title' => $event_title, |
105 | 'message' => $event_text, |
106 | 'reminder' => '' ); |
d61a01d4 |
107 | //save |
108 | writecalendardata(); |
109 | echo " <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n". |
110 | " <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n". |
111 | _("Event Has been added!") . "<br>\n". |
112 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n". |
113 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$month/$day/$year</TD></TR>\n". |
114 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n". |
115 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_hour:$event_minute</TD></TR>\n". |
116 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n". |
117 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_title</TD></TR>\n". |
118 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n". |
119 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_text</TD></TR>\n". |
120 | " <TR><TD COLSPAN=2 BGCOLOR=\"$color[4]\">\n". |
121 | "<A HREF=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</A>\n". |
122 | " </TD></TR>\n". |
123 | " </TABLE>\n"; |
124 | } |
125 | |
126 | ?> |
127 | </table></td></tr></table> |
128 | </body></html> |