Skip to content

Commit

Permalink
Managers can no longer access the Themes menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-milette committed Dec 19, 2024
1 parent 08690a1 commit 2edd906
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- New {lastnamephonetic} tag.
- New {middlename} tag.
### Updated
- Managers can no longer access the Themes menu.
- Only Site Administrators can access User: Profile Fields in Admin menu.
- Fix-312: ifactivitycompleted and ifnotactivitycompleted now works correctly with graded activities.

Expand Down
52 changes: 25 additions & 27 deletions classes/text_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ private function generatortags(&$text) {
// Allow Theme Changes on URL must be enabled for this to have any effect.
if (stripos($text, '{menuthemes}') !== false) {
$menu = '';
if (is_siteadmin() && empty($_POST)) { // If a site administrator.
if (empty($_POST) && is_siteadmin() && !is_role_switched($PAGE->course->id)) { // If a site administrator.
if (get_config('core', 'allowthemechangeonurl')) {
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http")
. "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
Expand All @@ -1058,34 +1058,32 @@ private function generatortags(&$text) {
$menu .= '-' . $themename . '|' . $url . 'theme=' . $theme . PHP_EOL;
}

// If an administrator, add links to Advanced Theme Settings and to Current theme settings.
if (is_siteadmin() && !is_role_switched($PAGE->course->id)) {
$theme = $PAGE->theme->name;
$menu = 'Themes' . PHP_EOL . $menu;
if ($CFG->branch >= 404) {
$label = 'themesettingsadvanced';
$section = 'themesettingsadvanced';
} else {
$label = 'themesettings';
$section = 'themesettings';
}
// Add links to Advanced Theme Settings and to Current theme settings.
$theme = $PAGE->theme->name;
$menu = 'Themes' . PHP_EOL . $menu;
if ($CFG->branch >= 404) {
$label = 'themesettingsadvanced';
$section = 'themesettingsadvanced';
} else {
$label = 'themesettings';
$section = 'themesettings';
}

$menu .= '-###' . PHP_EOL;
$menu .= '-{getstring:admin}' . $label . '{/getstring}|/admin/settings.php' .
'?section=' . $section . '|Including custom menus, designer mode, theme in URL' . PHP_EOL;

$menu .= '-###' . PHP_EOL;
$menu .= '-{getstring:admin}' . $label . '{/getstring}|/admin/settings.php' .
'?section=' . $section . '|Including custom menus, designer mode, theme in URL' . PHP_EOL;

if (!file_exists($CFG->dirroot . '/mod/hvp/version.php')) { // Not compatible with mod_hvp.
if (file_exists($CFG->dirroot . '/theme/' . $theme . '/settings.php')) {
require_once($CFG->libdir . '/adminlib.php');
if (admin_get_root()->locate('theme_' . $theme)) {
// Settings use categories interface URL.
$url = '/admin/category.php?category=theme_' . $theme . PHP_EOL;
} else {
// Settings use tabs interface URL.
$url = '/admin/settings.php?section=themesetting' . $theme . PHP_EOL;
}
$menu .= '-{getstring:admin}currenttheme{/getstring}|' . $url;
if (!file_exists($CFG->dirroot . '/mod/hvp/version.php')) { // Not compatible with mod_hvp.
if (file_exists($CFG->dirroot . '/theme/' . $theme . '/settings.php')) {
require_once($CFG->libdir . '/adminlib.php');
if (admin_get_root()->locate('theme_' . $theme)) {
// Settings use categories interface URL.
$url = '/admin/category.php?category=theme_' . $theme . PHP_EOL;
} else {
// Settings use tabs interface URL.
$url = '/admin/settings.php?section=themesetting' . $theme . PHP_EOL;
}
$menu .= '-{getstring:admin}currenttheme{/getstring}|' . $url;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024100703; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024100704; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2014051200; // Requires Moodle version 2.7 or later.
$plugin->component = 'filter_filtercodes'; // Full name of the plugin (used for diagnostics).
$plugin->release = '2.6.1';
Expand Down

0 comments on commit 2edd906

Please sign in to comment.