From b647fbc199e8db4ab2017a28287be6d169687dd9 Mon Sep 17 00:00:00 2001 From: Stefan Topfstedt Date: Wed, 13 Mar 2024 06:40:54 -0700 Subject: [PATCH] prevent help menu from displaying if it is turned off or empty. --- classes/output/helpmenu.php | 27 +++---------------------- templates/helpmenu.mustache | 39 ++++++++++++++++++++----------------- version.php | 2 +- 3 files changed, 25 insertions(+), 43 deletions(-) diff --git a/classes/output/helpmenu.php b/classes/output/helpmenu.php index bd290f69..83876bb5 100644 --- a/classes/output/helpmenu.php +++ b/classes/output/helpmenu.php @@ -43,8 +43,9 @@ class helpmenu implements renderable, templatable { public function export_for_template(renderer_base $output): stdClass { $menu = new stdClass(); $menu->items = []; + $menu->showmenu = false; - if (!$this->show_menu()) { + if (!config::get_setting('helpfeedbackenabled')) { return $menu; } @@ -60,29 +61,7 @@ public function export_for_template(renderer_base $output): stdClass { ]; } } - + $menu->showmenu = !empty($menu->items); return $menu; } - - /** - * Determine if the help menu should be shown. - * - * @return bool - * @throws dml_exception - */ - protected function show_menu(): bool { - if (!config::get_setting('helpfeedbackenabled')) { - return false; - } - - // Check if at least one of the menu items actually contains a link. - for ($i = 1; $i <= constants::HELPMENU_ITEMS_COUNT; $i++) { - $url = config::get_setting('helpfeedback' . $i . 'link', ''); - if (!empty($url)) { - return true; - } - } - - return false; - } } diff --git a/templates/helpmenu.mustache b/templates/helpmenu.mustache index 83c8bac5..ed9d50d0 100644 --- a/templates/helpmenu.mustache +++ b/templates/helpmenu.mustache @@ -32,24 +32,27 @@ "title": "Foo Bar", "target": "_blank" } - ] + ], + "showmenu": true } }} -