if ($reset and confirm_sesskey()) {
theme_reset_all_caches();
-} else if ($choose && $device && !$unsettheme && confirm_sesskey()) {
+} else if ($choose && $device && !theme_is_device_locked($device) && !$unsettheme && confirm_sesskey()) {
// Load the theme to make sure it is valid.
$theme = theme_config::load($choose);
+
// Get the config argument for the chosen device.
$themename = core_useragent::get_device_type_cfg_var_name($device);
set_config($themename, $theme->name);
echo $output->continue_button($CFG->wwwroot . '/theme/index.php');
echo $output->footer();
exit;
-} else if ($device && $unsettheme && confirm_sesskey() && ($device != 'default')) {
+} else if ($device && !theme_is_device_locked($device) && $unsettheme && confirm_sesskey() && ($device != 'default')) {
// Unset the theme and continue.
unset_config(core_useragent::get_device_type_cfg_var_name($device));
$device = '';
if (!$themename && $thedevice == 'default') {
$themename = theme_config::DEFAULT_THEME;
}
+ $themelocked = theme_is_device_locked($thedevice);
$screenshotcell = $strthemenotselected;
$unsetthemebutton = '';
$headingthemename = $OUTPUT->heading($strthemename, 3);
}
// If not default device then show option to unset theme.
- if ($thedevice != 'default') {
+ if ($thedevice != 'default' && !$themelocked) {
$unsetthemestr = get_string('unsettheme', 'admin');
$unsetthemeurl = new moodle_url('/theme/index.php',
array('device' => $thedevice, 'sesskey' => sesskey(), 'unsettheme' => true));
}
$deviceurl = new moodle_url('/theme/index.php', array('device' => $thedevice, 'sesskey' => sesskey()));
- $select = new single_button($deviceurl, $strthemeselect, 'get');
+
+ $select = '';
+ if (!$themelocked) {
+ $select = $OUTPUT->render(new single_button($deviceurl, $strthemeselect, 'get'));
+ }
+
+ $lockwarning = '';
+ if ($themelocked) {
+ $lockwarning = html_writer::div(get_string('configoverride', 'admin'), 'alert alert-info');
+ }
$table->data[] = array(
$OUTPUT->heading(ucfirst($thedevice), 3),
$screenshotcell,
- $headingthemename . $OUTPUT->render($select) . $unsetthemebutton
+ $headingthemename . $lockwarning . $select . $unsetthemebutton
);
}
} else {
$device = core_useragent::get_device_type();
}
+ $themelocked = theme_is_device_locked($device);
$table->id = 'adminthemeselector';
$table->head = array(get_string('theme'), get_string('info'));
- $themes = core_component::get_plugin_list('theme');
+ $themes = array();
+ if ($themelocked) {
+ $heading = get_string('currenttheme', 'admin');
+ $themename = theme_get_locked_theme_for_device($device);
+ $themedirectory = core_component::get_plugin_directory('theme', $themename);
+ $themes[$themename] = $themedirectory;
+ } else {
+ $themes = core_component::get_plugin_list('theme');
+ }
foreach ($themes as $themename => $themedir) {
// Contents of the second cell.
$infocell = $OUTPUT->heading($strthemename, 3);
+ if ($themelocked) {
+ $infocell .= html_writer::div(get_string('configoverride', 'admin'), 'alert alert-info');
+ }
+
// Button to choose this as the main theme or unset this theme for devices other then default.
- if (($ischosentheme) && ($device != 'default')) {
- $unsetthemestr = get_string('unsettheme', 'admin');
- $unsetthemeurl = new moodle_url('/theme/index.php',
- array('device' => $device, 'unsettheme' => true, 'sesskey' => sesskey()));
- $unsetbutton = new single_button($unsetthemeurl, $unsetthemestr, 'get');
- $infocell .= $OUTPUT->render($unsetbutton);
- } else if ((!$ischosentheme)) {
- $setthemestr = get_string('usetheme');
- $setthemeurl = new moodle_url('/theme/index.php',
- array('device' => $device, 'choose' => $themename, 'sesskey' => sesskey()));
- $setthemebutton = new single_button($setthemeurl, $setthemestr, 'get');
- $infocell .= $OUTPUT->render($setthemebutton);
+ if (!$themelocked) {
+ if (($ischosentheme) && ($device != 'default')) {
+ $unsetthemestr = get_string('unsettheme', 'admin');
+ $unsetthemeurl = new moodle_url('/theme/index.php',
+ array('device' => $device, 'unsettheme' => true, 'sesskey' => sesskey()));
+ $unsetbutton = new single_button($unsetthemeurl, $unsetthemestr, 'get');
+ $infocell .= $OUTPUT->render($unsetbutton);
+ } else if ((!$ischosentheme)) {
+ $setthemestr = get_string('usetheme');
+ $setthemeurl = new moodle_url('/theme/index.php',
+ array('device' => $device, 'choose' => $themename, 'sesskey' => sesskey()));
+ $setthemebutton = new single_button($setthemeurl, $setthemestr, 'get');
+ $infocell .= $OUTPUT->render($setthemebutton);
+ }
}
$row[] = $infocell;