Time to stop coding for tonight. Making this kind of terrible bugs is bad.
[squirrelmail.git] / plugins / calendar / day.php
1 <?php
2
3 /**
4 * day.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 * Displays the day page (day view).
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 //displays head of day calendar view
31 function day_header() {
32 global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
33 $prev_date, $next_month, $next_day, $next_year, $next_date;
34
35 echo html_tag( 'tr', '', '', $color[0] ) . "\n".
36 html_tag( 'td', '', 'left' ) .
37 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" .
38 html_tag( 'tr',
39 html_tag( 'th',
40 "<a href=\"day.php?year=$prev_year&month=$prev_month&day=$prev_day\">&lt;&nbsp;".
41 date_intl('D',$prev_date)."</a>",
42 'left' ) .
43 html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
44 '', '', 'width="75%"' ) .
45 html_tag( 'th',
46 "<a href=\"day.php?year=$next_year&month=$next_month&day=$next_day\">".
47 date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
48 'right' )
49 );
50 }
51
52 //events for specific day are inserted into "daily" array
53 function initialize_events() {
54 global $daily_events, $calendardata, $month, $day, $year;
55
56 for ($i=7;$i<23;$i++){
57 if ($i<10){
58 $evntime = '0' . $i . '00';
59 } else {
60 $evntime = $i . '00';
61 }
62 $daily_events[$evntime] = 'empty';
63 }
64
65 $cdate = $month . $day . $year;
66
67 if (isset($calendardata[$cdate])){
68 while ( $calfoo = each($calendardata[$cdate])){
69 $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
70 }
71 }
72 }
73
74 //main loop for displaying daily events
75 function display_events() {
76 global $daily_events, $month, $day, $year, $color;
77
78 ksort($daily_events,SORT_STRING);
79 $eo=0;
80 while ($calfoo = each($daily_events)){
81 if ($eo==0){
82 $eo=4;
83 } else {
84 $eo=0;
85 }
86
87 $ehour = substr($calfoo['key'],0,2);
88 $eminute = substr($calfoo['key'],2,2);
89 if (!is_array($calfoo['value'])){
90 echo html_tag( 'tr',
91 html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
92 html_tag( 'td', '&nbsp;', 'left' ) .
93 html_tag( 'td',
94 "<font size=\"-1\"><a href=\"event_create.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."\">".
95 _("ADD") . "</a></font>" ,
96 'center' ) ,
97 '', $color[$eo]);
98
99 } else {
100 $calbar=$calfoo['value'];
101 if ($calbar['length']!=0){
102 $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
103 } else {
104 $elength='';
105 }
106 echo html_tag( 'tr', '', '', $color[$eo] ) .
107 html_tag( 'td', $ehour . ':' . $eminute . $elength, 'left' ) .
108 html_tag( 'td', '', 'left' ) . '[';
109 echo ($calbar['priority']==1) ? "<font color=\"$color[1]\">$calbar[title]</font>" : "$calbar[title]";
110 echo"] $calbar[message]&nbsp;" .
111 html_tag( 'td',
112 "<font size=\"-1\"><nobr>\n" .
113 "<a href=\"event_edit.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."&minute=".substr($calfoo['key'],2,2)."\">".
114 _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
115 "<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\">" .
116 _("DEL") . '</a>' .
117 "</nobr></font>\n" ,
118 'center' );
119 }
120 }
121
122
123 }
124
125 if ($month <= 0){
126 $month = date( 'm');
127 }
128 if ($year <= 0){
129 $year = date( 'Y');
130 }
131 if ($day <= 0){
132 $day = date( 'd');
133 }
134
135 $prev_date = mktime(0, 0, 0, $month , $day - 1, $year);
136 $next_date = mktime(0, 0, 0, $month , $day + 1, $year);
137 $prev_day = date ('d',$prev_date);
138 $prev_month = date ('m',$prev_date);
139 $prev_year = date ('Y',$prev_date);
140 $next_day = date ('d',$next_date);
141 $next_month = date ('m',$next_date);
142 $next_year = date ('Y',$next_date);
143
144 $calself=basename($PHP_SELF);
145
146 $daily_events = array();
147
148 displayPageHeader($color, 'None');
149 calendar_header();
150 readcalendardata();
151 day_header();
152 initialize_events();
153 display_events();
154 ?>
155 </table></td></tr></table>
156 </body></html>