From a564b9e3f94dcd52acd4133c84de9cac3da3cab6 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sat, 17 Jun 2017 20:23:12 +0000 Subject: [PATCH] Add ability to control the display of the "Check Spelling" button. Allows administrators to offer this plugin but keep it out of the way for users who do not want it. Put sqspell_show_button=0 in default preferences if it should be hidden by default. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14686 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- .../modules/change_main_options.mod | 55 +++++++++++++++++++ .../squirrelspell/modules/options_main.mod | 31 ++++++++++- plugins/squirrelspell/sqspell_functions.php | 6 +- 3 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 plugins/squirrelspell/modules/change_main_options.mod diff --git a/plugins/squirrelspell/modules/change_main_options.mod b/plugins/squirrelspell/modules/change_main_options.mod new file mode 100644 index 00000000..204133e3 --- /dev/null +++ b/plugins/squirrelspell/modules/change_main_options.mod @@ -0,0 +1,55 @@ + + * @version $Id: lang_change.mod 14642 2017-01-27 20:31:33Z pdontthink $ + * @package plugins + * @subpackage squirrelspell + */ + +if (!sqgetGlobalVar('smtoken',$submitted_token, SQ_POST)) { + $submitted_token = ''; +} +sm_validate_security_token($submitted_token, -1, TRUE); + +$main_options_changed_message = '

'; + +if (sqgetGlobalVar('sqspell_show_button', $sqspell_show_button, SQ_POST) + && !empty($sqspell_show_button)) +{ + $sqspell_show_button = 1; + $main_options_changed_message .= sprintf(_("Settings changed: Set to show \"%s\" button"), _("Check Spelling")); +} +else +{ + $sqspell_show_button = 0; + $main_options_changed_message .= sprintf(_("Settings changed: Set to hide \"%s\" button"), _("Check Spelling")); +} + +$main_options_changed_message .= '

'; + +setPref($data_dir, $username, 'sqspell_show_button', $sqspell_show_button); + +// so far the only thing this file does is change a checkbox, +// so for now we can skip the confirmation page and just reload +// the changed main options page (with a simple confirmation message) +// +require(SM_PATH . 'plugins/squirrelspell/modules/options_main.mod'); + +/** + * For Emacs weenies: + * Local variables: + * mode: php + * End: + * vim: syntax=php + */ + diff --git a/plugins/squirrelspell/modules/options_main.mod b/plugins/squirrelspell/modules/options_main.mod index 82d43f18..e84c842c 100644 --- a/plugins/squirrelspell/modules/options_main.mod +++ b/plugins/squirrelspell/modules/options_main.mod @@ -15,8 +15,14 @@ * @subpackage squirrelspell */ -global $SQSPELL_APP; -$msg = '

' +global $SQSPELL_APP, $main_options_changed_message; + +if (!empty($main_options_changed_message)) + $msg = $main_options_changed_message; +else + $msg = ''; + +$msg .= '

' . _("Please choose which options you wish to set up:") . '

' . '\n"; + + + +// add checkbox to enable/disable the spellcheck button on compose screen +// +$sqspell_show_button = getPref($data_dir, $username, 'sqspell_show_button', 1); +$msg .= '
' + . '' + . '' + . '

' + . '\n"; +$msg .= "

"; + + sqspell_makePage( _("SquirrelSpell Options Menu"), null, $msg); /** diff --git a/plugins/squirrelspell/sqspell_functions.php b/plugins/squirrelspell/sqspell_functions.php index dfb14986..f64f9e7d 100644 --- a/plugins/squirrelspell/sqspell_functions.php +++ b/plugins/squirrelspell/sqspell_functions.php @@ -57,11 +57,15 @@ function squirrelspell_optpage_block_function() { * @return void */ function squirrelspell_setup_function() { + + global $data_dir, $username; + $sqspell_show_button = getPref($data_dir, $username, 'sqspell_show_button', 1); + /** * Check if this browser is capable of displaying SquirrelSpell * correctly. */ - if (checkForJavascript()) { + if ($sqspell_show_button && checkForJavascript()) { global $oTemplate, $base_uri, $nbsp; -- 2.25.1