From ad9fee8416cb726dd4bdc7a52a4b40db279bae8d Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Thu, 3 May 2012 10:46:28 +0700 Subject: [PATCH] MDL-31488 admin: made admin_externalpage_setup() try to guess the reason why the requested section couldnt be found --- lib/adminlib.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/adminlib.php b/lib/adminlib.php index 7d9b70a3ef2..e7d97c512f5 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -5828,8 +5828,15 @@ function admin_externalpage_setup($section, $extrabutton = '', array $extraurlpa $extpage = $adminroot->locate($section, true); if (empty($extpage) or !($extpage instanceof admin_externalpage)) { - print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/"); - die; + // The requested section isn't in the admin tree + // It could be because the user has inadequate capapbilities or because the section doesn't exist + if (!has_capability('moodle/site:config', context_system::instance())) { + // The requested section could depend on a different capability + // but most likely the user has inadequate capabilities + print_error('accessdenied', 'admin'); + } else { + print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/"); + } } // this eliminates our need to authenticate on the actual pages