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