fix for display of empty date
[squirrelmail.git] / functions / options.php
index 057cb8c86b00801ca1981ec31bb911b506e5935b..67c3c132ac378c7562aaf716aa5043fb693b4100 100644 (file)
 /* Define constants for the various option types. */
 define('SMOPT_TYPE_STRING', 0);
 define('SMOPT_TYPE_STRLIST', 1);
-define('SMOPT_TYPE_textarea', 2);
+define('SMOPT_TYPE_TEXTAREA', 2);
 define('SMOPT_TYPE_INTEGER', 3);
 define('SMOPT_TYPE_FLOAT', 4);
 define('SMOPT_TYPE_BOOLEAN', 5);
-define('SMOPT_TYPE_hidden', 6);
+define('SMOPT_TYPE_HIDDEN', 6);
 define('SMOPT_TYPE_COMMENT', 7);
 
 /* Define constants for the options refresh levels. */
@@ -90,14 +90,14 @@ class SquirrelOption {
         }
 
         /* Check for a new value. */
-        if (isset($GLOBALS["new_$name"])) {
-            $this->new_value = $GLOBALS["new_$name"];
+        if (isset($_POST["new_$name"])) {
+            $this->new_value = $_POST["new_$name"];
         } else {
             $this->new_value = '';
         }
 
         /* Set the default save function. */
-        if (($type != SMOPT_TYPE_hidden) && ($type != SMOPT_TYPE_COMMENT)) {
+        if (($type != SMOPT_TYPE_HIDDEN) && ($type != SMOPT_TYPE_COMMENT)) {
             $this->save_function = SMOPT_SAVE_DEFAULT;
         } else {
             $this->save_function = SMOPT_SAVE_NOOP;
@@ -145,7 +145,7 @@ class SquirrelOption {
             case SMOPT_TYPE_STRLIST:
                 $result = $this->createWidget_StrList();
                 break;
-            case SMOPT_TYPE_textarea:
+            case SMOPT_TYPE_TEXTAREA:
                 $result = $this->createWidget_TextArea();
                 break;
             case SMOPT_TYPE_INTEGER:
@@ -157,7 +157,7 @@ class SquirrelOption {
             case SMOPT_TYPE_BOOLEAN:
                 $result = $this->createWidget_Boolean();
                 break;
-            case SMOPT_TYPE_hidden:
+            case SMOPT_TYPE_HIDDEN:
                 $result = $this->createWidget_Hidden();
                 break;
             case SMOPT_TYPE_COMMENT:
@@ -289,16 +289,18 @@ class SquirrelOption {
     }
 
     function changed() {
-        return ($this->value !== $this->new_value);
+        return ($this->value != $this->new_value);
     }
 }
 
 function save_option($option) {
-    global $data_dir, $username;
-    setPref($data_dir, $username, $option->name, $option->new_value);
+    if ( (float)substr(PHP_VERSION,0,3) < 4.1 ) {
+        global $_SESSION;
+    }
+    global $data_dir;
+    $username = $_SESSION['username'];
 
-    /* I do not know if this next line does any good. */
-    $GLOBALS[$option->name] = $option->new_value;
+    setPref($data_dir, $username, $option->name, $option->new_value);
 }
 
 function save_option_noop($option) {
@@ -396,7 +398,7 @@ function print_option_groups($option_groups) {
 
         /* Print each option in this option group. */
         foreach ($next_optgrp['options'] as $option) {
-            if ($option->type != SMOPT_TYPE_hidden) {
+            if ($option->type != SMOPT_TYPE_HIDDEN) {
                 echo html_tag( 'tr', "\n".
                            html_tag( 'td', $option->caption . ':', 'right' ,'', 'valign="middle"' ) .
                            html_tag( 'td', $option->createHTMLWidget(), 'left' )