From 2b2967d43e37c24844f66ecf0a654e748c92daa7 Mon Sep 17 00:00:00 2001 From: jangliss Date: Sat, 8 Mar 2003 04:59:19 +0000 Subject: [PATCH] I'd like my settings to stay on login... we need a better solution :) Reverting file_prefs.php to previous version until proper fix is discovered for PHP 4.3.1 dropping settings. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4620 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/file_prefs.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/functions/file_prefs.php b/functions/file_prefs.php index 1cde4c88..79852012 100644 --- a/functions/file_prefs.php +++ b/functions/file_prefs.php @@ -18,7 +18,7 @@ function cachePrefValues($data_dir, $username) { global $prefs_are_cached, $prefs_cache; if ( isset($prefs_are_cached) && $prefs_are_cached) { - return $prefs_cache; + return; } sqsession_unregister('prefs_cache'); @@ -79,7 +79,6 @@ function cachePrefValues($data_dir, $username) { sqsession_register($prefs_cache, 'prefs_cache'); sqsession_register($prefs_are_cached, 'prefs_are_cached'); - return $prefs_cache; } /** @@ -90,7 +89,7 @@ function getPref($data_dir, $username, $string, $default = '') { $result = do_hook_function('get_pref_override',array($username,$string)); if (!$result) { - $prefs_cache = cachePrefValues($data_dir, $username); + cachePrefValues($data_dir, $username); if (isset($prefs_cache[$string])) { $result = $prefs_cache[$string]; } else { @@ -106,16 +105,11 @@ function getPref($data_dir, $username, $string, $default = '') { /** * Save the preferences for this user. */ -function savePrefValues($data_dir, $username, $prefs_cache) { +function savePrefValues($data_dir, $username) { + global $prefs_cache; $filename = getHashedFile($username, $data_dir, "$username.pref"); - if (!is_array($prefs_cache) || count($prefs_cache) == 0) { - include_once(SM_PATH . 'functions/display_messages.php'); - logout_error( _("Houston we have a problem, the preference cache is lost!!!.")); - exit; - } - /* Open the file for writing, or else display an error to the user. */ if(!$file = @fopen($filename.'.tmp', 'w')) { @@ -144,11 +138,13 @@ function savePrefValues($data_dir, $username, $prefs_cache) { function removePref($data_dir, $username, $string) { global $prefs_cache; + cachePrefValues($data_dir, $username); + if (isset($prefs_cache[$string])) { unset($prefs_cache[$string]); } - savePrefValues($data_dir, $username,$prefs_cache); + savePrefValues($data_dir, $username); } /** @@ -157,16 +153,18 @@ function removePref($data_dir, $username, $string) { function setPref($data_dir, $username, $string, $value) { global $prefs_cache; + cachePrefValues($data_dir, $username); if (isset($prefs_cache[$string]) && ($prefs_cache[$string] == $value)) { return; } if ($value === '') { - unset($prefs_cache[$string]); - } else { - $prefs_cache[$string] = $value; + removePref($data_dir, $username, $string); + return; } - savePrefValues($data_dir, $username, $prefs_cache); + + $prefs_cache[$string] = $value; + savePrefValues($data_dir, $username); } /** -- 2.25.1