Commit 5ea0566c authored by Richard Mansfield's avatar Richard Mansfield

Make language selector work on any logged-out page

Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent a87d8a2f
......@@ -482,6 +482,10 @@ function auth_setup () {
// Check if the page is public or the site is configured to be public.
if (defined('PUBLIC') && !isset($_GET['login'])) {
if ($lang = param_alphanumext('lang', null)) {
$SESSION->set('lang', $lang);
current_language($lang);
}
return;
}
......
......@@ -36,11 +36,6 @@ require('init.php');
if (!$USER->is_logged_in()) {
define('TITLE', get_string('home'));
$pagename = 'loggedouthome';
$lang = param_alphanumext('lang', null);
if (!empty($lang)) {
$SESSION->set('lang', $lang);
redirect();
}
}
else {
define('TITLE', get_string('dashboard', 'view'));
......
......@@ -916,14 +916,20 @@ function print_object($mixed) {
* This function returns the current
* language to use, either for a given user
* or sitewide, or the default
*
* param @string $reset If passed, reset the current language to this
*
* @return string
*/
function current_language() {
function current_language($reset=null) {
global $USER, $CFG, $SESSION;
static $lang;
if (!empty($reset)) {
$lang = $reset; // Set the language for this request
}
if (!empty($lang)) {
return $lang;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment