New get_plugin_version() function, and a couple places to use it.
[squirrelmail.git] / plugins / calendar / day.php
1 <?php
2
3 /**
4 * Displays the day page (day view).
5 *
6 * @copyright &copy; 2002-2007 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
9 * @package plugins
10 * @subpackage calendar
11 */
12
13 /**
14 * Include the SquirrelMail initialization file.
15 */
16 require('../../include/init.php');
17
18 /* date_intl() */
19 include_once(SM_PATH . 'functions/date.php');
20
21 /* Calendar plugin required files. */
22 include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
23 include_once(SM_PATH . 'plugins/calendar/functions.php');
24
25 /* get globals */
26 if (! sqGetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
27 unset($year);
28 }
29 if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
30 unset($month);
31 }
32 if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) {
33 unset($day);
34 }
35 /* got 'em */
36
37 /**
38 * displays head of day calendar view
39 * @return void
40 * @access private
41 */
42 function day_header() {
43 global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
44 $prev_date, $next_month, $next_day, $next_year, $next_date;
45
46 echo html_tag( 'tr', '', '', $color[0] ) . "\n".
47 html_tag( 'td', '', 'left' ) .
48 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" .
49 html_tag( 'tr',
50 html_tag( 'th',
51 "<a href=\"day.php?year=$prev_year&amp;month=$prev_month&amp;day=$prev_day\">&lt;&nbsp;".
52 date_intl('D',$prev_date)."</a>",
53 'left' ) .
54 html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
55 '', '', 'width="75%"' ) .
56 html_tag( 'th',
57 "<a href=\"day.php?year=$next_year&amp;month=$next_month&amp;day=$next_day\">".
58 date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
59 'right' )
60 );
61 }
62
63 /**
64 * events for specific day are inserted into "daily" array
65 * @return void
66 * @access private
67 */
68 function initialize_events() {
69 global $daily_events, $calendardata, $month, $day, $year;
70
71 for ($i=7;$i<23;$i++){
72 if ($i<10){
73 $evntime = '0' . $i . '00';
74 } else {
75 $evntime = $i . '00';
76 }
77 $daily_events[$evntime] = 'empty';
78 }
79
80 $cdate = $month . $day . $year;
81
82 if (isset($calendardata[$cdate])){
83 while ( $calfoo = each($calendardata[$cdate])){
84 $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
85 }
86 }
87 }
88
89 /**
90 * main loop for displaying daily events
91 * @return void
92 * @access private
93 */
94 function display_events() {
95 global $daily_events, $month, $day, $year, $color;
96
97 ksort($daily_events,SORT_STRING);
98 $eo=0;
99 while ($calfoo = each($daily_events)){
100 if ($eo==0){
101 $eo=4;
102 } else {
103 $eo=0;
104 }
105
106 $ehour = substr($calfoo['key'],0,2);
107 $eminute = substr($calfoo['key'],2,2);
108 if (!is_array($calfoo['value'])){
109 echo html_tag( 'tr',
110 html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
111 html_tag( 'td', '&nbsp;', 'left' ) .
112 html_tag( 'td',
113 "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;hour="
114 .substr($calfoo['key'],0,2)."\">".
115 _("ADD") . "</a></font>" ,
116 'center' ) ,
117 '', $color[$eo]);
118
119 } else {
120 $calbar=$calfoo['value'];
121 if ($calbar['length']!=0){
122 $elength = '-'.date_intl(_("H:i"),mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
123 } else {
124 $elength='';
125 }
126 echo html_tag( 'tr', '', '', $color[$eo] ) .
127 html_tag( 'td', date_intl(_("H:i"),mktime($ehour,$eminute,0,1,1,0)) . $elength, 'left' ) .
128 html_tag( 'td', '', 'left' ) . '[';
129 echo ($calbar['priority']==1) ?
130 "<font color=\"$color[1]\">".htmlspecialchars($calbar['title']).'</font>' :
131 htmlspecialchars($calbar['title']);
132 echo'] <div style="margin-left:10px">'.nl2br(htmlspecialchars($calbar['message'])).'</div>' .
133 html_tag( 'td',
134 "<font size=\"-1\"><nobr>\n" .
135 "<a href=\"event_edit.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".
136 substr($calfoo['key'],0,2)."&amp;minute=".substr($calfoo['key'],2,2)."\">".
137 _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
138 "<a href=\"event_delete.php?dyear=$year&amp;dmonth=$month&amp;dday=$day&amp;dhour=".
139 substr($calfoo['key'],0,2)."&amp;dminute=".substr($calfoo['key'],2,2).
140 "&amp;year=$year&amp;month=$month&amp;day=$day\">" .
141 _("DEL") . '</a>' .
142 "</nobr></font>\n" ,
143 'center' );
144 }
145 }
146 }
147 /* end of day functions */
148
149 if ($month <= 0){
150 $month = date( 'm');
151 }
152 if ($year <= 0){
153 $year = date( 'Y');
154 }
155 if ($day <= 0){
156 $day = date( 'd');
157 }
158
159 $prev_date = mktime(0, 0, 0, $month , $day - 1, $year);
160 $next_date = mktime(0, 0, 0, $month , $day + 1, $year);
161 $prev_day = date ('d',$prev_date);
162 $prev_month = date ('m',$prev_date);
163 $prev_year = date ('Y',$prev_date);
164 $next_day = date ('d',$next_date);
165 $next_month = date ('m',$next_date);
166 $next_year = date ('Y',$next_date);
167
168 $calself=basename($PHP_SELF);
169
170 $daily_events = array();
171
172 displayPageHeader($color, 'None');
173 calendar_header();
174 readcalendardata();
175 day_header();
176 initialize_events();
177 display_events();
178 ?>
179 </table></td></tr></table>
180 </body></html>