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