Skip to content

Commit

Permalink
MDL-72163 admin: Plugins overview page should link to categories
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 16, 2021
1 parent 2e1212e commit 6d0a391
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
14 changes: 14 additions & 0 deletions lib/adminlib.php
Expand Up @@ -810,6 +810,20 @@ public function __construct($name, $visiblename, $hidden=false) {
$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.
*
Expand Down
21 changes: 15 additions & 6 deletions lib/classes/plugininfo/base.php
Expand Up @@ -509,13 +509,22 @@ public function get_settings_url() {
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;
}

/**
Expand Down

0 comments on commit 6d0a391

Please sign in to comment.