Skip to content

Commit

Permalink
Bugfix: The starred courses popover in the navbar must only be shown …
Browse files Browse the repository at this point in the history
…if Boost Union or Boost Union child is active, resolves moodle-an-hochschulen#759. (moodle-an-hochschulen#762)

* Bugfix: The starred courses popover in the navbar must only be shown if Boost Union or Boost Union child is active, resolves moodle-an-hochschulen#759.

* Bugfix: The starred courses popover showed a JavaScript error in the browser JS console, resolves moodle-an-hochschulen#759
  • Loading branch information
abias authored Nov 20, 2024
1 parent a0e2c3d commit aae86d1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Changes

### Unreleased

* 2024-11-19 - Bugfix: The starred courses popover showed a JavaScript error in the browser JS console, resolves #759.
* 2024-11-19 - Bugfix: The starred courses popover in the navbar must only be shown if Boost Union or Boost Union child is active, resolves #759.
* 2024-11-18 - Improvement: Add the possibility to restrict smart menus and smart menu items to site admins and non-site admins only, resolves #421.
* 2024-11-18 - Bugfix: Footer displacement on pages with minimal content, resolves #655.
* 2024-11-18 - Upstream change: Adopt changes from MDL-77732 ('Custom menu items do not receive active behaviour'), resolves #436 #620 #384 #715.
Expand Down
26 changes: 24 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,12 @@ function theme_boost_union_yesno_to_boolstring($var) {
function theme_boost_union_get_navbar_starredcoursespopover() {
global $USER, $OUTPUT;

// If a theme other than Boost Union or a child theme of it is active, return directly.
// This is necessary as the callback is called regardless of the active theme.
if (theme_boost_union_is_active_theme() != true) {
return '';
}

// The popover is relevant only for logged-in users. If the user is not logged in, return directly.
if (!isloggedin()) {
return '';
Expand Down Expand Up @@ -2033,7 +2039,7 @@ function($favourite) {
* @return string|void The legacy implementation will return a string, the hook implementation will return nothing.
*/
function theme_boost_union_callbackimpl_before_standard_html(&$hook = null) {
global $CFG, $PAGE;
global $CFG;

// Require local library.
require_once($CFG->dirroot.'/theme/boost_union/locallib.php');
Expand All @@ -2043,7 +2049,7 @@ function theme_boost_union_callbackimpl_before_standard_html(&$hook = null) {

// If a theme other than Boost Union or a child theme of it is active, return directly.
// This is necessary as the callback is called regardless of the active theme.
if ($PAGE->theme->name != 'boost_union' && !in_array('boost_union', $PAGE->theme->parents)) {
if (theme_boost_union_is_active_theme() != true) {
if ($hook != null) {
return;
} else {
Expand Down Expand Up @@ -2412,3 +2418,19 @@ function theme_boost_union_remove_hookmanipulation() {
// Remove the hook overrides.
$cache->delete('overrides');
}

/**
* Helper function to check if Boost Union or a child theme of Boost Union is active.
* This is needed at multiple locations to avoid that callbacks in Boost Union affect other active themes.
*
* @return bool
*/
function theme_boost_union_is_active_theme() {
global $PAGE;

if ($PAGE->theme->name == 'boost_union' || in_array('boost_union', $PAGE->theme->parents)) {
return true;
} else {
return false;
}
}
1 change: 0 additions & 1 deletion templates/popover-favourites.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
require(['jquery', 'core/popover_region_controller'], function($, Controller) {
var container = $('#nav-popover-favourites-container');
var controller = new Controller(container);
controller.registerEventListeners();
controller.registerListNavigationEventListeners();
});
{{/js}}

0 comments on commit aae86d1

Please sign in to comment.