use different variable name in order to preserve original variable data
[squirrelmail.git] / plugins / calendar / day.php
1 <?php
2
3 /**
4 * day.php
5 *
6 * Copyright (c) 2002-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
10 *
11 * Displays the day page (day view).
12 *
13 * $Id$
14 * @package plugins
15 * @subpackage calendar
16 */
17
18 /** @ignore */
19 define('SM_PATH','../../');
20
21 /* Calender plugin required files. */
22 require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
23 require_once(SM_PATH . 'plugins/calendar/functions.php');
24
25 /* SquirrelMail required files. */
26 require_once(SM_PATH . 'include/validate.php');
27 require_once(SM_PATH . 'functions/strings.php');
28 require_once(SM_PATH . 'functions/date.php');
29 require_once(SM_PATH . 'config/config.php');
30 require_once(SM_PATH . 'functions/page_header.php');
31 require_once(SM_PATH . 'include/load_prefs.php');
32 require_once(SM_PATH . 'functions/html.php');
33
34 /* get globals */
35
36 // undo rg = on effects
37 if (isset($month)) unset($month);
38 if (isset($year)) unset($year);
39 if (isset($day)) unset($day);
40
41 if (isset($_GET['year']) && is_numeric($_GET['year'])) {
42 $year = $_GET['year'];
43 }
44 elseif (isset($_POST['year']) && is_numeric($_POST['year'])) {
45 $year = $_POST['year'];
46 }
47 if (isset($_GET['month']) && is_numeric($_GET['month'])) {
48 $month = $_GET['month'];
49 }
50 elseif (isset($_POST['month']) && is_numeric($_POST['month'])) {
51 $month = $_POST['month'];
52 }
53 if (isset($_GET['day']) && is_numeric($_GET['day'])) {
54 $day = $_GET['day'];
55 }
56 elseif (isset($_POST['day']) && is_numeric($_POST['day'])) {
57 $day = $_POST['day'];
58 }
59
60 /* got 'em */
61
62 //displays head of day calendar view
63 function 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
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" .
70 html_tag( 'tr',
71 html_tag( 'th',
72 "<a href=\"day.php?year=$prev_year&amp;month=$prev_month&amp;day=$prev_day\">&lt;&nbsp;".
73 date_intl('D',$prev_date)."</a>",
74 'left' ) .
75 html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
76 '', '', 'width="75%"' ) .
77 html_tag( 'th',
78 "<a href=\"day.php?year=$next_year&amp;month=$next_month&amp;day=$next_day\">".
79 date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
80 'right' )
81 );
82 }
83
84 //events for specific day are inserted into "daily" array
85 function 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])){
101 $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
102 }
103 }
104 }
105
106 //main loop for displaying daily events
107 function 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
119 $ehour = substr($calfoo['key'],0,2);
120 $eminute = substr($calfoo['key'],2,2);
121 if (!is_array($calfoo['value'])){
122 echo html_tag( 'tr',
123 html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
124 html_tag( 'td', '&nbsp;', 'left' ) .
125 html_tag( 'td',
126 "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".substr($calfoo['key'],0,2)."\">".
127 _("ADD") . "</a></font>" ,
128 'center' ) ,
129 '', $color[$eo]);
130
131 } else {
132 $calbar=$calfoo['value'];
133 if ($calbar['length']!=0){
134 $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
135 } else {
136 $elength='';
137 }
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" .
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)."\">".
146 _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
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\">" .
148 _("DEL") . '</a>' .
149 "</nobr></font>\n" ,
150 'center' );
151 }
152 }
153
154
155 }
156
157 if ($month <= 0){
158 $month = date( 'm');
159 }
160 if ($year <= 0){
161 $year = date( 'Y');
162 }
163 if ($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
180 displayPageHeader($color, 'None');
181 calendar_header();
182 readcalendardata();
183 day_header();
184 initialize_events();
185 display_events();
186 ?>
187 </table></td></tr></table>
188 </body></html>