Skip to content

Commit fb7f119

Browse files
authored
Feature: Add Bootstrap alert to Boost Union settings if Boost Union (or Boost Union Child) is not the active theme, resolves #773
1 parent edd391d commit fb7f119

File tree

11 files changed

+97
-0
lines changed

11 files changed

+97
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Changes
66

77
### Unreleased
88

9+
* 2025-10-16 - Feature: Add Bootstrap alert to Boost Union settings if Boost Union (or Boost Union Child) is not the active theme, resolves #773.
910
* 2025-10-15 - Improvement: On course cards, display the course fields as Bootstrap badges, resolves #1070
1011

1112
### v5.0-r10

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ Moodle an Hochschulen e.V. would like to thank these main contributors (in alpha
992992
* RWTH Aachen, Tim Schröder: Code
993993
* Solent University, Mark Sharp: Code
994994
* ssystems GmbH, Alexander Bias: Code, Peer Review, Ideating, Funding
995+
* ssystems GmbH, Sangyul Cha: Code
995996
* Technische Universität Berlin, Lars Bonczek: Code
996997
* University of Bayreuth, Nikolai Jahreis: Code
997998
* University of California, San Francisco, Stefan Topfstedt: Code

classes/admin_settingspage_tabs_with_external_and_tertiary.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public function output_html() {
8282
$this->override_selector_active_url(new \core\url('/theme/boost_union/snippets/overview.php'));
8383
$output .= $this->render_tertiary_navigation();
8484

85+
// Show alert if Boost Union is not the active theme.
86+
$output .= theme_boost_union_is_not_active_alert();
87+
8588
$activetab = optional_param('activetab', '', PARAM_TEXT);
8689
$context = ['tabs' => []];
8790
$havesetactive = false;

classes/admin_settingspage_tabs_with_tertiary.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ public function output_html() {
183183
// Add tertiary navigation as a select menu.
184184
$output .= $this->render_tertiary_navigation();
185185

186+
// Show alert if Boost Union is not the active theme.
187+
$output .= theme_boost_union_is_not_active_alert();
188+
186189
// Append parent output.
187190
$output .= parent::output_html();
188191

flavours/overview.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
echo $OUTPUT->header();
114114
echo \theme_boost_union\admin_settingspage_tabs_with_tertiary::get_tertiary_navigation_for_externalpage();
115115

116+
// Show alert if Boost Union is not the active theme.
117+
echo theme_boost_union_is_not_active_alert();
118+
116119
// Show flavours intro.
117120
$intro = new \core\output\notification(
118121
get_string('flavoursoverview_desc', 'theme_boost_union'), \core\output\notification::NOTIFY_INFO);

lang/en/theme_boost_union.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
$string['choosereadme'] = 'Theme Boost Union is an enhanced child theme of Boost which is intended, on the one hand, to make Boost simply more configurable and, on the other hand, to provide helpful additional features for the daily Moodle operation of admins, teachers and students. Boost Union is maintained by Moodle an Hochschulen e.V., in cooperation with ssystems GmbH, together with bdecent GmbH and lern.link GmbH';
3434
$string['configtitle'] = 'Boost Union';
3535
$string['githubissueslink'] = '<a href="https://github.com/moodle-an-hochschulen/moodle-theme_boost_union/issues">Github issues</a>';
36+
$string['warningboostunioninactive'] = 'Boost Union (or a child theme of Boost Union) is currently <em>not</em> the active theme. Settings on these pages will not have any effect if you do not <a href="{$a->url}">make Boost Union the active theme</a> or allow Boost Union to be used as category / course / user / cohort theme.';
3637

3738
// General select options.
3839
$string['never'] = 'Never';

locallib.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,6 +2626,38 @@ function theme_boost_union_is_active_theme() {
26262626
}
26272627
}
26282628

2629+
/**
2630+
* Helper function to generate HTML for an alert when Boost Union is not the active theme,
2631+
* but someone tries to access Boost Union's settings.
2632+
*
2633+
* @return string HTML for the alert.
2634+
*/
2635+
function theme_boost_union_is_not_active_alert() {
2636+
global $OUTPUT;
2637+
2638+
// Check if Boost Union or a child theme of it is active.
2639+
if (theme_boost_union_is_active_theme()) {
2640+
return '';
2641+
}
2642+
2643+
// Get the URL of the theme selector page for use in the alert.
2644+
$notificationurl = new core\url('/admin/themeselector.php');
2645+
2646+
// Create the notification object.
2647+
$notification = new core\output\notification(
2648+
get_string('warningboostunioninactive', 'theme_boost_union', [
2649+
'url' => $notificationurl->out(),
2650+
]),
2651+
core\output\notification::NOTIFY_WARNING
2652+
);
2653+
2654+
// Do not show a close button.
2655+
$notification->set_show_closebutton(false);
2656+
2657+
// Return the HTML for the alert.
2658+
return $OUTPUT->render($notification);
2659+
}
2660+
26292661
/**
26302662
* Helper function to check if a child theme of Boost Union (and _not_ Boost Union itself) is active.
26312663
* This is needed at multiple locations to improve child theme support in Boost Union already.

settings_overview.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
// Show page heading.
5252
echo $OUTPUT->heading(get_string('settingsoverview_title', 'theme_boost_union'));
5353

54+
// Show alert if Boost Union is not the active theme.
55+
echo theme_boost_union_is_not_active_alert();
56+
5457
// First, compose template context for Boost Union setting pages.
5558
$templatecontext['cards'][] = [
5659
'label' => get_string('configtitlelook', 'theme_boost_union'),

smartmenus/menus.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
echo $OUTPUT->header();
108108
echo \theme_boost_union\admin_settingspage_tabs_with_tertiary::get_tertiary_navigation_for_externalpage();
109109

110+
// Show alert if Boost Union is not the active theme.
111+
echo theme_boost_union_is_not_active_alert();
112+
110113
// Show smart menus intro.
111114
$intro = new \core\output\notification(
112115
get_string('smartmenus_desc', 'theme_boost_union'), \core\output\notification::NOTIFY_INFO);

snippets/overview.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@
128128
echo $OUTPUT->header();
129129
echo \theme_boost_union\admin_settingspage_tabs_with_tertiary::get_tertiary_navigation_for_externalpage();
130130

131+
// Show alert if Boost Union is not the active theme.
132+
echo theme_boost_union_is_not_active_alert();
133+
131134
// Create and render the tab tree.
132135
$tabtree = new \theme_boost_union\admin_externalpage_tabs();
133136
$tabtree->add_tab('snippetsoverview',

0 commit comments

Comments
 (0)