| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * day.php |
| 5 | * |
| 6 | * Originally contrubuted by Michal Szczotka <michal@tuxy.org> |
| 7 | * |
| 8 | * Displays the day page (day view). |
| 9 | * |
| 10 | * @copyright © 2002-2005 The SquirrelMail Project Team |
| 11 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 12 | * @version $Id$ |
| 13 | * @package plugins |
| 14 | * @subpackage calendar |
| 15 | */ |
| 16 | |
| 17 | /** @ignore */ |
| 18 | define('SM_PATH','../../'); |
| 19 | |
| 20 | /* Calender plugin required files. */ |
| 21 | require_once(SM_PATH . 'plugins/calendar/calendar_data.php'); |
| 22 | require_once(SM_PATH . 'plugins/calendar/functions.php'); |
| 23 | |
| 24 | /* SquirrelMail required files. */ |
| 25 | require_once(SM_PATH . 'include/validate.php'); |
| 26 | require_once(SM_PATH . 'functions/strings.php'); |
| 27 | require_once(SM_PATH . 'functions/date.php'); |
| 28 | require_once(SM_PATH . 'config/config.php'); |
| 29 | require_once(SM_PATH . 'functions/page_header.php'); |
| 30 | require_once(SM_PATH . 'include/load_prefs.php'); |
| 31 | require_once(SM_PATH . 'functions/html.php'); |
| 32 | |
| 33 | /* get globals */ |
| 34 | |
| 35 | // undo rg = on effects |
| 36 | if (isset($month)) unset($month); |
| 37 | if (isset($year)) unset($year); |
| 38 | if (isset($day)) unset($day); |
| 39 | |
| 40 | if (isset($_GET['year']) && is_numeric($_GET['year'])) { |
| 41 | $year = $_GET['year']; |
| 42 | } |
| 43 | elseif (isset($_POST['year']) && is_numeric($_POST['year'])) { |
| 44 | $year = $_POST['year']; |
| 45 | } |
| 46 | if (isset($_GET['month']) && is_numeric($_GET['month'])) { |
| 47 | $month = $_GET['month']; |
| 48 | } |
| 49 | elseif (isset($_POST['month']) && is_numeric($_POST['month'])) { |
| 50 | $month = $_POST['month']; |
| 51 | } |
| 52 | if (isset($_GET['day']) && is_numeric($_GET['day'])) { |
| 53 | $day = $_GET['day']; |
| 54 | } |
| 55 | elseif (isset($_POST['day']) && is_numeric($_POST['day'])) { |
| 56 | $day = $_POST['day']; |
| 57 | } |
| 58 | |
| 59 | /* got 'em */ |
| 60 | |
| 61 | //displays head of day calendar view |
| 62 | function day_header() { |
| 63 | global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day, |
| 64 | $prev_date, $next_month, $next_day, $next_year, $next_date; |
| 65 | |
| 66 | echo html_tag( 'tr', '', '', $color[0] ) . "\n". |
| 67 | html_tag( 'td', '', 'left' ) . |
| 68 | html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" . |
| 69 | html_tag( 'tr', |
| 70 | html_tag( 'th', |
| 71 | "<a href=\"day.php?year=$prev_year&month=$prev_month&day=$prev_day\">< ". |
| 72 | date_intl('D',$prev_date)."</a>", |
| 73 | 'left' ) . |
| 74 | html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) , |
| 75 | '', '', 'width="75%"' ) . |
| 76 | html_tag( 'th', |
| 77 | "<a href=\"day.php?year=$next_year&month=$next_month&day=$next_day\">". |
| 78 | date_intl('D',$next_date)." ></a>" , |
| 79 | 'right' ) |
| 80 | ); |
| 81 | } |
| 82 | |
| 83 | //events for specific day are inserted into "daily" array |
| 84 | function initialize_events() { |
| 85 | global $daily_events, $calendardata, $month, $day, $year; |
| 86 | |
| 87 | for ($i=7;$i<23;$i++){ |
| 88 | if ($i<10){ |
| 89 | $evntime = '0' . $i . '00'; |
| 90 | } else { |
| 91 | $evntime = $i . '00'; |
| 92 | } |
| 93 | $daily_events[$evntime] = 'empty'; |
| 94 | } |
| 95 | |
| 96 | $cdate = $month . $day . $year; |
| 97 | |
| 98 | if (isset($calendardata[$cdate])){ |
| 99 | while ( $calfoo = each($calendardata[$cdate])){ |
| 100 | $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']]; |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | //main loop for displaying daily events |
| 106 | function display_events() { |
| 107 | global $daily_events, $month, $day, $year, $color; |
| 108 | |
| 109 | ksort($daily_events,SORT_STRING); |
| 110 | $eo=0; |
| 111 | while ($calfoo = each($daily_events)){ |
| 112 | if ($eo==0){ |
| 113 | $eo=4; |
| 114 | } else { |
| 115 | $eo=0; |
| 116 | } |
| 117 | |
| 118 | $ehour = substr($calfoo['key'],0,2); |
| 119 | $eminute = substr($calfoo['key'],2,2); |
| 120 | if (!is_array($calfoo['value'])){ |
| 121 | echo html_tag( 'tr', |
| 122 | html_tag( 'td', $ehour . ':' . $eminute, 'left' ) . |
| 123 | html_tag( 'td', ' ', 'left' ) . |
| 124 | html_tag( 'td', |
| 125 | "<font size=\"-1\"><a href=\"event_create.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."\">". |
| 126 | _("ADD") . "</a></font>" , |
| 127 | 'center' ) , |
| 128 | '', $color[$eo]); |
| 129 | |
| 130 | } else { |
| 131 | $calbar=$calfoo['value']; |
| 132 | if ($calbar['length']!=0){ |
| 133 | $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0)); |
| 134 | } else { |
| 135 | $elength=''; |
| 136 | } |
| 137 | echo html_tag( 'tr', '', '', $color[$eo] ) . |
| 138 | html_tag( 'td', $ehour . ':' . $eminute . $elength, 'left' ) . |
| 139 | html_tag( 'td', '', 'left' ) . '['; |
| 140 | echo ($calbar['priority']==1) ? "<font color=\"$color[1]\">$calbar[title]</font>" : "$calbar[title]"; |
| 141 | echo'] <div style="margin-left:10px">'.nl2br($calbar['message']).'</div>' . |
| 142 | html_tag( 'td', |
| 143 | "<font size=\"-1\"><nobr>\n" . |
| 144 | "<a href=\"event_edit.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."&minute=".substr($calfoo['key'],2,2)."\">". |
| 145 | _("EDIT") . "</a> | \n" . |
| 146 | "<a href=\"event_delete.php?dyear=$year&dmonth=$month&dday=$day&dhour=".substr($calfoo['key'],0,2)."&dminute=".substr($calfoo['key'],2,2)."&year=$year&month=$month&day=$day\">" . |
| 147 | _("DEL") . '</a>' . |
| 148 | "</nobr></font>\n" , |
| 149 | 'center' ); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | |
| 154 | } |
| 155 | |
| 156 | if ($month <= 0){ |
| 157 | $month = date( 'm'); |
| 158 | } |
| 159 | if ($year <= 0){ |
| 160 | $year = date( 'Y'); |
| 161 | } |
| 162 | if ($day <= 0){ |
| 163 | $day = date( 'd'); |
| 164 | } |
| 165 | |
| 166 | $prev_date = mktime(0, 0, 0, $month , $day - 1, $year); |
| 167 | $next_date = mktime(0, 0, 0, $month , $day + 1, $year); |
| 168 | $prev_day = date ('d',$prev_date); |
| 169 | $prev_month = date ('m',$prev_date); |
| 170 | $prev_year = date ('Y',$prev_date); |
| 171 | $next_day = date ('d',$next_date); |
| 172 | $next_month = date ('m',$next_date); |
| 173 | $next_year = date ('Y',$next_date); |
| 174 | |
| 175 | $calself=basename($PHP_SELF); |
| 176 | |
| 177 | $daily_events = array(); |
| 178 | |
| 179 | displayPageHeader($color, 'None'); |
| 180 | calendar_header(); |
| 181 | readcalendardata(); |
| 182 | day_header(); |
| 183 | initialize_events(); |
| 184 | display_events(); |
| 185 | ?> |
| 186 | </table></td></tr></table> |
| 187 | </body></html> |