mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
Merge branch 'mdl27_mdl-43497_allow_force_language_02' of https://github.com/brki/moodle
This commit is contained in:
commit
38c5e34c00
6 changed files with 69 additions and 62 deletions
|
@ -820,6 +820,21 @@ if (isset($_GET['lang']) and ($lang = optional_param('lang', '', PARAM_SAFEDIR))
|
|||
}
|
||||
unset($lang);
|
||||
|
||||
// PARAM_SAFEDIR used instead of PARAM_LANG because using PARAM_LANG results
|
||||
// in an empty string being returned when a non-existant language is specified,
|
||||
// which would make it necessary to log out to undo the forcelang setting.
|
||||
// With PARAM_SAFEDIR, it's possible to specify ?forcelang=none to drop the forcelang effect.
|
||||
if ($forcelang = optional_param('forcelang', '', PARAM_SAFEDIR)) {
|
||||
if (isloggedin()
|
||||
&& get_string_manager()->translation_exists($forcelang, false)
|
||||
&& has_capability('moodle/site:forcelanguage', context_system::instance())) {
|
||||
$SESSION->forcelang = $forcelang;
|
||||
} else if (isset($SESSION->forcelang)) {
|
||||
unset($SESSION->forcelang);
|
||||
}
|
||||
}
|
||||
unset($forcelang);
|
||||
|
||||
setup_lang_from_browser();
|
||||
|
||||
if (empty($CFG->lang)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue