add fixme
[squirrelmail.git] / functions / db_prefs.php
index 9756fc88195dfde3e5519f104033824b9b322191..71422f1345587e04353774889f6efdb096091d7e 100644 (file)
@@ -164,6 +164,27 @@ class dbPrefs {
 
 
 
+    /**
+     * initialize the default preferences array.
+     *
+     */
+    function dbPrefs() {
+        // Try and read the default preferences file.
+        $default_pref = SM_PATH . 'config/default_pref';
+        if (@file_exists($default_pref)) {
+            if ($file = @fopen($default_pref, 'r')) {
+                while (!feof($file)) {
+                    $pref = fgets($file, 1024);
+                    $i = strpos($pref, '=');
+                    if ($i > 0) {
+                        $this->default[trim(substr($pref, 0, $i))] = trim(substr($pref, $i + 1));
+                    }
+                }
+                fclose($file);
+            }
+        }
+    }
+
     /**
      * initialize DB connection object
      *
@@ -257,17 +278,27 @@ class dbPrefs {
     function getKey($user, $key, $default = '') {
         global $prefs_cache;
 
-        cachePrefValues($user);
+        $temp = array(&$user, &$key);
+        $result = do_hook('get_pref_override', $temp);
+        if (is_null($result)) {
+            cachePrefValues($user);
 
-        if (isset($prefs_cache[$key])) {
-            return $prefs_cache[$key];
-        } else {
-            if (isset($this->default[$key])) {
-                return $this->default[$key];
+            if (isset($prefs_cache[$key])) {
+                $result = $prefs_cache[$key];
             } else {
-                return $default;
+//FIXME: is there a justification for having two prefs hooks so close?  who uses them?
+                $temp = array(&$user, &$key);
+                $result = do_hook('get_pref', $temp);
+                if (is_null($result)) {
+                    if (isset($this->default[$key])) {
+                        $result = $this->default[$key];
+                    } else {
+                        $result = $default;
+                    }
+                }
             }
         }
+        return $result;
     }
 
     /**