mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 18:06:51 +02:00
MDL-43497 Language: Allow course language to be overridden
This commit is contained in:
parent
76e4de31cc
commit
c484af5aa6
7 changed files with 70 additions and 63 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