mail_fetch => rg=0
[squirrelmail.git] / plugins / calendar / calendar.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
4 * calendar.php
d61a01d4 5 *
7c67a5e8 6 * Copyright (c) 2002 The SquirrelMail Project Team
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$
d61a01d4 14 */
8d6a115b 15define('SM_PATH','../../');
d61a01d4 16
8d6a115b 17/* Calender plugin required files. */
18require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
19require_once(SM_PATH . 'plugins/calendar/functions.php');
cf1efdce 20
21/* SquirrelMail required files. */
22require_once(SM_PATH . 'include/validate.php');
23require_once(SM_PATH . 'functions/strings.php');
24require_once(SM_PATH . 'functions/date.php');
25require_once(SM_PATH . 'config/config.php');
26require_once(SM_PATH . 'functions/page_header.php');
aa7fb30c 27require_once(SM_PATH . 'include/load_prefs.php');
cf1efdce 28require_once(SM_PATH . 'functions/html.php');
d61a01d4 29
30//display upper part of month calendar view
31function startcalendar() {
32 global $year, $month, $day, $color;
33
34 $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
35 $act_date = mktime(0, 0, 0, $month, 1, $year);
36 $next_date = mktime(0, 0, 0, $month + 1, 1, $year);
37 $prev_month = date( 'm', $prev_date );
38 $next_month = date( 'm', $next_date);
39 $prev_year = date( 'Y', $prev_date);
40 $next_year = date( 'Y', $next_date );
88cb1b4d 41 $self = 'calendar.php';
d61a01d4 42
b01b21d0 43 echo html_tag( 'tr', "\n".
44 html_tag( 'td', "\n".
45 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
46 html_tag( 'tr', "\n".
47 html_tag( 'th',
48 "<a href=\"$self?year=".($year-1)."&month=$month\">&lt;&lt;&nbsp;".($year-1)."</a>"
49 ) . "\n".
50 html_tag( 'th',
51 "<a href=\"$self?year=$prev_year&month=$prev_month\">&lt;&nbsp;" .
52 date_intl( 'M', $prev_date). "</a>"
53 ) . "\n".
54 html_tag( 'th', date_intl( 'F Y', $act_date ), '', $color[0], 'colspan="3"') .
55 html_tag( 'th',
56 "<a href=\"$self?year=$next_year&month=$next_month\">" .
57 date_intl( 'M', $next_date) . "&nbsp;&gt;</a>"
58 ) . "\n".
59 html_tag( 'th',
60 "<a href=\"$self?year=".($year+1)."&month=$month\">".($year+1)."&nbsp;&gt;&gt;</a>"
61 )
62 ) . "\n".
63 html_tag( 'tr',
64 html_tag( 'th', _("Sunday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
65 html_tag( 'th', _("Monday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
66 html_tag( 'th', _("Tuesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
67 html_tag( 'th', _("Wednesday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
68 html_tag( 'th', _("Thursday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
69 html_tag( 'th', _("Friday"), '', $color[5], 'width="14%" width="90"' ) ."\n" .
70 html_tag( 'th', _("Saturday"), '', $color[5], 'width="14%" width="90"' ) ."\n"
71 )
72 ) ,
73 '', $color[0] ) ."\n";
d61a01d4 74}
75
76//main logic for month view of calendar
77function drawmonthview() {
78 global $year, $month, $day, $color, $calendardata, $todayis;
79
80 $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
81 $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
82 while ($aday <= $days_in_month) {
b01b21d0 83 echo html_tag( 'tr' );
d61a01d4 84 for ($j=1; $j<=7; $j++) {
85 $cdate="$month";
86 ($aday<10)?$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
87 $cdate=$cdate."$year";
88 if ( $aday <= $days_in_month && $aday > 0){
b01b21d0 89 echo html_tag( 'td', '', 'left', $color[4], 'height="50" valign="top"' ) ."\n".
90 html_tag( 'div', '', 'right' );
d61a01d4 91 echo(($cdate==$todayis) ? "<font size=-1 color=$color[1]>[ " . _("TODAY") . " ] " : "<font size=-1>");
92 echo "<a href=day.php?year=$year&month=$month&day=";
93 echo(($aday<10) ? "0" : "");
94 echo "$aday>$aday</a></font></div>";
95 } else {
b01b21d0 96 echo html_tag( 'td', '', 'left', $color[0]) ."\n".
d61a01d4 97 "&nbsp;";
98 }
99 if (isset($calendardata[$cdate])){
100 $i=0;
101 while ($calfoo = each($calendardata[$cdate])) {
88cb1b4d 102 $calbar = $calendardata[$cdate][$calfoo['key']];
103 echo ($calbar['priority']==1) ? "<FONT COLOR=\"$color[1]\">$calbar[title]</FONT><br>\n" : "$calbar[title]<br>\n";
d61a01d4 104 $i=$i+1;
105 if($i==2){
106 break;
107 }
108 }
109 }
b01b21d0 110 echo "\n</td>\n";
d61a01d4 111 $aday++;
112 }
113 echo '</tr>';
114 }
115}
116
117//end of monthly view and form to jump to any month and year
118function endcalendar() {
119 global $year, $month, $day, $color;
120
b01b21d0 121 echo html_tag( 'tr' ) ."\n" .
122 html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
d61a01d4 123 " <FORM NAME=caljump ACTION=\"calendar.php\" METHOD=POST>\n".
124 " <SELECT NAME=\"year\">\n";
125 select_option_year($year);
126 echo " </SELECT>\n".
127 " <SELECT NAME=\"month\">\n";
128 select_option_month($month);
129 echo " </SELECT>\n".
130 ' <INPUT TYPE=SUBMIT VALUE="' . _("Go") . "\">\n".
131 " </FORM>\n".
132 " </TD></TR>\n".
133 "</TABLE></TD></TR></TABLE>\n";
134}
135
136
88cb1b4d 137if( !isset( $month ) || $month <= 0){
d61a01d4 138 $month = date( 'm' );
139}
88cb1b4d 140if( !isset($year) || $year <= 0){
d61a01d4 141 $year = date( 'Y' );
142}
88cb1b4d 143if( !isset($day) || $day <= 0){
d61a01d4 144 $day = date( 'd' );
145}
146
147$todayis = date( 'mdY' );
148$calself=basename($PHP_SELF);
149
150displayPageHeader($color, 'None');
151calendar_header();
152readcalendardata();
153startcalendar();
154drawmonthview();
155endcalendar();
156
157?>
7c67a5e8 158</body></html>