Created
April 22, 2011 20:43
-
-
Save aaronstaves/937573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class userModel extends userDefinition{ | |
public function hasPermission($permId) { | |
//setup initial return vars | |
$roleHasPermission = false; | |
$userHasPermission = false; | |
//if we weren't passed a specific permission Id | |
//lets look it up | |
$perm = new permissionModel(); | |
if(!is_int($permId)) { | |
$perm->key = $permId; | |
} | |
else { | |
$perm->id = $permId; | |
} | |
//if we can't load it, they certainly don't | |
//have permission! | |
if(!$perm->load()) { | |
return false; | |
} | |
//see if their role(s) has the permission | |
$roles = userRoleModel::getUserRoles($this->id); | |
foreach($roles as $role) { | |
/*************/ | |
//$perm->id here is passing in as a string | |
/*************/ | |
if($role->hasPermission($perm->id)) { | |
$roleHasPermission = true; | |
} | |
} | |
/***** more code below ***/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment