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