Resolve confusing var names for preferences.
authorstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 18 Aug 2006 21:26:04 +0000 (21:26 +0000)
committerstevetruckstuff <stevetruckstuff@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 18 Aug 2006 21:26:04 +0000 (21:26 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11613 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/options.php

index 747d85e432993df951abd609b080be57a14b4fb0..a8236919370cd4a2290b9c126cf8b4919fb312a0 100644 (file)
@@ -175,8 +175,20 @@ class SquirrelOption {
         $this->script = '';
         $this->post_script = '';
 
         $this->script = '';
         $this->post_script = '';
 
-        /* Check for a current value. */
-        if (isset($GLOBALS[$name])) {
+        /**
+         * Check for a current value.  If the $GLOBALS[] value exists, we also
+         * need to make sure it is the same data type as the initial value to
+         * make sure we are looking at the correct preference.
+         */
+        $var_type = NULL;        
+        if (!empty($initial_value)) {
+            $var_type = gettype($initial_value);
+        } elseif (is_array($possible_values)) {
+            list($index, $x) = each ($possible_values);
+            $var_type = gettype($index);
+        }
+        
+        if (isset($GLOBALS[$name]) && (is_null($var_type) ? true : $var_type == gettype($GLOBALS[$name]))) {
             $this->value = $GLOBALS[$name];
         } else if (!empty($initial_value)) {
             $this->value = $initial_value;
             $this->value = $GLOBALS[$name];
         } else if (!empty($initial_value)) {
             $this->value = $initial_value;