From: ebullient Date: Sun, 28 Mar 2004 22:47:11 +0000 (+0000) Subject: updates to make javascript actually behave correctly for real. X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=ae958cd393ee39fb805a2cc6937b9dff5af29867 updates to make javascript actually behave correctly for real. Autodetection is fixed, load of JS dependent items (like address book and search) will be set to false if javascript_on session var is false/0. javascript_on will ONLY be true if: javascript_setting = 1 (ALWAYS) javascript_setting = 2 (Autodetect, and test works) If you change your javascript settings, javascript_on will change immediately. We might actually want to DISABLE Always, and have it be either Never, or autodetect. Since Always might not always work.. :-P git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6918 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/prefs.php b/functions/prefs.php index dd97204b..1c8ae1e2 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -145,24 +145,27 @@ function computeHashDirs($username) { return ($hash_dirs); } -function checkForJavascript() +function checkForJavascript($reset = FALSE) { - global $data_dir, $username, $javascript_on; - if ( sqGetGlobalVar('javascript_on', $javascript_on) ) - return; + global $data_dir, $username, $javascript_on, $javascript_setting; - if ( !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results) ) - $js_autodetect_results = SMPREF_JS_OFF; + if ( !$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION) ) + return $javascript_on; + + if ( $reset || !isset($javascript_setting) ) + $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); - $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); + if ( !sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) && + !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results) ) + $js_autodetect_results = SMPREF_JS_OFF; if ( $javascript_setting == SMPREF_JS_AUTODETECT ) - $js_pref = $js_autodetect_results; + $javascript_on = $js_autodetect_results; else - $js_pref = $javascript_setting; + $javascript_on = $javascript_setting; - sqsession_register('javascript_on',$js_pref); - return $js_pref; + sqsession_register($javascript_on, 'javascript_on'); + return $javascript_on; } ?> diff --git a/include/load_prefs.php b/include/load_prefs.php index 69e2724b..49a74cc5 100644 --- a/include/load_prefs.php +++ b/include/load_prefs.php @@ -265,6 +265,7 @@ $internal_date_sort = getPref($data_dir, $username, 'internal_date_sort', SMPREF $sort_by_ref = getPref($data_dir, $username, 'sort_by_ref', 1); /* Load the javascript settings. */ +$javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); if ( checkForJavascript() ) { $use_javascript_folder_list = getPref($data_dir, $username, 'use_javascript_folder_list'); diff --git a/include/options/display.php b/include/options/display.php index 43ef12ad..366024fc 100644 --- a/include/options/display.php +++ b/include/options/display.php @@ -45,7 +45,7 @@ if ($use_icons) { * @return array all option information */ function load_optpage_data_display() { - global $theme, $language, $languages, $js_autodetect_results, + global $theme, $language, $languages, $js_autodetect_results, $javascript_setting, $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort, $optmode, $show_alternative_names, $available_languages, $use_icons; @@ -151,22 +151,17 @@ function load_optpage_data_display() { 'refresh' => SMOPT_REFRESH_ALL, 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"), SMPREF_JS_ON => _("Always"), - SMPREF_JS_OFF => _("Never")) + SMPREF_JS_OFF => _("Never")), + 'save' => 'save_option_javascript_autodetect', + 'script' => 'onclick="document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';"' ); - - if ($optmode != 'submit') - $onLoadScript = 'document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\''; - else - $onLoadScript = ''; - $optvals[SMOPT_GRP_GENERAL][] = array( 'name' => 'js_autodetect_results', 'caption' => '', 'type' => SMOPT_TYPE_HIDDEN, - 'refresh' => SMOPT_REFRESH_NONE, + 'refresh' => SMOPT_REFRESH_NONE //'post_script' => $js_autodetect_script, - 'save' => 'save_option_javascript_autodetect' ); /*** Load the General Options into the array ***/ @@ -438,8 +433,7 @@ function load_optpage_data_display() { /* Assemble all this together and return it as our result. */ $result = array( 'grps' => $optgrps, - 'vals' => $optvals, - 'xtra' => $onLoadScript + 'vals' => $optvals ); return ($result); } @@ -476,10 +470,10 @@ function save_option_theme($option) { * This function saves the javascript detection option. */ function save_option_javascript_autodetect($option) { - global $data_dir, $username, $new_javascript_setting; + global $data_dir, $username; - setPref($data_dir, $username, 'javascript_setting', $new_javascript_setting); - checkForJavascript(); + save_option($option); + checkForJavascript(TRUE); } /** diff --git a/src/login.php b/src/login.php index 7b541aba..f124ccef 100644 --- a/src/login.php +++ b/src/login.php @@ -77,7 +77,6 @@ do_hook('login_cookie'); $header = "