From bf3abdc31867b0be2a7878793c6b524a8f04b51a Mon Sep 17 00:00:00 2001 From: pdontthink Date: Fri, 24 Aug 2007 02:29:20 +0000 Subject: [PATCH] Load prefs for all page loads, no matter if user is logged in. This fixes some login page issues and seems fine when user isn't logged in, but please report problems I may not have seen in my limited testing. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12593 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- include/init.php | 48 ++++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/include/init.php b/include/init.php index 28b9eb05..39e54371 100644 --- a/include/init.php +++ b/include/init.php @@ -292,6 +292,20 @@ if (! sqgetGlobalVar('squirrelmail_language',$squirrelmail_language,SQ_COOKIE)) $squirrelmail_language = ''; } + +/* load prefs system; even when user not logged in, should be OK to do this here */ +require(SM_PATH . 'functions/prefs.php'); + +$prefs_backend = do_hook('prefs_backend', $null); +if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) { + require(SM_PATH . $prefs_backend); +} elseif (isset($prefs_dsn) && !empty($prefs_dsn)) { + require(SM_PATH . 'functions/db_prefs.php'); +} else { + require(SM_PATH . 'functions/file_prefs.php'); +} + + /** * Do something special for some pages. This is based on the PAGE_NAME constand * set at the top of every page. @@ -331,22 +345,9 @@ switch (PAGE_NAME) { break; case 'redirect': - /** - * directory hashing functions are needed for all setups in case - * plugins use own pref files. - */ - require(SM_PATH . 'functions/prefs.php'); require(SM_PATH . 'functions/auth.php'); - /* hook loads custom prefs backend plugins */ - $prefs_backend = do_hook('prefs_backend', $null); - if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) { - require(SM_PATH . $prefs_backend); - } elseif (isset($prefs_dsn) && !empty($prefs_dsn)) { - require(SM_PATH . 'functions/db_prefs.php'); - } else { - require(SM_PATH . 'functions/file_prefs.php'); - } //nobreak; + case 'login': require(SM_PATH . 'functions/display_messages.php' ); require(SM_PATH . 'functions/page_header.php'); @@ -449,18 +450,6 @@ switch (PAGE_NAME) { $prefs_cache = false; //array(); } - /* see 'redirect' case */ - require(SM_PATH . 'functions/prefs.php'); - - $prefs_backend = do_hook('prefs_backend', $null); - if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) { - require(SM_PATH . $prefs_backend); - } elseif (isset($prefs_dsn) && !empty($prefs_dsn)) { - require(SM_PATH . 'functions/db_prefs.php'); - } else { - require(SM_PATH . 'functions/file_prefs.php'); - } - /** * initializing user settings */ @@ -599,12 +588,7 @@ function checkForJavascript($reset = FALSE) { return $javascript_on; $user_is_logged_in = FALSE; - if ( ( $reset || !isset($javascript_setting) ) - // getPref() not defined (nor is it meaningful) when user not - // logged in, but that begs the question if $javascript_on is - // not in the session in that case, where do we get it from? - && ( sqGetGlobalVar('user_is_logged_in', $user_is_logged_in, SQ_SESSION) - && $user_is_logged_in) ) + if ( $reset || !isset($javascript_setting) ) $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); if ( !sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) && -- 2.25.1