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 #759.
  • Loading branch information
abias committed Nov 19, 2024
1 parent a0e2c3d commit e58fb94
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 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;
}
}

0 comments on commit e58fb94

Please sign in to comment.