| 1 | <?php |
| 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. |
| 8 | * |
| 9 | * Originally contrubuted by Michal Szczotka <michal@tuxy.org> |
| 10 | * |
| 11 | * functions to create a event for calendar. |
| 12 | * |
| 13 | * $Id$ |
| 14 | */ |
| 15 | define('SM_PATH','../../'); |
| 16 | |
| 17 | /* Calender plugin required files. */ |
| 18 | require_once(SM_PATH . 'plugins/calendar/calendar_data.php'); |
| 19 | require_once(SM_PATH . 'plugins/calendar/functions.php'); |
| 20 | |
| 21 | /* SquirrelMail required files. */ |
| 22 | require_once(SM_PATH . 'include/validate.php'); |
| 23 | require_once(SM_PATH . 'functions/strings.php'); |
| 24 | require_once(SM_PATH . 'functions/date.php'); |
| 25 | require_once(SM_PATH . 'config/config.php'); |
| 26 | require_once(SM_PATH . 'functions/page_header.php'); |
| 27 | require_once(SM_PATH . 'include/load_prefs.php'); |
| 28 | require_once(SM_PATH . 'functions/html.php'); |
| 29 | |
| 30 | //main form to gather event info |
| 31 | function show_event_form() { |
| 32 | global $color, $editor_size, $year, $day, $month, $hour; |
| 33 | |
| 34 | echo "\n<FORM name=eventscreate action=\"event_create.php\" METHOD=POST >\n". |
| 35 | " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n". |
| 36 | " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n". |
| 37 | " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n". |
| 38 | html_tag( 'tr' ) . |
| 39 | html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" . |
| 40 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
| 41 | " <SELECT NAME=\"event_hour\">\n"; |
| 42 | select_option_hour($hour); |
| 43 | echo " </SELECT>\n" . |
| 44 | " : \n" . |
| 45 | " <SELECT NAME=\"event_minute\">\n"; |
| 46 | select_option_minute("00"); |
| 47 | echo " </SELECT>\n". |
| 48 | " </td></tr>\n". |
| 49 | html_tag( 'tr' ) . |
| 50 | html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" . |
| 51 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
| 52 | " <SELECT NAME=\"event_length\">\n"; |
| 53 | select_option_length("0"); |
| 54 | echo " </SELECT>\n". |
| 55 | " </td></tr>\n". |
| 56 | html_tag( 'tr' ) . |
| 57 | html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" . |
| 58 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
| 59 | " <SELECT NAME=\"event_priority\">\n"; |
| 60 | select_option_priority("0"); |
| 61 | echo " </SELECT>\n". |
| 62 | " </td></tr>\n". |
| 63 | html_tag( 'tr' ) . |
| 64 | html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" . |
| 65 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
| 66 | " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n". |
| 67 | " </td></tr>\n". |
| 68 | html_tag( 'tr', |
| 69 | html_tag( 'td', |
| 70 | "<TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD></TEXTAREA>" , |
| 71 | 'left', $color[4], 'colspan="2"' ) |
| 72 | ) ."\n" . |
| 73 | html_tag( 'tr', |
| 74 | html_tag( 'td', |
| 75 | "<INPUT TYPE=SUBMIT NAME=send VALUE=\"" . |
| 76 | _("Set Event") . "\">" , |
| 77 | 'left', $color[4], 'colspan="2"' ) |
| 78 | ) ."\n"; |
| 79 | echo "</FORM>\n"; |
| 80 | } |
| 81 | |
| 82 | |
| 83 | if ( !isset($month) || $month <= 0){ |
| 84 | $month = date( 'm' ); |
| 85 | } |
| 86 | if ( !isset($year) || $year <= 0){ |
| 87 | $year = date( 'Y' ); |
| 88 | } |
| 89 | if (!isset($day) || $day <= 0){ |
| 90 | $day = date( 'd' ); |
| 91 | } |
| 92 | if (!isset($hour) || $hour <= 0){ |
| 93 | $hour = '08'; |
| 94 | } |
| 95 | |
| 96 | $calself=basename($PHP_SELF); |
| 97 | |
| 98 | |
| 99 | displayPageHeader($color, 'None'); |
| 100 | //load calendar menu |
| 101 | calendar_header(); |
| 102 | |
| 103 | echo html_tag( 'tr', '', '', $color[0] ) . |
| 104 | html_tag( 'td', '', 'left' ) . |
| 105 | html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) . |
| 106 | html_tag( 'tr', |
| 107 | html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' ) |
| 108 | ); |
| 109 | //if form has not been filled in |
| 110 | if(!isset($event_text)){ |
| 111 | show_event_form(); |
| 112 | } else { |
| 113 | readcalendardata(); |
| 114 | //make sure that event text is fittting in one line |
| 115 | $event_text=nl2br($event_text); |
| 116 | $event_text=ereg_replace ("\n", "", $event_text); |
| 117 | $event_text=ereg_replace ("\r", "", $event_text); |
| 118 | $calendardata["$month$day$year"]["$event_hour$event_minute"] = |
| 119 | array( 'length' => $event_length, |
| 120 | 'priority' => $event_priority, |
| 121 | 'title' => $event_title, |
| 122 | 'message' => $event_text, |
| 123 | 'reminder' => '' ); |
| 124 | //save |
| 125 | writecalendardata(); |
| 126 | echo html_tag( 'table', |
| 127 | html_tag( 'tr', |
| 128 | html_tag( 'th', _("Event Has been added!") . "<br>\n", '', $color[4], 'colspan="2"' ) |
| 129 | ) . |
| 130 | html_tag( 'tr', |
| 131 | html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" . |
| 132 | html_tag( 'td', $month .'/'.$day.'/'.$year, 'left', $color[4] ) . "\n" |
| 133 | ) . |
| 134 | html_tag( 'tr', |
| 135 | html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" . |
| 136 | html_tag( 'td', $event_hour.':'.$event_minute, 'left', $color[4] ) . "\n" |
| 137 | ) . |
| 138 | html_tag( 'tr', |
| 139 | html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" . |
| 140 | html_tag( 'td', $event_title, 'left', $color[4] ) . "\n" |
| 141 | ) . |
| 142 | html_tag( 'tr', |
| 143 | html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" . |
| 144 | html_tag( 'td', $event_text, 'left', $color[4] ) . "\n" |
| 145 | ) . |
| 146 | html_tag( 'tr', |
| 147 | html_tag( 'td', |
| 148 | "<a href=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</a>\n" , |
| 149 | 'left', $color[4], 'colspan="2"' ) . "\n" |
| 150 | ) , |
| 151 | '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n"; |
| 152 | } |
| 153 | |
| 154 | ?> |
| 155 | </table></td></tr></table> |
| 156 | </body></html> |