Add convenience function; keep track of multi-value widget types in one place
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 4 Mar 2008 08:44:14 +0000 (08:44 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 4 Mar 2008 08:44:14 +0000 (08:44 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12990 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/options.php

index 036e43c..f900140 100644 (file)
@@ -202,6 +202,14 @@ class SquirrelOption {
         }
     }
 
         }
     }
 
+    /** Convenience function that identifies which types of
+        widgets are stored as (serialized) array values. */
+    function is_multiple_valued() {
+        return ($this->type == SMOPT_TYPE_FLDRLIST_MULTI
+             || $this->type == SMOPT_TYPE_STRLIST_MULTI
+             || $this->type == SMOPT_TYPE_EDIT_LIST);
+    }
+
     /**
      * Set the value for this option.
      * @param mixed $value
     /**
      * Set the value for this option.
      * @param mixed $value
@@ -673,8 +681,7 @@ function save_option($option) {
     // Certain option types need to be serialized because
     // they are not scalar
     //
     // Certain option types need to be serialized because
     // they are not scalar
     //
-    } else if ($option->type == SMOPT_TYPE_FLDRLIST_MULTI
-            || $option->type == SMOPT_TYPE_STRLIST_MULTI)
+    } else if ($option->is_multiple_valued())
         setPref($data_dir, $username, $option->name, serialize($option->new_value));
 
     else
         setPref($data_dir, $username, $option->name, serialize($option->new_value));
 
     else