From 08174740fbdc5d0a86d67c3736d4c78dced11331 Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Thu, 6 Mar 2014 08:53:54 -0500 Subject: [PATCH] MDL-40699 Language - Add option to Override Moodle's default behaviour to reset the UI language on logout This change adds an option to the Site Admin > Langauge > Language Settings page which can prevent Moodle from changing language when users log out. Affected files: lang/en/admin.php admin/settings/language.php login/logout.php Signed-off-by: Michael Milette --- admin/settings/language.php | 25 ++++++++++++++++++------- lang/en/admin.php | 2 ++ login/logout.php | 6 ++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/admin/settings/language.php b/admin/settings/language.php index 14770828790..207e89b9585 100644 --- a/admin/settings/language.php +++ b/admin/settings/language.php @@ -6,14 +6,25 @@ if ($hassiteconfig) { // "languageandlocation" settingpage $temp = new admin_settingpage('langsettings', new lang_string('languagesettings', 'admin')); - $temp->add(new admin_setting_configcheckbox('autolang', new lang_string('autolang', 'admin'), new lang_string('configautolang', 'admin'), 1)); - $temp->add(new admin_setting_configselect('lang', new lang_string('lang', 'admin'), new lang_string('configlang', 'admin'), current_language(), get_string_manager()->get_list_of_translations())); // $CFG->lang might be set in installer already, default en is in setup.php - $temp->add(new admin_setting_configcheckbox('langmenu', new lang_string('langmenu', 'admin'), new lang_string('configlangmenu', 'admin'), 1)); + $temp->add(new admin_setting_configcheckbox('autolang', + new lang_string('autolang', 'admin'), new lang_string('configautolang', 'admin'), 1)); + $temp->add(new admin_setting_configselect('lang', new lang_string('lang', 'admin'), + new lang_string('configlang', 'admin'), current_language(), + get_string_manager()->get_list_of_translations())); + // The $CFG->lang variable might be set in installer already, default en is in setup.php. + $temp->add(new admin_setting_configcheckbox('keeplogoutlang', new lang_string('keeplogoutlang', 'admin'), + new lang_string('keeplogoutlang_desc', 'admin'), 1)); + $temp->add(new admin_setting_configcheckbox('langmenu', new lang_string('langmenu', 'admin'), + new lang_string('configlangmenu', 'admin'), 1)); $temp->add(new admin_setting_langlist()); - $temp->add(new admin_setting_configcheckbox('langcache', new lang_string('langcache', 'admin'), new lang_string('langcache_desc', 'admin'), 1)); - $temp->add(new admin_setting_configcheckbox('langstringcache', new lang_string('langstringcache', 'admin'), new lang_string('configlangstringcache', 'admin'), 1)); - $temp->add(new admin_setting_configtext('locale', new lang_string('localetext', 'admin'), new lang_string('configlocale', 'admin'), '', PARAM_FILE)); - $temp->add(new admin_setting_configselect('latinexcelexport', new lang_string('latinexcelexport', 'admin'), new lang_string('configlatinexcelexport', 'admin'), '0', array('0'=>'Unicode','1'=>'Latin'))); + $temp->add(new admin_setting_configcheckbox('langcache', new lang_string('langcache', 'admin'), + new lang_string('langcache_desc', 'admin'), 1)); + $temp->add(new admin_setting_configcheckbox('langstringcache', new lang_string('langstringcache', 'admin'), + new lang_string('configlangstringcache', 'admin'), 1)); + $temp->add(new admin_setting_configtext('locale', new lang_string('localetext', 'admin'), + new lang_string('configlocale', 'admin'), '', PARAM_FILE)); + $temp->add(new admin_setting_configselect('latinexcelexport', new lang_string('latinexcelexport', 'admin'), + new lang_string('configlatinexcelexport', 'admin'), '0', array('0' => 'Unicode', '1' => 'Latin'))); $ADMIN->add('language', $temp); diff --git a/lang/en/admin.php b/lang/en/admin.php index 86fa99f4f4b..ef39c899125 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -597,6 +597,8 @@ $string['iplookupinfo'] = 'By default Moodle uses the free online NetGeo (The In It is recommended to install local copy of free GeoLite City database from MaxMind.
IP address location is displayed on simple map or using Google Maps. Please note that you need to have a Google account and apply for free Google Maps API key to enable interactive maps.'; $string['iplookupmaxmindnote'] = 'This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com/.'; +$string['keeplogoutlang'] = 'Keep language on logout'; +$string['keeplogoutlang_desc'] = 'Enable this option to prevent the user interface language from reverting back to the site\'s default language when users log out.'; $string['keeptagnamecase'] = 'Keep tag name casing'; $string['lang'] = 'Default language'; $string['langcache'] = 'Cache language menu'; diff --git a/login/logout.php b/login/logout.php index 664b179aa95..b2c08d7d652 100644 --- a/login/logout.php +++ b/login/logout.php @@ -39,6 +39,12 @@ if ($login) { $redirect = $CFG->wwwroot.'/'; } +if (!empty($CFG->keeplogoutlang)) { + // Override Moodle's default behaviour to reset the UI language on logout. + $redirectlang = optional_param('lang', current_language(), PARAM_LANG); + $redirect = new moodle_url($redirect, array('lang' => $redirectlang)); +} + if (!isloggedin()) { // no confirmation, user has already logged out require_logout(); -- 2.43.0