Skip to content

Commit

Permalink
capability related changes in new admin tree
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 21, 2006
1 parent db51ddc commit 2ce38b7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1025,21 +1025,21 @@ class admin_externalpage extends part_of_admin_tree {
/**
* @var string The role capability/permission a user must have to access this external page.
*/
var $role;
var $req_capability;

/**
* Constructor for adding an external page into the admin tree.
*
* @param string $name The internal name for this external page. Must be unique amongst ALL part_of_admin_tree objects.
* @param string $visiblename The displayed name for this external page. Usually obtained through get_string().
* @param string $url The external URL that we should link to when someone requests this external page.
* @param string $role The role capability/permission a user must have to access this external page. Defaults to 'moodle/legacy:admin'.
* @param string $req_capability The role capability/permission a user must have to access this external page. Defaults to 'moodle/site:config'.
*/
function admin_externalpage($name, $visiblename, $url, $role = 'moodle/legacy:admin') {
function admin_externalpage($name, $visiblename, $url, $req_capability = 'moodle/site:config') {
$this->name = $name;
$this->visiblename = $visiblename;
$this->url = $url;
$this->role = $role;
$this->req_capability = $req_capability;
}

/**
Expand Down Expand Up @@ -1074,7 +1074,7 @@ function prune($name) {
}

/**
* Determines if the current user has access to this external page based on $this->role.
* Determines if the current user has access to this external page based on $this->req_capability.
*
* @uses CONTEXT_SYSTEM
* @uses SITEID
Expand All @@ -1085,7 +1085,7 @@ function check_access() {
return true; // no access check before site is fully set up
}
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
return has_capability($this->role, $context);
return has_capability($this->req_capability, $context);
}

}
Expand Down Expand Up @@ -1115,7 +1115,7 @@ class admin_settingpage extends part_of_admin_tree {
/**
* @var string The role capability/permission a user must have to access this external page.
*/
var $role;
var $req_capability;

// see admin_category
function path($name, $path = array()) {
Expand All @@ -1138,12 +1138,12 @@ function prune($name) {
}

// see admin_externalpage
function admin_settingpage($name, $visiblename, $role = 'moodle/legacy:admin') {
function admin_settingpage($name, $visiblename, $req_capability = 'moodle/site:config') {
global $CFG;
$this->settings = new stdClass();
$this->name = $name;
$this->visiblename = $visiblename;
$this->role = $role;
$this->req_capability = $req_capability;
}

// not the same as add for admin_category. adds an admin_setting to this admin_settingpage. settings appear (on the settingpage) in the order in which they're added
Expand All @@ -1164,7 +1164,7 @@ function check_access() {
return true; // no access check before site is fully set up
}
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
return has_capability($this->role, $context);
return has_capability($this->req_capability, $context);
}

// outputs this page as html in a table (suitable for inclusion in an admin pagetype)
Expand Down

0 comments on commit 2ce38b7

Please sign in to comment.