36ae7171bb6acbf8e26cb4c7d645c11d02e84590
[squirrelmail.git] / plugins / calendar / day.php
1 <?php
2 /*
3 * day.php
4 *
5 * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
7 *
8 * Displays the day page (day view).
9 *
10 * $Id$
11 */
12
13 require_once('calendar_data.php');
14 require_once('functions.php');
15 chdir('..');
16 require_once('../src/validate.php');
17 require_once('../functions/strings.php');
18 require_once('../functions/date.php');
19 require_once('../config/config.php');
20 require_once('../functions/page_header.php');
21 require_once('../src/load_prefs.php');
22
23 //displays head of day calendar view
24 function day_header() {
25 global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
26 $prev_date, $next_month, $next_day, $next_year, $next_date;
27
28 echo " <TR BGCOLOR=\"$color[0]\"><TD>" .
29 " <TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n" .
30 " <TR><TH WIDTH=\"5%\" ALIGN=LEFT><A HREF=\"day.php?year=$prev_year&month=$prev_month&day=$prev_day\">&lt;&nbsp;".
31 date_intl('D',$prev_date)."</A></TH>\n" .
32 " <TH WIDTH=\"75%\">" .
33 date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) . "</TH>\n" .
34 " <TH ALIGN=RIGHT><A HREF=\"day.php?year=$next_year&month=$next_month&day=$next_day\">".
35 date_intl('D',$next_date)."&nbsp;&gt;</A></TH></TR>\n";
36 }
37
38 //events for specific day are inserted into "daily" array
39 function initialize_events() {
40 global $daily_events, $calendardata, $month, $day, $year;
41
42 for ($i=7;$i<23;$i++){
43 if ($i<10){
44 $evntime = '0' . $i . '00';
45 } else {
46 $evntime = $i . '00';
47 }
48 $daily_events[$evntime] = 'empty';
49 }
50
51 $cdate = $month . $day . $year;
52
53 if (isset($calendardata[$cdate])){
54 while ( $calfoo = each($calendardata[$cdate])){
55 $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
56 }
57 }
58 }
59
60 //main loop for displaying daily events
61 function display_events() {
62 global $daily_events, $month, $day, $year, $color;
63
64 ksort($daily_events,SORT_STRING);
65 $eo=0;
66 while ($calfoo = each($daily_events)){
67 if ($eo==0){
68 $eo=4;
69 } else {
70 $eo=0;
71 }
72
73 $ehour = substr($calfoo['key'],0,2);
74 $eminute = substr($calfoo['key'],2,2);
75 if (!is_array($calfoo['value'])){
76 echo " <TR BGCOLOR=\"$color[$eo]\"><TD>$ehour:$eminute</TD>\n" .
77 " <TD>&nbsp;</TD>\n" .
78 " <TD ALIGN=CENTER><FONT SIZE=-1><A HREF=\"event_create.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."\">".
79 _("ADD") . "</A></FONT></TD></TR>\n";
80 } else {
81 $calbar=$calfoo['value'];
82 if ($calbar['length']!=0){
83 $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
84 } else {
85 $elength='';
86 }
87 echo " <TR BGCOLOR=\"$color[$eo]\"><TD>$ehour:$eminute$elength</TD>\n" .
88 " <TD>[";
89 echo ($calbar['priority']==1) ? "<FONT COLOR=\"$color[1]\">$calbar[title]</FONT>" : "$calbar[title]";
90 echo"] $calbar[message]&nbsp;</TD>\n" .
91 " <TD ALIGN=CENTER><FONT SIZE=-1><nobr>\n" .
92 "<A HREF=\"event_edit.php?year=$year&month=$month&day=$day&hour=".substr($calfoo['key'],0,2)."&minute=".substr($calfoo['key'],2,2)."\">".
93 _("EDIT") . "</A>&nbsp;|&nbsp;\n" .
94 "<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\">" .
95 _("DEL") . '</A>' .
96 " </nobr></FONT></TD></TR>\n";
97 }
98 }
99
100
101 }
102
103 if ($month <= 0){
104 $month = date( 'm');
105 }
106 if ($year <= 0){
107 $year = date( 'Y');
108 }
109 if ($day <= 0){
110 $day = date( 'd');
111 }
112
113 $prev_date = mktime(0, 0, 0, $month , $day - 1, $year);
114 $next_date = mktime(0, 0, 0, $month , $day + 1, $year);
115 $prev_day = date ('d',$prev_date);
116 $prev_month = date ('m',$prev_date);
117 $prev_year = date ('Y',$prev_date);
118 $next_day = date ('d',$next_date);
119 $next_month = date ('m',$next_date);
120 $next_year = date ('Y',$next_date);
121
122 $calself=basename($PHP_SELF);
123
124 $daily_events = array();
125
126 displayPageHeader($color, 'None');
127 calendar_header();
128 readcalendardata();
129 day_header();
130 initialize_events();
131 display_events();
132 ?>
133 </table></td></tr></table>
134 </body></html>