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