Perforce Chronicle 2012.2/486814
API Documentation

Content_Acl_Assert_CanEdit Class Reference

Check if the active user can edit the given content resource. More...

Inheritance diagram for Content_Acl_Assert_CanEdit:
Content_Acl_Assert_CanDelete

List of all members.

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'

Detailed Description

Check if the active user can edit the given content resource.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

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.

Parameters:
Zend_Acl$aclthe acl instance
Zend_Acl_Role_Interface$rolethe role to check access for
Zend_Acl_Resource_Interface$resourcethe resource (should be content/*)
string$privilegethe privilege (should be edit)
Returns:
boolean true if the given role can edit the given content resource false if not allowed or if resource/privilege are not content/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;
        }
    }

Member Data Documentation

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.


The documentation for this class was generated from the following file: