From 78c96c6f445f812b1b6c88aac228bc7c4a654d08 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 15 Jul 2021 20:18:50 +0800 Subject: [PATCH] MDL-72163 admin: Plugins overview page should link to categories --- lib/adminlib.php | 14 ++++++++++++++ lib/classes/plugininfo/base.php | 21 +++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/adminlib.php b/lib/adminlib.php index 82ac4027dac..c38965edba9 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -810,6 +810,20 @@ class admin_category implements parentable_part_of_admin_tree { $this->hidden = $hidden; } + /** + * Get the URL to view this page. + * + * @return moodle_url + */ + public function get_settings_page_url(): moodle_url { + return new moodle_url( + '/admin/category.php', + [ + 'category' => $this->name, + ] + ); + } + /** * Returns a reference to the part_of_admin_tree object with internal name $name. * diff --git a/lib/classes/plugininfo/base.php b/lib/classes/plugininfo/base.php index 486baee309f..f32498f40b6 100644 --- a/lib/classes/plugininfo/base.php +++ b/lib/classes/plugininfo/base.php @@ -509,13 +509,22 @@ abstract class base { return null; } $settings = admin_get_root()->locate($section); - if ($settings && $settings instanceof \admin_settingpage) { - return new moodle_url('/admin/settings.php', array('section' => $section)); - } else if ($settings && $settings instanceof \admin_externalpage) { - return new moodle_url($settings->url); - } else { - return null; + if ($settings) { + if ($settings instanceof \admin_settingpage) { + return new moodle_url('/admin/settings.php', [ + 'section' => $section, + ]); + } + + if ($settings instanceof \admin_externalpage) { + return new moodle_url($settings->url); + } + + if ($settings instanceof \admin_category) { + return $settings->get_settings_page_url(); + } } + return null; } /**