Commit 4de78659 authored by Antonella De Chiara's avatar Antonella De Chiara Committed by Robert Lyon

Bug 1698242: Get current instittuion via usr_account_preference theme value

behatnotneeded

Change-Id: Ie14a090eaacbdabf621d366109c5082107eba50a
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent dc0c96ae
......@@ -1108,3 +1108,26 @@ function plugin_institution_prefs_submit(Pieform $form, $values, Institution $in
call_static_method(generate_class_name($i->plugintype, $i->name), 'institutionprefs_submit', $form, $values, $institution);
}
}
/**
* Get current institution by theme.
* If the user account theme is set use that otherwise use
* the first institution the user belongs to.
*
* @return $string Name of institution
*/
function get_institution_by_current_theme() {
global $USER;
$usrtheme = $USER->get_account_preference('theme');
if ($usrtheme) {
$list = (explode('/', $usrtheme));
if (count($list) > 1 && !empty($list[1])) {
return $list[1];
}
}
$institutions = $USER->institutions;
if (!empty($institutions)) {
return key(array_slice($institutions, 0, 1));
}
return 'mahara';
}
......@@ -3743,7 +3743,7 @@ function progressbar_sideblock($preview=false) {
// Set user's first institution in case that institution isn't
// set yet or user is not member of currently set institution.
if (!$institution || !array_key_exists($institution, $institutions)) {
$institution = key(array_slice($institutions, 0, 1));
$institution = get_institution_by_current_theme();
}
}
else {
......
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