removed local directory name used for testing.
[squirrelmail.git] / plugins / calendar / calendar.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
4 * calendar.php
d61a01d4 5 *
6c84ba1e 6 * Copyright (c) 2002-2005 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>
d61a01d4 10 *
7c67a5e8 11 * Displays the main calendar page (month view).
d61a01d4 12 *
2c85de8f 13 * $Id$
ea5f4b8e 14 * @package plugins
15 * @subpackage calendar
d61a01d4 16 */
ea5f4b8e 17
18/**
19*/
8d6a115b 20define('SM_PATH','../../');
d61a01d4 21
8d6a115b 22/* Calender plugin required files. */
23require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
24require_once(SM_PATH . 'plugins/calendar/functions.php');
cf1efdce 25
26/* SquirrelMail required files. */
27require_once(SM_PATH . 'include/validate.php');
28require_once(SM_PATH . 'functions/strings.php');
29require_once(SM_PATH . 'functions/date.php');
30require_once(SM_PATH . 'config/config.php');
31require_once(SM_PATH . 'functions/page_header.php');
aa7fb30c 32require_once(SM_PATH . 'include/load_prefs.php');
cf1efdce 33require_once(SM_PATH . 'functions/html.php');
d61a01d4 34
95dcee50 35/* get globals */
36
a6d3eff6 37// undo rg = on effects
38if (isset($month)) unset($month);
39if (isset($year)) unset($year);
40
41if (isset($_GET['month']) && is_numeric($_GET['month'])) {
95dcee50 42 $month = $_GET['month'];
43}
a6d3eff6 44if (isset($_GET['year']) && is_numeric($_GET['year'])) {
95dcee50 45 $year = $_GET['year'];
46}
a6d3eff6 47if (isset($_POST['year']) && is_numeric($_POST['year'])) {
95dcee50 48 $year = $_POST['year'];
49}
a6d3eff6 50if (isset($_POST['month']) && is_numeric($_POST['month'])) {
95dcee50 51 $month = $_POST['month'];
52}
53/* got 'em */
54
d61a01d4 55//display upper part of month calendar view
56function startcalendar() {
ce68b76b 57 global $year, $month, $color;
d61a01d4 58
59 $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
60 $act_date = mktime(0, 0, 0, $month, 1, $year);
61 $next_date = mktime(0, 0, 0, $month + 1, 1, $year);
62 $prev_month = date( 'm', $prev_date );
63 $next_month = date( 'm', $next_date);
64 $prev_year = date( 'Y', $prev_date);
65 $next_year = date( 'Y', $next_date );
88cb1b4d 66 $self = 'calendar.php';
d61a01d4 67
b01b21d0 68 echo html_tag( 'tr', "\n".
69 html_tag( 'td', "\n".
70 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
71 html_tag( 'tr', "\n".
72 html_tag( 'th',
1ba8cd6b 73 "<a href=\"$self?year=".($year-1)."&amp;month=$month\">&lt;&lt;&nbsp;".($year-1)."</a>"
b01b21d0 74 ) . "\n".
75 html_tag( 'th',
1ba8cd6b 76 "<a href=\"$self?year=$prev_year&amp;month=$prev_month\">&lt;&nbsp;" .
b01b21d0 77 date_intl( 'M', $prev_date). "</a>"
78 ) . "\n".
79 html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
80 html_tag( 'th',
1ba8cd6b 81 "<a href=\"$self?year=$next_year&amp;month=$next_month\">" .
b01b21d0 82 date_intl( 'M', $next_date) . "&nbsp;&gt;</a>"
83 ) . "\n".
84 html_tag( 'th',
1ba8cd6b 85 "<a href=\"$self?year=".($year+1)."&amp;month=$month\">".($year+1)."&nbsp;&gt;&gt;</a>"
b01b21d0 86 )
87 ) . "\n".
88 html_tag( 'tr',
89 html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
90 html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
91 html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
92 html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
93 html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
94 html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
95 html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n"
96 )
97 ) ,
98 '', $color[0] ) ."\n";
d61a01d4 99}
100
101//main logic for month view of calendar
102function drawmonthview() {
8d8da447 103 global $year, $month, $color, $calendardata, $todayis;
d61a01d4 104
105 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
106 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
107 while ($aday <= $days_in_month) {
b01b21d0 108 echo html_tag( 'tr' );
d61a01d4 109 for ($j=1; $j<=7; $j++) {
110 $cdate="$month";
111 ($aday<10)?$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
112 $cdate=$cdate."$year";
113 if ( $aday <= $days_in_month && $aday > 0){
b01b21d0 114 echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
115 html_tag( 'div', '', 'right' );
6fd95361 116 echo(($cdate==$todayis) ? '<font size="-1" color="'.$color[1].'">[ ' . _("TODAY") . " ] " : '<font size="-1">');
1ba8cd6b 117 echo "<a href=day.php?year=$year&amp;month=$month&amp;day=";
d61a01d4 118 echo(($aday<10) ? "0" : "");
119 echo "$aday>$aday</a></font></div>";
120 } else {
b01b21d0 121 echo html_tag( 'td', '', 'left', $color[0]) ."\n".
d61a01d4 122 "&nbsp;";
123 }
124 if (isset($calendardata[$cdate])){
125 $i=0;
126 while ($calfoo = each($calendardata[$cdate])) {
88cb1b4d 127 $calbar = $calendardata[$cdate][$calfoo['key']];
5d01bcce 128 $title = '['. $calfoo['key']. '] ' .$calbar['message'];
6fd95361 129 echo ($calbar['priority']==1) ? "<a href=\"#\" style=\"text-decoration:none; color: $color[1]\" title=\"$title\">$calbar[title]</a><br />\n" : "<a href=\"#\" style=\"text-decoration:none; color: $color[6]\" title=\"$title\">$calbar[title]</a><br />\n";
d61a01d4 130 $i=$i+1;
131 if($i==2){
132 break;
133 }
134 }
135 }
b01b21d0 136 echo "\n</td>\n";
d61a01d4 137 $aday++;
138 }
139 echo '</tr>';
140 }
141}
142
143//end of monthly view and form to jump to any month and year
144function endcalendar() {
145 global $year, $month, $day, $color;
146
b01b21d0 147 echo html_tag( 'tr' ) ."\n" .
148 html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
6fd95361 149 " <form name=\"caljump\" action=\"calendar.php\" method=\"post\">\n".
150 " <select name=\"year\">\n";
d61a01d4 151 select_option_year($year);
6fd95361 152 echo " </select>\n".
153 " <select name=\"month\">\n";
d61a01d4 154 select_option_month($month);
6fd95361 155 echo " </select>\n".
156 ' <input type="submit" value="' . _("Go") . "\" />\n".
157 " </form>\n".
158 " </td></tr>\n".
159 "</table></td></tr></table>\n";
d61a01d4 160}
161
162
88cb1b4d 163if( !isset( $month ) || $month <= 0){
d61a01d4 164 $month = date( 'm' );
165}
88cb1b4d 166if( !isset($year) || $year <= 0){
d61a01d4 167 $year = date( 'Y' );
168}
88cb1b4d 169if( !isset($day) || $day <= 0){
d61a01d4 170 $day = date( 'd' );
171}
172
173$todayis = date( 'mdY' );
174$calself=basename($PHP_SELF);
175
176displayPageHeader($color, 'None');
177calendar_header();
178readcalendardata();
179startcalendar();
180drawmonthview();
181endcalendar();
182
183?>
91e0dccc 184</body></html>