From dfe26d0ba3e970f8b96f6888f6a1765fc34010f3 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 900e538fb37..5273fe31324 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -5804,8 +5804,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', get_system_context())) { + // 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