removed local directory name used for testing.
[squirrelmail.git] / plugins / calendar / day.php
CommitLineData
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 19define('SM_PATH','../../');
cf1efdce 20
8d6a115b 21/* Calender plugin required files. */
22require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
23require_once(SM_PATH . 'plugins/calendar/functions.php');
cf1efdce 24
25/* SquirrelMail required files. */
26require_once(SM_PATH . 'include/validate.php');
27require_once(SM_PATH . 'functions/strings.php');
28require_once(SM_PATH . 'functions/date.php');
29require_once(SM_PATH . 'config/config.php');
30require_once(SM_PATH . 'functions/page_header.php');
aa7fb30c 31require_once(SM_PATH . 'include/load_prefs.php');
cf1efdce 32require_once(SM_PATH . 'functions/html.php');
d61a01d4 33
95dcee50 34/* get globals */
a6d3eff6 35
36// undo rg = on effects
37if (isset($month)) unset($month);
38if (isset($year)) unset($year);
39if (isset($day)) unset($day);
40
41if (isset($_GET['year']) && is_numeric($_GET['year'])) {
95dcee50 42 $year = $_GET['year'];
43}
a6d3eff6 44elseif (isset($_POST['year']) && is_numeric($_POST['year'])) {
95dcee50 45 $year = $_POST['year'];
46}
a6d3eff6 47if (isset($_GET['month']) && is_numeric($_GET['month'])) {
95dcee50 48 $month = $_GET['month'];
49}
a6d3eff6 50elseif (isset($_POST['month']) && is_numeric($_POST['month'])) {
95dcee50 51 $month = $_POST['month'];
52}
a6d3eff6 53if (isset($_GET['day']) && is_numeric($_GET['day'])) {
95dcee50 54 $day = $_GET['day'];
55}
a6d3eff6 56elseif (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
63function 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&amp;month=$prev_month&amp;day=$prev_day\">&lt;&nbsp;".
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&amp;month=$next_month&amp;day=$next_day\">".
b01b21d0 79 date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
80 'right' )
81 );
d61a01d4 82}
83
84//events for specific day are inserted into "daily" array
85function 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
107function 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', '&nbsp;', 'left' ) .
125 html_tag( 'td',
1ba8cd6b 126 "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;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]&nbsp;" .
143 html_tag( 'td',
144 "<font size=\"-1\"><nobr>\n" .
1ba8cd6b 145 "<a href=\"event_edit.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".substr($calfoo['key'],0,2)."&amp;minute=".substr($calfoo['key'],2,2)."\">".
b01b21d0 146 _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
1ba8cd6b 147 "<a href=\"event_delete.php?dyear=$year&amp;dmonth=$month&amp;dday=$day&amp;dhour=".substr($calfoo['key'],0,2)."&amp;dminute=".substr($calfoo['key'],2,2)."&amp;year=$year&amp;month=$month&amp;day=$day\">" .
b01b21d0 148 _("DEL") . '</a>' .
149 "</nobr></font>\n" ,
150 'center' );
d61a01d4 151 }
d61a01d4 152}
153
154
155}
156
157if ($month <= 0){
158 $month = date( 'm');
159}
160if ($year <= 0){
161 $year = date( 'Y');
162}
163if ($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
180displayPageHeader($color, 'None');
181calendar_header();
182readcalendardata();
183day_header();
184initialize_events();
185display_events();
d61a01d4 186?>
187</table></td></tr></table>
91e0dccc 188</body></html>