d61a01d4 |
1 | <?php |
7c67a5e8 |
2 | |
3 | /** |
4 | * day.php |
d61a01d4 |
5 | * |
6c84ba1e |
6 | * Copyright (c) 2002-2005 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 */ |
a6d3eff6 |
35 | |
36 | // undo rg = on effects |
37 | if (isset($month)) unset($month); |
38 | if (isset($year)) unset($year); |
39 | if (isset($day)) unset($day); |
40 | |
41 | if (isset($_GET['year']) && is_numeric($_GET['year'])) { |
95dcee50 |
42 | $year = $_GET['year']; |
43 | } |
a6d3eff6 |
44 | elseif (isset($_POST['year']) && is_numeric($_POST['year'])) { |
95dcee50 |
45 | $year = $_POST['year']; |
46 | } |
a6d3eff6 |
47 | if (isset($_GET['month']) && is_numeric($_GET['month'])) { |
95dcee50 |
48 | $month = $_GET['month']; |
49 | } |
a6d3eff6 |
50 | elseif (isset($_POST['month']) && is_numeric($_POST['month'])) { |
95dcee50 |
51 | $month = $_POST['month']; |
52 | } |
a6d3eff6 |
53 | if (isset($_GET['day']) && is_numeric($_GET['day'])) { |
95dcee50 |
54 | $day = $_GET['day']; |
55 | } |
a6d3eff6 |
56 | elseif (isset($_POST['day']) && is_numeric($_POST['day'])) { |
95dcee50 |
57 | $day = $_POST['day']; |
58 | } |
59 | |
60 | /* got 'em */ |
61 | |
d61a01d4 |
62 | //displays head of day calendar view |
63 | function day_header() { |
64 | global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day, |
65 | $prev_date, $next_month, $next_day, $next_year, $next_date; |
66 | |
b01b21d0 |
67 | echo html_tag( 'tr', '', '', $color[0] ) . "\n". |
68 | html_tag( 'td', '', 'left' ) . |
69 | html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" . |
91e0dccc |
70 | html_tag( 'tr', |
b01b21d0 |
71 | html_tag( 'th', |
1ba8cd6b |
72 | "<a href=\"day.php?year=$prev_year&month=$prev_month&day=$prev_day\">< ". |
b01b21d0 |
73 | date_intl('D',$prev_date)."</a>", |
74 | 'left' ) . |
f3409980 |
75 | html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) , |
76 | '', '', 'width="75%"' ) . |
b01b21d0 |
77 | html_tag( 'th', |
1ba8cd6b |
78 | "<a href=\"day.php?year=$next_year&month=$next_month&day=$next_day\">". |
b01b21d0 |
79 | date_intl('D',$next_date)." ></a>" , |
80 | 'right' ) |
81 | ); |
d61a01d4 |
82 | } |
83 | |
84 | //events for specific day are inserted into "daily" array |
85 | function initialize_events() { |
86 | global $daily_events, $calendardata, $month, $day, $year; |
87 | |
88 | for ($i=7;$i<23;$i++){ |
89 | if ($i<10){ |
90 | $evntime = '0' . $i . '00'; |
91 | } else { |
92 | $evntime = $i . '00'; |
93 | } |
94 | $daily_events[$evntime] = 'empty'; |
95 | } |
96 | |
97 | $cdate = $month . $day . $year; |
98 | |
99 | if (isset($calendardata[$cdate])){ |
100 | while ( $calfoo = each($calendardata[$cdate])){ |
88cb1b4d |
101 | $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']]; |
d61a01d4 |
102 | } |
103 | } |
104 | } |
105 | |
106 | //main loop for displaying daily events |
107 | function display_events() { |
108 | global $daily_events, $month, $day, $year, $color; |
109 | |
110 | ksort($daily_events,SORT_STRING); |
111 | $eo=0; |
112 | while ($calfoo = each($daily_events)){ |
113 | if ($eo==0){ |
114 | $eo=4; |
115 | } else { |
116 | $eo=0; |
117 | } |
118 | |
88cb1b4d |
119 | $ehour = substr($calfoo['key'],0,2); |
120 | $eminute = substr($calfoo['key'],2,2); |
121 | if (!is_array($calfoo['value'])){ |
b01b21d0 |
122 | echo html_tag( 'tr', |
123 | html_tag( 'td', $ehour . ':' . $eminute, 'left' ) . |
124 | html_tag( 'td', ' ', 'left' ) . |
125 | html_tag( 'td', |
1ba8cd6b |
126 | "<font size=\"-1\"><a href=\"event_create.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."\">". |
b01b21d0 |
127 | _("ADD") . "</a></font>" , |
128 | 'center' ) , |
129 | '', $color[$eo]); |
130 | |
d61a01d4 |
131 | } else { |
88cb1b4d |
132 | $calbar=$calfoo['value']; |
133 | if ($calbar['length']!=0){ |
134 | $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0)); |
d61a01d4 |
135 | } else { |
136 | $elength=''; |
137 | } |
b01b21d0 |
138 | echo html_tag( 'tr', '', '', $color[$eo] ) . |
139 | html_tag( 'td', $ehour . ':' . $eminute . $elength, 'left' ) . |
140 | html_tag( 'td', '', 'left' ) . '['; |
141 | echo ($calbar['priority']==1) ? "<font color=\"$color[1]\">$calbar[title]</font>" : "$calbar[title]"; |
142 | echo"] $calbar[message] " . |
143 | html_tag( 'td', |
144 | "<font size=\"-1\"><nobr>\n" . |
1ba8cd6b |
145 | "<a href=\"event_edit.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."&minute=".substr($calfoo['key'],2,2)."\">". |
b01b21d0 |
146 | _("EDIT") . "</a> | \n" . |
1ba8cd6b |
147 | "<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 |
148 | _("DEL") . '</a>' . |
149 | "</nobr></font>\n" , |
150 | 'center' ); |
d61a01d4 |
151 | } |
d61a01d4 |
152 | } |
153 | |
154 | |
155 | } |
156 | |
157 | if ($month <= 0){ |
158 | $month = date( 'm'); |
159 | } |
160 | if ($year <= 0){ |
161 | $year = date( 'Y'); |
162 | } |
163 | if ($day <= 0){ |
164 | $day = date( 'd'); |
165 | } |
166 | |
167 | $prev_date = mktime(0, 0, 0, $month , $day - 1, $year); |
168 | $next_date = mktime(0, 0, 0, $month , $day + 1, $year); |
169 | $prev_day = date ('d',$prev_date); |
170 | $prev_month = date ('m',$prev_date); |
171 | $prev_year = date ('Y',$prev_date); |
172 | $next_day = date ('d',$next_date); |
173 | $next_month = date ('m',$next_date); |
174 | $next_year = date ('Y',$next_date); |
175 | |
176 | $calself=basename($PHP_SELF); |
177 | |
178 | $daily_events = array(); |
179 | |
180 | displayPageHeader($color, 'None'); |
181 | calendar_header(); |
182 | readcalendardata(); |
183 | day_header(); |
184 | initialize_events(); |
185 | display_events(); |
d61a01d4 |
186 | ?> |
187 | </table></td></tr></table> |
91e0dccc |
188 | </body></html> |