user rights

This commit is contained in:
Evan Prodromou
2009-09-15 15:28:11 -04:00
parent a8d1b7e9c2
commit 6c069312e2
3 changed files with 135 additions and 0 deletions

View File

@@ -711,4 +711,30 @@ class User extends Memcached_DataObject
return true;
}
/**
* Does this user have the right to do X?
*
* With our role-based authorization, this is merely a lookup for whether the user
* has a particular role. The implementation currently uses a switch statement
* to determine if the user has the pre-defined role to exercise the right. Future
* implementations may allow per-site roles, and different mappings of roles to rights.
*
* @param $right string Name of the right, usually a constant in class Right
* @return boolean whether the user has the right in question
*/
function hasRight($right)
{
switch ($right)
{
case Right::deleteOthersNotice:
return $this->hasRole('moderator');
break;
default:
$result = false;
Event::handle('UserRightsCheck', array($this, &$result));
return $result;
}
}
}