Perforce Chronicle 2012.2/486814
API Documentation
|
Check if the active user owns 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 owns the given content resource. |
Check if the active user owns the given content resource.
Content_Acl_Assert_IsOwner::assert | ( | Zend_Acl $ | acl, |
Zend_Acl_Role_Interface $ | role = null , |
||
Zend_Acl_Resource_Interface $ | resource = null , |
||
$ | privilege = null |
||
) |
Checks if the active user owns the given content resource.
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 doesn't match content/* if (!preg_match('#^content/(.+)$#', $resource->getResourceId(), $matches)) { return false; } // grab active user, or return false if no named active user. if (P4Cms_User::hasActive() && !P4Cms_User::fetchActive()->isAnonymous()) { $user = P4Cms_User::fetchActive(); } else { return false; } // fetch content entry, or return false if entry does not exist. $id = $matches[1]; $options = array('includeDeleted' => true); if (P4Cms_Content::exists($id, $options)) { $entry = P4Cms_Content::fetch($id, $options); } else { return false; } // check if user is owner of content entry. if ($entry->getOwner() == $user->getId()) { return true; } else { return false; } }