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