Split out functionality that gathers system specs
[squirrelmail.git] / plugins / calendar / day.php
1 <?php
2
3 /**
4 * day.php
5 *
6 * Copyright (c) 2002-2004 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 if (isset($_GET['year'])) {
36 $year = $_GET['year'];
37 }
38 elseif (isset($_POST['year'])) {
39 $year = $_POST['year'];
40 }
41 if (isset($_GET['month'])) {
42 $month = $_GET['month'];
43 }
44 elseif (isset($_POST['month'])) {
45 $month = $_POST['month'];
46 }
47 if (isset($_GET['day'])) {
48 $day = $_GET['day'];
49 }
50 elseif (isset($_POST['day'])) {
51 $day = $_POST['day'];
52 }
53
54 /* got 'em */
55
56 //displays head of day calendar view
57 function day_header() {
58 global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
59 $prev_date, $next_month, $next_day, $next_year, $next_date;
60
61 echo html_tag( 'tr', '', '', $color[0] ) . "\n".
62 html_tag( 'td', '', 'left' ) .
63 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" .
64 html_tag( 'tr',
65 html_tag( 'th',
66 "<a href=\"day.php?year=$prev_year&amp;month=$prev_month&amp;day=$prev_day\">&lt;&nbsp;".
67 date_intl('D',$prev_date)."</a>",
68 'left' ) .
69 html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
70 '', '', 'width="75%"' ) .
71 html_tag( 'th',
72 "<a href=\"day.php?year=$next_year&amp;month=$next_month&amp;day=$next_day\">".
73 date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
74 'right' )
75 );
76 }
77
78 //events for specific day are inserted into "daily" array
79 function initialize_events() {
80 global $daily_events, $calendardata, $month, $day, $year;
81
82 for ($i=7;$i<23;$i++){
83 if ($i<10){
84 $evntime = '0' . $i . '00';
85 } else {
86 $evntime = $i . '00';
87 }
88 $daily_events[$evntime] = 'empty';
89 }
90
91 $cdate = $month . $day . $year;
92
93 if (isset($calendardata[$cdate])){
94 while ( $calfoo = each($calendardata[$cdate])){
95 $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
96 }
97 }
98 }
99
100 //main loop for displaying daily events
101 function display_events() {
102 global $daily_events, $month, $day, $year, $color;
103
104 ksort($daily_events,SORT_STRING);
105 $eo=0;
106 while ($calfoo = each($daily_events)){
107 if ($eo==0){
108 $eo=4;
109 } else {
110 $eo=0;
111 }
112
113 $ehour = substr($calfoo['key'],0,2);
114 $eminute = substr($calfoo['key'],2,2);
115 if (!is_array($calfoo['value'])){
116 echo html_tag( 'tr',
117 html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
118 html_tag( 'td', '&nbsp;', 'left' ) .
119 html_tag( 'td',
120 "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".substr($calfoo['key'],0,2)."\">".
121 _("ADD") . "</a></font>" ,
122 'center' ) ,
123 '', $color[$eo]);
124
125 } else {
126 $calbar=$calfoo['value'];
127 if ($calbar['length']!=0){
128 $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
129 } else {
130 $elength='';
131 }
132 echo html_tag( 'tr', '', '', $color[$eo] ) .
133 html_tag( 'td', $ehour . ':' . $eminute . $elength, 'left' ) .
134 html_tag( 'td', '', 'left' ) . '[';
135 echo ($calbar['priority']==1) ? "<font color=\"$color[1]\">$calbar[title]</font>" : "$calbar[title]";
136 echo"] $calbar[message]&nbsp;" .
137 html_tag( 'td',
138 "<font size=\"-1\"><nobr>\n" .
139 "<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)."\">".
140 _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
141 "<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\">" .
142 _("DEL") . '</a>' .
143 "</nobr></font>\n" ,
144 'center' );
145 }
146 }
147
148
149 }
150
151 if ($month <= 0){
152 $month = date( 'm');
153 }
154 if ($year <= 0){
155 $year = date( 'Y');
156 }
157 if ($day <= 0){
158 $day = date( 'd');
159 }
160
161 $prev_date = mktime(0, 0, 0, $month , $day - 1, $year);
162 $next_date = mktime(0, 0, 0, $month , $day + 1, $year);
163 $prev_day = date ('d',$prev_date);
164 $prev_month = date ('m',$prev_date);
165 $prev_year = date ('Y',$prev_date);
166 $next_day = date ('d',$next_date);
167 $next_month = date ('m',$next_date);
168 $next_year = date ('Y',$next_date);
169
170 $calself=basename($PHP_SELF);
171
172 $daily_events = array();
173
174 displayPageHeader($color, 'None');
175 calendar_header();
176 readcalendardata();
177 day_header();
178 initialize_events();
179 display_events();
180 ?>
181 </table></td></tr></table>
182 </body></html>