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
-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 )
if ( $javascript_setting == SMPREF_JS_AUTODETECT )
- $js_pref = $js_autodetect_results;
+ $javascript_on = $js_autodetect_results;
- $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;
$sort_by_ref = getPref($data_dir, $username, 'sort_by_ref', 1);
/* Load the javascript settings. */
$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');
if ( checkForJavascript() )
{
$use_javascript_folder_list = getPref($data_dir, $username, 'use_javascript_folder_list');
* @return array all option information
*/
function load_optpage_data_display() {
* @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;
$compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
$optmode, $show_alternative_names, $available_languages, $use_icons;
'refresh' => SMOPT_REFRESH_ALL,
'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
SMPREF_JS_ON => _("Always"),
'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,
$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,
//'post_script' => $js_autodetect_script,
- 'save' => 'save_option_javascript_autodetect'
);
/*** Load the General Options into the array ***/
);
/*** Load the General Options into the array ***/
/* Assemble all this together and return it as our result. */
$result = array(
'grps' => $optgrps,
/* Assemble all this together and return it as our result. */
$result = array(
'grps' => $optgrps,
- 'vals' => $optvals,
- 'xtra' => $onLoadScript
* This function saves the javascript detection option.
*/
function save_option_javascript_autodetect($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);
$header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
"<!--\n".
" function squirrelmail_loginpage_onload() {\n".
$header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" .
"<!--\n".
" function squirrelmail_loginpage_onload() {\n".
- " document.forms[0].js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
" var textElements = 0;\n".
" for (i = 0; i < document.forms[0].elements.length; i++) {\n".
" if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
" var textElements = 0;\n".
" for (i = 0; i < document.forms[0].elements.length; i++) {\n".
" if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n".
displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload()\">" .
displayHtmlHeader( "$org_name - " . _("Login"), $header, FALSE );
echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" onLoad=\"squirrelmail_loginpage_onload()\">" .
- "\n" . '<form action="redirect.php" method="post">' . "\n";
+ "\n" . '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value=\'' . SMPREF_JS_ON .'\';">' . "\n";
$username_form_name = 'login_username';
$password_form_name = 'secretkey';
$username_form_name = 'login_username';
$password_form_name = 'secretkey';
'right', '', 'width="30%"' ) .
html_tag( 'td',
'<input type="password" name="' . $password_form_name . '" />' . "\n" .
'right', '', 'width="30%"' ) .
html_tag( 'td',
'<input type="password" name="' . $password_form_name . '" />' . "\n" .
- '<input type="hidden" name="js_autodetect_results" value="SMPREF_JS_OFF" />' . "\n" .
+ '<input type="hidden" name="js_autodetect_results" value="'.SMPREF_JS_OFF.'" />' . "\n" .
$rcptaddress .
'<input type="hidden" name="just_logged_in" value="1" />' . "\n",
'left', '', 'width="*"' )
$rcptaddress .
'<input type="hidden" name="just_logged_in" value="1" />' . "\n",
'left', '', 'width="*"' )