| 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 | * |
| 10 | * $Id$ |
| 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". |
| 31 | " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Start time:") . "</TD>\n". |
| 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 | |
| 66 | if ($month <= 0){ |
| 67 | $month = date( 'm' ); |
| 68 | } |
| 69 | if ($year <= 0){ |
| 70 | $year = date( 'Y' ); |
| 71 | } |
| 72 | if ($day <= 0){ |
| 73 | $day = date( 'd' ); |
| 74 | } |
| 75 | if ($hour <= 0){ |
| 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); |
| 101 | $calendardata["$month$day$year"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text"); |
| 102 | //save |
| 103 | writecalendardata(); |
| 104 | echo " <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n". |
| 105 | " <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n". |
| 106 | _("Event Has been added!") . "<br>\n". |
| 107 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n". |
| 108 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$month/$day/$year</TD></TR>\n". |
| 109 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n". |
| 110 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_hour:$event_minute</TD></TR>\n". |
| 111 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n". |
| 112 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_title</TD></TR>\n". |
| 113 | " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n". |
| 114 | " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_text</TD></TR>\n". |
| 115 | " <TR><TD COLSPAN=2 BGCOLOR=\"$color[4]\">\n". |
| 116 | "<A HREF=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</A>\n". |
| 117 | " </TD></TR>\n". |
| 118 | " </TABLE>\n"; |
| 119 | } |
| 120 | |
| 121 | ?> |
| 122 | </table></td></tr></table> |
| 123 | </body></html> |