Commit 6c757ae3 authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1501078: Allow the setting of 'no theme'



In user account settings page

behatnotneeded

Change-Id: I9eb8f345054ece362635cf93f6455a0dc55dbe63
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 6dadf5d5
...@@ -239,6 +239,10 @@ function accountprefs_submit(Pieform $form, $values) { ...@@ -239,6 +239,10 @@ function accountprefs_submit(Pieform $form, $values) {
} }
} }
if ($values['theme'] == 'sitedefault') {
$USER->set_account_preference('theme', '');
}
$returndata = array(); $returndata = array();
if (isset($values['username']) && $values['username'] != $USER->get('username')) { if (isset($values['username']) && $values['username'] != $USER->get('username')) {
$USER->username = $values['username']; $USER->username = $values['username'];
......
...@@ -927,10 +927,14 @@ class User { ...@@ -927,10 +927,14 @@ class User {
else if (!empty($list[0]) && get_config('sitethemeprefs')) { else if (!empty($list[0]) && get_config('sitethemeprefs')) {
return (object) array('basename' => $list[0]); return (object) array('basename' => $list[0]);
} }
// Or the current preferred theme is not available
// The system will pick one
return $this->institutiontheme;
}
if ($this->institutiontheme) {
// No theme set so use 'sitedefault'
$this->institutiontheme->altname = 'sitedefault';
} }
// The current user has not picked a preferred theme yet
// or his current preferred theme is not available for him
// The system will pick one for him
return $this->institutiontheme; return $this->institutiontheme;
} }
......
...@@ -361,7 +361,7 @@ $string['access'] = 'Access'; ...@@ -361,7 +361,7 @@ $string['access'] = 'Access';
$string['noaccesstoview'] = 'You do not have permission to access this page.'; $string['noaccesstoview'] = 'You do not have permission to access this page.';
$string['changeviewtheme'] = 'The theme you have chosen for this page is no longer available to you. Please select a different theme.'; $string['changeviewtheme'] = 'The theme you have chosen for this page is no longer available to you. Please select a different theme.';
$string['nothemeselected'] = 'No theme selected'; $string['nothemeselected1'] = 'Use institution theme';
// Templates // Templates
$string['Template'] = 'Template'; $string['Template'] = 'Template';
......
...@@ -724,7 +724,7 @@ function get_user_accessible_themes() { ...@@ -724,7 +724,7 @@ function get_user_accessible_themes() {
} }
} }
$themes = array_merge(array('sitedefault' => get_string('nothemeselected', 'view')), $themes); $themes = array_merge(array('sitedefault' => get_string('nothemeselected1', 'view')), $themes);
unset($themes['custom']); unset($themes['custom']);
return $themes; return $themes;
......
...@@ -290,11 +290,8 @@ function general_account_prefs_form_elements($prefs) { ...@@ -290,11 +290,8 @@ function general_account_prefs_form_elements($prefs) {
// Get all available standard site themes // Get all available standard site themes
if (get_config('sitethemeprefs') && !in_admin_section()) { if (get_config('sitethemeprefs') && !in_admin_section()) {
// get_user_accessible_themes() returns 'sitedefault' to mean fall back to the site or // get_user_accessible_themes() returns 'sitedefault' to mean fall back to the site or
// institution theme. This won't work for account prefs, where 'sitedefault' is just // institution theme. On save it sets user_account_preference to '' to allow the use of higher up theme.
// a theme that doesn't exist. So change the 'sitedefault' key to '', and the empty
// preference will be interpreted as "No theme selected".
$sitethemes = array_reverse(get_user_accessible_themes()); $sitethemes = array_reverse(get_user_accessible_themes());
unset($sitethemes['sitedefault']);
$sitethemes = array_reverse($sitethemes); $sitethemes = array_reverse($sitethemes);
} }
// Get all user's institution themes // Get all user's institution themes
...@@ -313,7 +310,7 @@ function general_account_prefs_form_elements($prefs) { ...@@ -313,7 +310,7 @@ function general_account_prefs_form_elements($prefs) {
$themes = array_merge($sitethemes, $institutionthemes); $themes = array_merge($sitethemes, $institutionthemes);
natcasesort($themes); natcasesort($themes);
$currenttheme = $USER->get_themedata(); $currenttheme = $USER->get_themedata();
if (!isset($currenttheme->basename)) { if (!isset($currenttheme->basename) || (isset($currenttheme->altname) && $currenttheme->altname == 'sitedefault')) {
$defaulttheme = 'sitedefault'; $defaulttheme = 'sitedefault';
} }
else { 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