Commit 3bf76544 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Update user theme whenever a custom theme is submitted (bug #814354)



An institutional admin modifying configurable theme colours doesn't
immediately see the new colours unless they are also changing the
theme dropdown.

This change ensures the user's theme is reset whenever the institution
settings form is submitted with a custom theme.

Change-Id: I3e39cf2de182fc6fa1cba10f4063412025f363ef
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 85122b03
......@@ -745,10 +745,13 @@ function institution_submit(Pieform $form, $values) {
}
else {
$message = get_string('institutionupdatedsuccessfully', 'admin');
if (isset($values['theme']) && $oldinstitution->theme != $values['theme']
&& (!empty($oldinstitution->theme) || $values['theme'] != 'sitedefault')) {
if (isset($values['theme'])) {
$changedtheme = $oldinstitution->theme != $values['theme']
&& (!empty($oldinstitution->theme) || $values['theme'] != 'sitedefault');
if ($changedtheme || $values['theme'] == 'custom') {
$message .= ' ' . get_string('usersseenewthemeonlogin', 'admin');
}
$USER->update_theme();
$message .= ' ' . get_string('usersseenewthemeonlogin', 'admin');
}
$SESSION->add_ok_msg($message);
$nexturl = '/admin/users/institutions.php';
......
......@@ -817,7 +817,7 @@ class User {
$institution->addRequestFromUser($this, $studentid);
}
public function reset_institutions() {
public function reset_institutions($nocachecss=false) {
$institutions = load_user_institutions($this->id);
$admininstitutions = array();
$staffinstitutions = array();
......@@ -848,7 +848,11 @@ class User {
$this->theme = $institutions[$themeinstitution]->theme;
$this->headerlogo = $institutions[$themeinstitution]->logo;
if ($institutions[$themeinstitution]->style) {
$stylesheets[] = get_config('wwwroot') . 'style.php?id=' . $institutions[$themeinstitution]->style;
$stylesheet = get_config('wwwroot') . 'style.php?id=' . $institutions[$themeinstitution]->style;
if ($nocachecss) {
$stylesheet .= '&time=' . time();
}
$stylesheets[] = $stylesheet;
}
}
$this->stylesheets = $stylesheets;
......@@ -1345,13 +1349,13 @@ class LiveUser extends User {
}
public function update_theme() {
$this->reset_institutions();
$this->reset_institutions(true);
$this->commit();
}
public function reset_institutions() {
public function reset_institutions($nocachecss=false) {
global $THEME;
parent::reset_institutions();
parent::reset_institutions($nocachecss);
if (!defined('INSTALLER')) {
$THEME = new Theme($this);
}
......
Supports Markdown
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