From 8763bba518ab2795add1e77ea1d95e85cb8b4979 Mon Sep 17 00:00:00 2001 From: Justus Dieckmann Date: Tue, 20 Sep 2022 12:33:55 +0200 Subject: [PATCH] MDL-75569 course: fix non-functional search bar in course index page For users who are not allowed to access course/management.php, the normal course search is used instead. --- course/classes/output/manage_categories_action_bar.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/course/classes/output/manage_categories_action_bar.php b/course/classes/output/manage_categories_action_bar.php index 70fee710d66..127521985ad 100644 --- a/course/classes/output/manage_categories_action_bar.php +++ b/course/classes/output/manage_categories_action_bar.php @@ -128,13 +128,18 @@ class manage_categories_action_bar implements \renderable { * @return array */ protected function get_search_form(): array { - return [ - 'action' => new moodle_url('/course/management.php'), + $searchform = [ 'btnclass' => 'btn-primary', 'inputname' => 'search', 'searchstring' => get_string('searchcourses'), 'query' => $this->searchvalue ]; + if (\core_course_category::has_capability_on_any(['moodle/category:manage', 'moodle/course:create'])) { + $searchform['action'] = new moodle_url('/course/management.php'); + } else { + $searchform['action'] = new moodle_url('/course/search.php'); + } + return $searchform; } /**