| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * event_create.php |
| 5 | * |
| 6 | * Copyright (c) 2002-2005 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 | * @package plugins |
| 15 | * @subpackage calendar |
| 16 | */ |
| 17 | |
| 18 | /** |
| 19 | * @ignore |
| 20 | */ |
| 21 | define('SM_PATH','../../'); |
| 22 | |
| 23 | /* Calender plugin required files. */ |
| 24 | require_once(SM_PATH . 'plugins/calendar/calendar_data.php'); |
| 25 | require_once(SM_PATH . 'plugins/calendar/functions.php'); |
| 26 | |
| 27 | /* SquirrelMail required files. */ |
| 28 | require_once(SM_PATH . 'include/validate.php'); |
| 29 | require_once(SM_PATH . 'functions/strings.php'); |
| 30 | require_once(SM_PATH . 'functions/date.php'); |
| 31 | require_once(SM_PATH . 'config/config.php'); |
| 32 | require_once(SM_PATH . 'functions/page_header.php'); |
| 33 | require_once(SM_PATH . 'include/load_prefs.php'); |
| 34 | require_once(SM_PATH . 'functions/html.php'); |
| 35 | |
| 36 | /* get globals */ |
| 37 | |
| 38 | if (isset($_POST['year'])) { |
| 39 | $year = $_POST['year']; |
| 40 | } |
| 41 | elseif (isset($_GET['year'])) { |
| 42 | $year = $_GET['year']; |
| 43 | } |
| 44 | if (isset($_POST['month'])) { |
| 45 | $month = $_POST['month']; |
| 46 | } |
| 47 | elseif (isset($_GET['month'])) { |
| 48 | $month = $_GET['month']; |
| 49 | } |
| 50 | if (isset($_POST['day'])) { |
| 51 | $day = $_POST['day']; |
| 52 | } |
| 53 | elseif (isset($_GET['day'])) { |
| 54 | $day = $_GET['day']; |
| 55 | } |
| 56 | if (isset($_POST['hour'])) { |
| 57 | $hour = $_POST['hour']; |
| 58 | } |
| 59 | elseif (isset($_GET['hour'])) { |
| 60 | $hour = $_GET['hour']; |
| 61 | } |
| 62 | if (isset($_POST['event_hour'])) { |
| 63 | $event_hour = $_POST['event_hour']; |
| 64 | } |
| 65 | if (isset($_POST['event_minute'])) { |
| 66 | $event_minute = $_POST['event_minute']; |
| 67 | } |
| 68 | if (isset($_POST['event_length'])) { |
| 69 | $event_length = $_POST['event_length']; |
| 70 | } |
| 71 | if (isset($_POST['event_priority'])) { |
| 72 | $event_priority = $_POST['event_priority']; |
| 73 | } |
| 74 | if (isset($_POST['event_title'])) { |
| 75 | $event_title = $_POST['event_title']; |
| 76 | } |
| 77 | if (isset($_POST['event_text'])) { |
| 78 | $event_text = $_POST['event_text']; |
| 79 | } |
| 80 | if (isset($_POST['send'])) { |
| 81 | $send = $_POST['send']; |
| 82 | } |
| 83 | /* got 'em */ |
| 84 | |
| 85 | //main form to gather event info |
| 86 | function show_event_form() { |
| 87 | global $color, $editor_size, $year, $day, $month, $hour; |
| 88 | |
| 89 | echo "\n<form name=\"eventscreate\" action=\"event_create.php\" method=\"post\">\n". |
| 90 | " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n". |
| 91 | " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n". |
| 92 | " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n". |
| 93 | html_tag( 'tr' ) . |
| 94 | html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" . |
| 95 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
| 96 | " <select name=\"event_hour\">\n"; |
| 97 | select_option_hour($hour); |
| 98 | echo " </select>\n" . |
| 99 | " : \n" . |
| 100 | " <select name=\"event_minute\">\n"; |
| 101 | select_option_minute("00"); |
| 102 | echo " </select>\n". |
| 103 | " </td></tr>\n". |
| 104 | html_tag( 'tr' ) . |
| 105 | html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" . |
| 106 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
| 107 | " <select name=\"event_length\">\n"; |
| 108 | select_option_length("0"); |
| 109 | echo " </select>\n". |
| 110 | " </td></tr>\n". |
| 111 | html_tag( 'tr' ) . |
| 112 | html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" . |
| 113 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
| 114 | " <select name=\"event_priority\">\n"; |
| 115 | select_option_priority("0"); |
| 116 | echo " </select>\n". |
| 117 | " </td></tr>\n". |
| 118 | html_tag( 'tr' ) . |
| 119 | html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" . |
| 120 | html_tag( 'td', '', 'left', $color[4] ) . "\n" . |
| 121 | " <input type=\"text\" name=\"event_title\" value=\"\" size=\"30\" maxlength=\"50\" /><br />\n". |
| 122 | " </td></tr>\n". |
| 123 | html_tag( 'tr', |
| 124 | html_tag( 'td', |
| 125 | "<textarea name=\"event_text\" rows=\"5\" cols=\"$editor_size\" wrap=\"hard\"></textarea>" , |
| 126 | 'left', $color[4], 'colspan="2"' ) |
| 127 | ) ."\n" . |
| 128 | html_tag( 'tr', |
| 129 | html_tag( 'td', |
| 130 | '<input type="submit" name="send" value="' . |
| 131 | _("Set Event") . '" />' , |
| 132 | 'left', $color[4], 'colspan="2"' ) |
| 133 | ) ."\n"; |
| 134 | echo "</form>\n"; |
| 135 | } |
| 136 | |
| 137 | |
| 138 | if ( !isset($month) || $month <= 0){ |
| 139 | $month = date( 'm' ); |
| 140 | } |
| 141 | if ( !isset($year) || $year <= 0){ |
| 142 | $year = date( 'Y' ); |
| 143 | } |
| 144 | if (!isset($day) || $day <= 0){ |
| 145 | $day = date( 'd' ); |
| 146 | } |
| 147 | if (!isset($hour) || $hour <= 0){ |
| 148 | $hour = '08'; |
| 149 | } |
| 150 | |
| 151 | $calself=basename($PHP_SELF); |
| 152 | |
| 153 | |
| 154 | displayPageHeader($color, 'None'); |
| 155 | //load calendar menu |
| 156 | calendar_header(); |
| 157 | |
| 158 | echo html_tag( 'tr', '', '', $color[0] ) . |
| 159 | html_tag( 'td', '', 'left' ) . |
| 160 | html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) . |
| 161 | html_tag( 'tr', |
| 162 | html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' ) |
| 163 | ); |
| 164 | //if form has not been filled in |
| 165 | if(!isset($event_text)){ |
| 166 | show_event_form(); |
| 167 | } else { |
| 168 | readcalendardata(); |
| 169 | //make sure that event text is fittting in one line |
| 170 | $event_text=nl2br($event_text); |
| 171 | $event_text=ereg_replace ("\n", "", $event_text); |
| 172 | $event_text=ereg_replace ("\r", "", $event_text); |
| 173 | $calendardata["$month$day$year"]["$event_hour$event_minute"] = |
| 174 | array( 'length' => $event_length, |
| 175 | 'priority' => $event_priority, |
| 176 | 'title' => $event_title, |
| 177 | 'message' => $event_text, |
| 178 | 'reminder' => '' ); |
| 179 | //save |
| 180 | writecalendardata(); |
| 181 | echo html_tag( 'table', |
| 182 | html_tag( 'tr', |
| 183 | html_tag( 'th', _("Event Has been added!") . "<br />\n", '', $color[4], 'colspan="2"' ) |
| 184 | ) . |
| 185 | html_tag( 'tr', |
| 186 | html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" . |
| 187 | html_tag( 'td', $month .'/'.$day.'/'.$year, 'left', $color[4] ) . "\n" |
| 188 | ) . |
| 189 | html_tag( 'tr', |
| 190 | html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" . |
| 191 | html_tag( 'td', $event_hour.':'.$event_minute, 'left', $color[4] ) . "\n" |
| 192 | ) . |
| 193 | html_tag( 'tr', |
| 194 | html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" . |
| 195 | html_tag( 'td', htmlspecialchars($event_title,ENT_NOQUOTES), 'left', $color[4] ) . "\n" |
| 196 | ) . |
| 197 | html_tag( 'tr', |
| 198 | html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" . |
| 199 | html_tag( 'td', htmlspecialchars($event_text,ENT_NOQUOTES), 'left', $color[4] ) . "\n" |
| 200 | ) . |
| 201 | html_tag( 'tr', |
| 202 | html_tag( 'td', |
| 203 | "<a href=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</a>\n" , |
| 204 | 'left', $color[4], 'colspan="2"' ) . "\n" |
| 205 | ) , |
| 206 | '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n"; |
| 207 | } |
| 208 | |
| 209 | ?> |
| 210 | </table></td></tr></table> |
| 211 | </body></html> |