diff --git a/CHANGES.md b/CHANGES.md index fbb4630cbbe..1a0a52095a7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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. diff --git a/locallib.php b/locallib.php index 256f9f11c25..fc8b7d0c925 100644 --- a/locallib.php +++ b/locallib.php @@ -1898,6 +1898,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 ''; @@ -1997,7 +2003,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'); @@ -2007,7 +2013,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 { @@ -2186,3 +2192,19 @@ function theme_boost_union_get_external_scss($type) { // Now return the (hopefully valid and working) SCSS code. return $extscss; } + +/** + * 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; + } +} diff --git a/templates/popover-favourites.mustache b/templates/popover-favourites.mustache index 6e13e83223d..e6b8157255f 100644 --- a/templates/popover-favourites.mustache +++ b/templates/popover-favourites.mustache @@ -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}}