Permalink
Browse files

MDL-31488 admin: made admin_externalpage_setup() try to guess the rea…

…son why the requested section couldnt be found
  • Loading branch information...
1 parent 81ef1b4 commit dfe26d0ba3e970f8b96f6888f6a1765fc34010f3 @andyjdavis andyjdavis committed with danpoltawski May 3, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/adminlib.php
View
@@ -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

0 comments on commit dfe26d0

Please sign in to comment.