Added support for using Squirrelmail without frames
[squirrelmail.git] / functions / file_prefs.php
index d80ba43889bf942fecb81b6fe21b8e851c4ff3b2..b579bdd42f58cd84e7e9a5ec7402e0a36ed282eb 100644 (file)
@@ -9,9 +9,10 @@
  * This contains functions for manipulating user preferences in files
  *
  * $Id$
+ * @package squirrelmail
  */
 
-/* include this for error messages */
+/** include this for error messages */
 include_once(SM_PATH . 'functions/display_messages.php');
 
 /**
@@ -73,8 +74,8 @@ function cachePrefValues($data_dir, $username) {
                 $prefs_cache[$key] = $value;
             }
         }
-     }
-     fclose($file);
+    }
+    fclose($file);
 
     $prefs_are_cached = TRUE;
 
@@ -119,7 +120,7 @@ function savePrefValues($data_dir, $username) {
     }
     foreach ($prefs_cache as $Key => $Value) {
         if (isset($Value)) {
-            if ( ! @fwrite($file, $Key . '=' . $Value . "\n") ) {
+            if ( @fwrite($file, $Key . '=' . $Value . "\n") === FALSE ) {
                logout_error( sprintf( _("Preference file, %s, could not be written. Contact your system administrator to resolve this issue.") , $filename . '.tmp') );
                exit;
             }
@@ -131,7 +132,8 @@ function savePrefValues($data_dir, $username) {
         exit;
     }
     @unlink($filename . '.tmp');
-    chmod($filename, 0600);
+    @chmod($filename, 0600);
+    sqsession_register($prefs_cache , 'prefs_cache');
 }
 
 /**
@@ -181,7 +183,10 @@ function checkForPrefs($data_dir, $username, $filename = '') {
     /* Then, check if the file exists. */
     if (!@file_exists($filename) ) {
         /* First, check the $data_dir for the default preference file. */
-        $default_pref = $data_dir . '/default_pref';
+        if(substr($data_dir,-1) != '/') {
+            $data_dir .= '/';
+        }
+        $default_pref = $data_dir . 'default_pref';
 
         /* If it is not there, check the internal data directory. */
         if (!@file_exists($default_pref)) {
@@ -222,7 +227,7 @@ function setSig($data_dir, $username, $number, $value) {
         logout_error( sprintf( _("Signature file, %s, could not be opened. Contact your system administrator to resolve this issue."), $filename . '.tmp') );
         exit;
     }
-    if (! @fwrite($file, $value) ) {
+    if ( @fwrite($file, $value) === FALSE ) {
        logout_error( sprintf( _("Signature file, %s, could not be written. Contact your system administrator to resolve this issue.") , $filename . '.tmp'));
        exit;
     }
@@ -232,7 +237,7 @@ function setSig($data_dir, $username, $number, $value) {
        exit;
     }
     @unlink($filename . '.tmp');
-    chmod($filename, 0600);
+    @chmod($filename, 0600);
 
 }