Perforce Chronicle 2012.2/486814
API Documentation
|
Check if the active user can edit the given content resource. More...
Public Member Functions | |
assert (Zend_Acl $acl, Zend_Acl_Role_Interface $role=null, Zend_Acl_Resource_Interface $resource=null, $privilege=null) | |
Checks if the active user can edit the given content resource. | |
Protected Attributes | |
$_privilege = 'edit' | |
$_privilegeAll = 'edit-all' |
Check if the active user can edit the given content resource.
Content_Acl_Assert_CanEdit::assert | ( | Zend_Acl $ | acl, |
Zend_Acl_Role_Interface $ | role = null , |
||
Zend_Acl_Resource_Interface $ | resource = null , |
||
$ | privilege = null |
||
) |
Checks if the active user can edit the given content resource.
Exists to aggregate the edit-all and edit-own privileges.
Zend_Acl | $acl | the acl instance |
Zend_Acl_Role_Interface | $role | the role to check access for |
Zend_Acl_Resource_Interface | $resource | the resource (should be content/*) |
string | $privilege | the privilege (should be edit) |
{ // early exit if resource is not content or privilege is not edit. if (!preg_match('#^content(/.*)?$#', $resource->getResourceId()) || $privilege !== $this->_privilege ) { return false; } // true if role is allowed to edit all content. if ($acl->isAllowed($role, 'content', $this->_privilegeAll)) { return true; } // true if role is allowed to edit-own and user owns this content. $isOwner = new Content_Acl_Assert_IsOwner; if ($acl->isAllowed($role, 'content', $this->_privilege . '-own') && $isOwner->assert($acl, $role, $resource, $privilege) ) { return true; } else { return false; } }
Content_Acl_Assert_CanEdit::$_privilege = 'edit' [protected] |
Reimplemented in Content_Acl_Assert_CanDelete.
Content_Acl_Assert_CanEdit::$_privilegeAll = 'edit-all' [protected] |
Reimplemented in Content_Acl_Assert_CanDelete.