yet another db_prefs patch
[squirrelmail.git] / functions / db_prefs.php
index 0817458e9fbc38dcc06fd9334a0264638d7f4e76..7bc0800a6e956525d21fbc879c3a7e9c2e78e24c 100644 (file)
@@ -21,7 +21,7 @@
  *    prefkey    char  /  key
  *    prefval    blob
  *
- *   CREATE TABLE userprefs (user CHAR(32) NOT NULL DEFAULT '',
+ *   CREATE TABLE userprefs (user CHAR(128) NOT NULL DEFAULT '',
  *                           prefkey CHAR(64) NOT NULL DEFAULT '',
  *                           prefval BLOB NOT NULL DEFAULT '',
  *                           primary key (user,prefkey));
@@ -39,7 +39,7 @@ global $prefs_are_cached, $prefs_cache;
 if ( !session_is_registered('prefs_are_cached') ||
      !isset( $prefs_cache) ||
      !is_array( $prefs_cache) ||
-     substr( phpversion(), 0, 3 ) == '4.1 ) {
+     substr( phpversion(), 0, 3 ) == '4.1' ) {
     $prefs_are_cached = false;
     $prefs_cache = array();
 }
@@ -119,7 +119,11 @@ class dbPrefs {
         if (isset($prefs_cache[$key])) {
             return $prefs_cache[$key];
         } else {
-            return $default;
+            if (isset($this->default[$key])) {
+                return $this->default[$key];
+            } else {
+                return $default;
+            }
         }
     }
 
@@ -261,7 +265,7 @@ function removePref($data_dir, $username, $string) {
 function setPref($data_dir, $username, $string, $set_to) {
     global $prefs_cache;
 
-    if (isset($prefs_cache[$string]) && ($prefs_cache[$string] == $value)) {
+    if (isset($prefs_cache[$string]) && ($prefs_cache[$string] == $set_to)) {
         return;
     }