Skip to content

Instantly share code, notes, and snippets.

@aaronstaves
Created April 22, 2011 20:43
Show Gist options
  • Save aaronstaves/937573 to your computer and use it in GitHub Desktop.
Save aaronstaves/937573 to your computer and use it in GitHub Desktop.
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