A start for a new change_password master plugin. This is not finished
[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$
ea5f4b8e 14 * @package plugins
15 * @subpackage calendar
9fe56672 16 */
d61a01d4 17
ea5f4b8e 18/** @ignore */
8d6a115b 19define('SM_PATH','../../');
cf1efdce 20
8d6a115b 21/* Calender plugin required files. */
22require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
23require_once(SM_PATH . 'plugins/calendar/functions.php');
cf1efdce 24
25/* SquirrelMail required files. */
26require_once(SM_PATH . 'include/validate.php');
27require_once(SM_PATH . 'functions/strings.php');
28require_once(SM_PATH . 'functions/date.php');
29require_once(SM_PATH . 'config/config.php');
30require_once(SM_PATH . 'functions/page_header.php');
aa7fb30c 31require_once(SM_PATH . 'include/load_prefs.php');
cf1efdce 32require_once(SM_PATH . 'functions/html.php');
d61a01d4 33
95dcee50 34/* get globals */
35if (isset($_GET['year'])) {
36 $year = $_GET['year'];
37}
38elseif (isset($_POST['year'])) {
39 $year = $_POST['year'];
40}
41if (isset($_GET['month'])) {
42 $month = $_GET['month'];
43}
44elseif (isset($_POST['month'])) {
45 $month = $_POST['month'];
46}
47if (isset($_GET['day'])) {
48 $day = $_GET['day'];
49}
50elseif (isset($_POST['day'])) {
51 $day = $_POST['day'];
52}
53
54/* got 'em */
55
d61a01d4 56//displays head of day calendar view
57function 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
b01b21d0 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',
1ba8cd6b 66 "<a href=\"day.php?year=$prev_year&amp;month=$prev_month&amp;day=$prev_day\">&lt;&nbsp;".
b01b21d0 67 date_intl('D',$prev_date)."</a>",
68 'left' ) .
f3409980 69 html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
70 '', '', 'width="75%"' ) .
b01b21d0 71 html_tag( 'th',
1ba8cd6b 72 "<a href=\"day.php?year=$next_year&amp;month=$next_month&amp;day=$next_day\">".
b01b21d0 73 date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
74 'right' )
75 );
d61a01d4 76}
77
78//events for specific day are inserted into "daily" array
79function 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])){
88cb1b4d 95 $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
d61a01d4 96 }
97 }
98}
99
100//main loop for displaying daily events
101function 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
88cb1b4d 113 $ehour = substr($calfoo['key'],0,2);
114 $eminute = substr($calfoo['key'],2,2);
115 if (!is_array($calfoo['value'])){
b01b21d0 116 echo html_tag( 'tr',
117 html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
118 html_tag( 'td', '&nbsp;', 'left' ) .
119 html_tag( 'td',
1ba8cd6b 120 "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".substr($calfoo['key'],0,2)."\">".
b01b21d0 121 _("ADD") . "</a></font>" ,
122 'center' ) ,
123 '', $color[$eo]);
124
d61a01d4 125 } else {
88cb1b4d 126 $calbar=$calfoo['value'];
127 if ($calbar['length']!=0){
128 $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
d61a01d4 129 } else {
130 $elength='';
131 }
b01b21d0 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" .
1ba8cd6b 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)."\">".
b01b21d0 140 _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
1ba8cd6b 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\">" .
b01b21d0 142 _("DEL") . '</a>' .
143 "</nobr></font>\n" ,
144 'center' );
d61a01d4 145 }
d61a01d4 146}
147
148
149}
150
151if ($month <= 0){
152 $month = date( 'm');
153}
154if ($year <= 0){
155 $year = date( 'Y');
156}
157if ($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
174displayPageHeader($color, 'None');
175calendar_header();
176readcalendardata();
177day_header();
178initialize_events();
179display_events();
d61a01d4 180?>
181</table></td></tr></table>
34d86c16 182</body></html>