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