Commit adcddb41 authored by Robert Lyon's avatar Robert Lyon

Bug 1514799: Ignoring theme check for new institutions

Stopping 'The theme "" is missing' message

behatnotneeded - only an info alert when not in production mode

Change-Id: Iacff81b2fd3d6ed264ca608ab00d3dcbf325231b
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 7dd962f2
......@@ -259,7 +259,7 @@ if ($institution || $add) {
$themeoptions = get_institution_themes($institution);
$themeoptions['sitedefault'] = '- ' . get_string('sitedefault', 'admin') . ' (' . $themeoptions[get_config('theme')] . ') -';
uksort($themeoptions, 'theme_sort');
if (validate_theme($data->theme, $institution) === false) {
if (validate_theme($data->theme, $institution, $add) === false) {
$data->theme = 'sitedefault';
}
$showonlineusersoptions = array('0' => get_string('none'), '1' => get_string('institutiononly', 'admin'), '2' => get_string('all', 'admin'));
......
......@@ -797,11 +797,18 @@ function get_all_theme_objects() {
*
* @param $theme string Name of theme
* @param $institution string Name of Institution
* @param $new boolean If we are validating the theme for something newly created
*
* @return bool True if theme exists
*/
function validate_theme($theme, $institution = null) {
function validate_theme($theme, $institution = null, $new = false) {
global $SESSION;
// Null theme means the institution is using the site default.
if ($theme == null && ($institution || $new)) {
return true;
}
if ($institution) {
$themeoptions = get_institution_themes($institution);
}
......@@ -809,14 +816,19 @@ function validate_theme($theme, $institution = null) {
$themeoptions = get_all_themes();
}
if (!array_key_exists($theme, $themeoptions)) {
if ($institution) {
set_config_institution($institution, 'theme', null);
if ($new) {
return false;
}
else {
set_config('theme', 'default');
if ($institution) {
set_config_institution($institution, 'theme', null);
}
else {
set_config('theme', 'default');
}
$SESSION->add_info_msg(get_string('thememissing', 'admin', $theme));
return false;
}
$SESSION->add_info_msg(get_string('thememissing', 'admin', $theme));
return false;
}
return true;
}
......
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