mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Formatting and documentation in Permission
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@86084 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
2b711fe45f
commit
e9df16ba5a
@ -85,19 +85,17 @@ class Permission extends DataObject {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the current member has the given permission
|
* Check that the current member has the given permission.
|
||||||
*
|
*
|
||||||
* @param string $code Code of the permission to check
|
* @param string $code Code of the permission to check (case-sensitive)
|
||||||
* @param string $arg Optional argument (e.g. a permissions for a specific
|
* @param string $arg Optional argument (e.g. a permissions for a specific page)
|
||||||
* page)
|
|
||||||
* @param int|Member $member Optional member instance or ID. If set to NULL, the permssion
|
* @param int|Member $member Optional member instance or ID. If set to NULL, the permssion
|
||||||
* will be checked for the current user
|
* will be checked for the current user
|
||||||
* @param bool $strict Use "strict" checking (which means a permission
|
* @param bool $strict Use "strict" checking (which means a permission
|
||||||
* will be granted if the key does not exist at all)?
|
* will be granted if the key does not exist at all)?
|
||||||
* @return int|bool The ID of the permission record if the permission
|
* @return int|bool The ID of the permission record if the permission
|
||||||
* exists; FALSE otherwise. If "strict" checking is
|
* exists; FALSE otherwise. If "strict" checking is
|
||||||
* disabled, TRUE will be returned if the permission does
|
* disabled, TRUE will be returned if the permission does not exist at all.
|
||||||
* not exist at all.
|
|
||||||
*/
|
*/
|
||||||
public static function check($code, $arg = "any", $member = null, $strict = true) {
|
public static function check($code, $arg = "any", $member = null, $strict = true) {
|
||||||
if(!$member) {
|
if(!$member) {
|
||||||
@ -125,18 +123,17 @@ class Permission extends DataObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the given member has the given permission
|
* Check that the given member has the given permission.
|
||||||
|
*
|
||||||
* @param int|Member memberID The ID of the member to check. Leave blank for the current member.
|
* @param int|Member memberID The ID of the member to check. Leave blank for the current member.
|
||||||
* Alternatively you can use a member object.
|
* Alternatively you can use a member object.
|
||||||
* @param string|array $code Code of the permission to check
|
* @param string|array $code Code of the permission to check (case-sensitive)
|
||||||
* @param string $arg Optional argument (e.g. a permissions for a specific
|
* @param string $arg Optional argument (e.g. a permissions for a specific page)
|
||||||
* page)
|
|
||||||
* @param bool $strict Use "strict" checking (which means a permission
|
* @param bool $strict Use "strict" checking (which means a permission
|
||||||
* will be granted if the key does not exist at all)?
|
* will be granted if the key does not exist at all)?
|
||||||
* @return int|bool The ID of the permission record if the permission
|
* @return int|bool The ID of the permission record if the permission
|
||||||
* exists; FALSE otherwise. If "strict" checking is
|
* exists; FALSE otherwise. If "strict" checking is
|
||||||
* disabled, TRUE will be returned if the permission does
|
* disabled, TRUE will be returned if the permission does not exist at all.
|
||||||
* not exist at all.
|
|
||||||
*/
|
*/
|
||||||
public static function checkMember($member, $code, $arg = "any", $strict = true) {
|
public static function checkMember($member, $code, $arg = "any", $strict = true) {
|
||||||
if(!$member) {
|
if(!$member) {
|
||||||
@ -155,7 +152,7 @@ class Permission extends DataObject {
|
|||||||
// case and this keeps the code simpler
|
// case and this keeps the code simpler
|
||||||
if(!is_array($code)) $code = array($code);
|
if(!is_array($code)) $code = array($code);
|
||||||
if(self::$admin_implies_all) $code[] = "ADMIN";
|
if(self::$admin_implies_all) $code[] = "ADMIN";
|
||||||
|
|
||||||
// Multiple $code values - return true if at least one matches, ie, intersection exists
|
// Multiple $code values - return true if at least one matches, ie, intersection exists
|
||||||
return (bool)array_intersect($code, self::$cache_permissions[$memberID]);
|
return (bool)array_intersect($code, self::$cache_permissions[$memberID]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user