start of fine-grained permissions
This commit is contained in:
parent
bb49c09279
commit
bff5a8453f
2 changed files with 15 additions and 1 deletions
|
@ -4,6 +4,11 @@ function _new_user($row) {
|
|||
return new User($row);
|
||||
}
|
||||
|
||||
$_perm_map = array(
|
||||
"override_config" => "admin",
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* An object representing a row in the "users" table.
|
||||
*
|
||||
|
@ -90,6 +95,15 @@ class User {
|
|||
/*
|
||||
* useful user object functions start here
|
||||
*/
|
||||
public function can($ability) {
|
||||
global $_perm_map;
|
||||
$needed = $_perm_map[$ability];
|
||||
if($needed == "admin" && $this->is_admin()) return true;
|
||||
if($needed == "user" && $this->is_logged_in()) return true;
|
||||
if($needed == "anon") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if this user is anonymous (not logged in)
|
||||
|
|
|
@ -879,7 +879,7 @@ function get_debug_info() {
|
|||
// print_obj ($object, $title, $return)
|
||||
function print_obj($object,$title="Object Information", $return=false) {
|
||||
global $user;
|
||||
if(DEBUG && isset($_GET['debug']) && $user->is_admin()) {
|
||||
if(DEBUG && isset($_GET['DEBUG']) && $user->can("override_config")) {
|
||||
$pr = print_r($object,true);
|
||||
$count = substr_count($pr,"\n")<=25?substr_count($pr,"\n"):25;
|
||||
$pr = "<textarea rows='".$count."' cols='80'>$pr</textarea>";
|
||||
|
|
Reference in a new issue