** -> *
[squirrelmail.git] / functions / prefs.php
index 76704e93e5416be5c0dbaa604bca2be60cf61332..5ecf530f94476e64b9e831386f583201b8a36184 100644 (file)
@@ -1,15 +1,15 @@
 <?php
-   /**
-    **  prefs.php
-    **
-    **  This contains functions for manipulating user preferences
-    **
-    **  $Id$
-    **/
 
-   if (defined('prefs_php'))
-      return;
-   define('prefs_php', true);
+   /**
+    *   prefs.php
+    *
+    *   Copyright (c) 1999-2001 The Squirrelmail Development Team
+    *   Licensed under the GNU GPL. For full terms see the file COPYING.
+    *
+    *   This contains functions for manipulating user preferences
+    *
+    *   $Id$
+    */
 
    global $prefs_are_cached, $prefs_cache;
    if (!session_is_registered('prefs_are_cached')) {
    
    
    /** returns the value for $string **/
-   function getPref($data_dir, $username, $string) {
+   function getPref($data_dir, $username, $string, $default = '') {
       global $prefs_cache;
-      
+
       cachePrefValues($data_dir, $username);
-      
+
       if (isset($prefs_cache[$string]))
           return $prefs_cache[$string];
-      return '';
+      else
+        return $default;
    }
 
 
       global $prefs_cache;
       
       cachePrefValues($data_dir, $username);
+      if (isset($prefs_cache[$string]) && $prefs_cache[$string] == $set_to)
+         return;
+      if ($set_to === '') {
+         removePref($data_dir, $username, $string);
+        return;
+      }
       $prefs_cache[$string] = $set_to;
       savePrefValues($data_dir, $username);
    }