Commit c1fda6fe authored by Richard Mansfield's avatar Richard Mansfield

Add support in User for theme preference

Part of bug #793308

If a user has the 'theme' property set in their account preferences,
this is used instead of the site or institution's theme.

The LiveUser::reset_institutions() function, which recalculates the
institution theme, is now called in place of LiveUser::update_theme()
whenever a user's institutions have changed.  reset_institutions() now
calls update_theme() if the user is a LiveUser.

Change-Id: I75b36da85a5aa249c3098078b8588b8a20ac9b48
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent a9e7ef47
......@@ -664,7 +664,7 @@ function siteoptions_submit(Pieform $form, $values) {
if ($oldtheme != $values['theme']) {
global $USER;
$message .= ' ' . get_string('usersseenewthemeonlogin', 'admin');
$USER->update_theme();
$USER->reset_institutions();
}
$form->reply(PIEFORM_OK, array('message' => $message, 'goto' => '/admin/site/options.php'));
}
......
......@@ -805,7 +805,7 @@ function institution_submit(Pieform $form, $values) {
if ($changedtheme || $values['theme'] == 'custom') {
$message .= ' ' . get_string('usersseenewthemeonlogin', 'admin');
}
$USER->update_theme();
$USER->reset_institutions();
}
$SESSION->add_ok_msg($message);
$nexturl = '/admin/users/institutions.php';
......
......@@ -879,6 +879,9 @@ class User {
}
public function get_themedata() {
if ($preftheme = $this->get_account_preference('theme')) {
return (object) array('basename' => $preftheme);
}
return $this->institutiontheme;
}
......@@ -1439,18 +1442,17 @@ class LiveUser extends User {
}
public function update_theme() {
$this->reset_institutions(true);
$this->commit();
}
public function reset_institutions($nocachecss=false) {
global $THEME;
parent::reset_institutions($nocachecss);
if (!defined('INSTALLER')) {
$THEME = new Theme($this);
}
}
public function reset_institutions($nocachecss=false) {
parent::reset_institutions($nocachecss);
$this->update_theme();
}
private function store_sessionid() {
$sessionid = $this->get('sessionid');
delete_records('usr_session', 'session', $sessionid);
......
......@@ -209,6 +209,7 @@ function expected_account_preferences() {
'multipleblogs' => 0,
'showhomeinfo' => 1,
'mobileuploadtoken' => '',
'theme' => '',
);
}
......
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