MDL-31488 admin: made admin_externalpage_setup() try to guess the reason why the requested section couldnt be found

This commit is contained in:
Andrew Davis
2012-05-09 11:58:24 +08:00
committed by Dan Poltawski
parent 1357fde409
commit ad9fee8416
+9 -2
View File
@@ -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