Revert changes in revision 14302. Revision 14302 should only have changed functions...
[squirrelmail.git] / plugins / calendar / calendar.php
index b87d694336df2c0041598a35d9966d42090cc898..2563be57d5a396aa8b5f1293be9e9a51c5f8e03a 100644 (file)
@@ -1,58 +1,41 @@
 <?php
 
 /**
- * calendar.php
- *
- * Copyright (c) 2002-2005 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
- * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
- *
  * Displays the main calendar page (month view).
  *
- * $Id$
+ * @copyright 2002-2012 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
  * @package plugins
  * @subpackage calendar
  */
 
 /**
-*/
-define('SM_PATH','../../');
-
-/* Calender plugin required files. */
-require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
-require_once(SM_PATH . 'plugins/calendar/functions.php');
-
-/* SquirrelMail required files. */
-require_once(SM_PATH . 'include/validate.php');
-require_once(SM_PATH . 'functions/strings.php');
-require_once(SM_PATH . 'functions/date.php');
-require_once(SM_PATH . 'config/config.php');
-require_once(SM_PATH . 'functions/page_header.php');
-require_once(SM_PATH . 'include/load_prefs.php');
-require_once(SM_PATH . 'functions/html.php');
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
 
-/* get globals */
+/* load date_intl() */
+include_once(SM_PATH . 'functions/date.php');
 
-// undo rg = on effects
-if (isset($month)) unset($month);
-if (isset($year))  unset($year);
+/* Calendar plugin required files. */
+include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
+include_once(SM_PATH . 'plugins/calendar/functions.php');
 
-if (isset($_GET['month']) && is_numeric($_GET['month'])) {
-    $month = $_GET['month'];
-}
-if (isset($_GET['year']) && is_numeric($_GET['year'])) {
-    $year = $_GET['year'];
-}
-if (isset($_POST['year']) && is_numeric($_POST['year'])) {
-    $year = $_POST['year'];
+/* get globals */
+if (! sqgetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
+    unset($month);
 }
-if (isset($_POST['month']) && is_numeric($_POST['month'])) {
-    $month = $_POST['month'];
+if (! sqgetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
+    unset($year);
 }
 /* got 'em */
 
-//display upper part of month calendar view
+/**
+ * display upper part of month calendar view
+ * @return void
+ * @access private
+ */
 function startcalendar() {
     global $year, $month, $color;
 
@@ -98,7 +81,11 @@ function startcalendar() {
            '', $color[0] ) ."\n";
 }
 
-//main logic for month view of calendar
+/**
+ * main logic for month view of calendar
+ * @return void
+ * @access private
+ */
 function drawmonthview() {
     global $year, $month, $color, $calendardata, $todayis;
 
@@ -125,8 +112,13 @@ function drawmonthview() {
                 $i=0;
                 while ($calfoo = each($calendardata[$cdate])) {
                     $calbar = $calendardata[$cdate][$calfoo['key']];
-                    $title = '['. $calfoo['key']. '] ' .$calbar['message'];
-                    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";
+                    // FIXME: how to display multiline task
+                    $title = '['. $calfoo['key']. '] ' .
+                        str_replace(array("\r","\n"),array(' ',' '),htmlspecialchars($calbar['message']));
+                    // FIXME: link to nowhere
+                    echo "<a href=\"#\" style=\"text-decoration:none; color: "
+                        .($calbar['priority']==1 ? $color[1] : $color[6])
+                        ."\" title=\"$title\">".htmlspecialchars($calbar['title'])."</a><br />\n";
                     $i=$i+1;
                     if($i==2){
                         break;
@@ -140,9 +132,13 @@ function drawmonthview() {
     }
 }
 
-//end of monthly view and form to jump to any month and year
+/**
+ * end of monthly view and form to jump to any month and year
+ * @return void
+ * @access private
+ */
 function endcalendar() {
-    global $year, $month, $day, $color;
+    global $year, $month;
 
     echo html_tag( 'tr' ) ."\n" .
            html_tag( 'td', '', 'left', '', 'colspan="7"' ) ."\n" .
@@ -173,7 +169,7 @@ if( !isset($day) || $day <= 0){
 $todayis = date( 'mdY' );
 $calself=basename($PHP_SELF);
 
-displayPageHeader($color, 'None');
+displayPageHeader($color);
 calendar_header();
 readcalendardata();
 startcalendar();
@@ -181,4 +177,4 @@ drawmonthview();
 endcalendar();
 
 ?>
-</body></html>
\ No newline at end of file
+</body></html>