if we can't open stream. we make up server's error message
[squirrelmail.git] / plugins / calendar / day.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
4 * day.php
d61a01d4 5 *
7c67a5e8 6 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
7 *
8 * Displays the day page (day view).
d61a01d4 9 *
4b4abf93 10 * @copyright &copy; 2002-2005 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @version $Id$
ea5f4b8e 13 * @package plugins
14 * @subpackage calendar
9fe56672 15 */
d61a01d4 16
ea5f4b8e 17/** @ignore */
8d6a115b 18define('SM_PATH','../../');
cf1efdce 19
8d6a115b 20/* Calender plugin required files. */
21require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
22require_once(SM_PATH . 'plugins/calendar/functions.php');
cf1efdce 23
24/* SquirrelMail required files. */
25require_once(SM_PATH . 'include/validate.php');
26require_once(SM_PATH . 'functions/strings.php');
27require_once(SM_PATH . 'functions/date.php');
28require_once(SM_PATH . 'config/config.php');
29require_once(SM_PATH . 'functions/page_header.php');
aa7fb30c 30require_once(SM_PATH . 'include/load_prefs.php');
cf1efdce 31require_once(SM_PATH . 'functions/html.php');
d61a01d4 32
95dcee50 33/* get globals */
a6d3eff6 34
35// undo rg = on effects
36if (isset($month)) unset($month);
37if (isset($year)) unset($year);
38if (isset($day)) unset($day);
39
40if (isset($_GET['year']) && is_numeric($_GET['year'])) {
95dcee50 41 $year = $_GET['year'];
42}
a6d3eff6 43elseif (isset($_POST['year']) && is_numeric($_POST['year'])) {
95dcee50 44 $year = $_POST['year'];
45}
a6d3eff6 46if (isset($_GET['month']) && is_numeric($_GET['month'])) {
95dcee50 47 $month = $_GET['month'];
48}
a6d3eff6 49elseif (isset($_POST['month']) && is_numeric($_POST['month'])) {
95dcee50 50 $month = $_POST['month'];
51}
a6d3eff6 52if (isset($_GET['day']) && is_numeric($_GET['day'])) {
95dcee50 53 $day = $_GET['day'];
54}
a6d3eff6 55elseif (isset($_POST['day']) && is_numeric($_POST['day'])) {
95dcee50 56 $day = $_POST['day'];
57}
58
59/* got 'em */
60
d61a01d4 61//displays head of day calendar view
62function day_header() {
63 global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
64 $prev_date, $next_month, $next_day, $next_year, $next_date;
65
b01b21d0 66 echo html_tag( 'tr', '', '', $color[0] ) . "\n".
67 html_tag( 'td', '', 'left' ) .
68 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" .
91e0dccc 69 html_tag( 'tr',
b01b21d0 70 html_tag( 'th',
1ba8cd6b 71 "<a href=\"day.php?year=$prev_year&amp;month=$prev_month&amp;day=$prev_day\">&lt;&nbsp;".
b01b21d0 72 date_intl('D',$prev_date)."</a>",
73 'left' ) .
f3409980 74 html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
75 '', '', 'width="75%"' ) .
b01b21d0 76 html_tag( 'th',
1ba8cd6b 77 "<a href=\"day.php?year=$next_year&amp;month=$next_month&amp;day=$next_day\">".
b01b21d0 78 date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
79 'right' )
80 );
d61a01d4 81}
82
83//events for specific day are inserted into "daily" array
84function initialize_events() {
85 global $daily_events, $calendardata, $month, $day, $year;
86
87 for ($i=7;$i<23;$i++){
88 if ($i<10){
89 $evntime = '0' . $i . '00';
90 } else {
91 $evntime = $i . '00';
92 }
93 $daily_events[$evntime] = 'empty';
94 }
95
96 $cdate = $month . $day . $year;
97
98 if (isset($calendardata[$cdate])){
99 while ( $calfoo = each($calendardata[$cdate])){
88cb1b4d 100 $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
d61a01d4 101 }
102 }
103}
104
105//main loop for displaying daily events
106function display_events() {
107 global $daily_events, $month, $day, $year, $color;
108
109 ksort($daily_events,SORT_STRING);
110 $eo=0;
111 while ($calfoo = each($daily_events)){
112 if ($eo==0){
113 $eo=4;
114 } else {
115 $eo=0;
116 }
117
88cb1b4d 118 $ehour = substr($calfoo['key'],0,2);
119 $eminute = substr($calfoo['key'],2,2);
120 if (!is_array($calfoo['value'])){
b01b21d0 121 echo html_tag( 'tr',
122 html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
123 html_tag( 'td', '&nbsp;', 'left' ) .
124 html_tag( 'td',
1ba8cd6b 125 "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".substr($calfoo['key'],0,2)."\">".
b01b21d0 126 _("ADD") . "</a></font>" ,
127 'center' ) ,
128 '', $color[$eo]);
129
d61a01d4 130 } else {
88cb1b4d 131 $calbar=$calfoo['value'];
132 if ($calbar['length']!=0){
133 $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
d61a01d4 134 } else {
135 $elength='';
136 }
b01b21d0 137 echo html_tag( 'tr', '', '', $color[$eo] ) .
138 html_tag( 'td', $ehour . ':' . $eminute . $elength, 'left' ) .
139 html_tag( 'td', '', 'left' ) . '[';
140 echo ($calbar['priority']==1) ? "<font color=\"$color[1]\">$calbar[title]</font>" : "$calbar[title]";
141 echo"] $calbar[message]&nbsp;" .
142 html_tag( 'td',
143 "<font size=\"-1\"><nobr>\n" .
1ba8cd6b 144 "<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 145 _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
1ba8cd6b 146 "<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 147 _("DEL") . '</a>' .
148 "</nobr></font>\n" ,
149 'center' );
d61a01d4 150 }
d61a01d4 151}
152
153
154}
155
156if ($month <= 0){
157 $month = date( 'm');
158}
159if ($year <= 0){
160 $year = date( 'Y');
161}
162if ($day <= 0){
163 $day = date( 'd');
164}
165
166$prev_date = mktime(0, 0, 0, $month , $day - 1, $year);
167$next_date = mktime(0, 0, 0, $month , $day + 1, $year);
168$prev_day = date ('d',$prev_date);
169$prev_month = date ('m',$prev_date);
170$prev_year = date ('Y',$prev_date);
171$next_day = date ('d',$next_date);
172$next_month = date ('m',$next_date);
173$next_year = date ('Y',$next_date);
174
175$calself=basename($PHP_SELF);
176
177$daily_events = array();
178
179displayPageHeader($color, 'None');
180calendar_header();
181readcalendardata();
182day_header();
183initialize_events();
184display_events();
d61a01d4 185?>
186</table></td></tr></table>
91e0dccc 187</body></html>