MDL-43497 Language: Allow course language to be overridden

This commit is contained in:
Brian King 2013-12-24 14:00:49 +01:00
parent 76e4de31cc
commit c484af5aa6
7 changed files with 70 additions and 63 deletions

View file

@ -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)) {