Perforce Chronicle 2012.2/486814
API Documentation

Cron_Model_User Class Reference

Extended P4Cms_User class to provide granting additional privileges on the fly. More...

Inheritance diagram for Cron_Model_User:
P4Cms_User P4Cms_Record_Connected P4Cms_Model P4Cms_ModelInterface

List of all members.

Public Member Functions

 allow ($resource, $privilege=null)
 Grant additonal access to a given resource and (optionally) a given privilege on the resource for this user.
 isAllowed ($resource, $privilege=null, P4Cms_Acl $acl=null)
 Extended parent to also consider additionally granted access when evaluating if this user is allowed access to the given resource.

Protected Attributes

 $_allowed = array()

Detailed Description

Extended P4Cms_User class to provide granting additional privileges on the fly.

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

Cron_Model_User::allow ( resource,
privilege = null 
)

Grant additonal access to a given resource and (optionally) a given privilege on the resource for this user.

Parameters:
string$resourceresource to grant access for
string | array | null$privilegeresource privilege to grant access for
Returns:
Cron_Model_User provides fluent interface
    {
        $this->_allowed[] = array('resource' => $resource, 'privilege' => (array) $privilege);

        return $this;
    }
Cron_Model_User::isAllowed ( resource,
privilege = null,
P4Cms_Acl acl = null 
)

Extended parent to also consider additionally granted access when evaluating if this user is allowed access to the given resource.

Parameters:
P4Cms_Acl_Resource | string$resourcethe resource to check access to.
P4Cms_Acl_Privilege | string | null$privilegeoptional - the privilege to check.
P4Cms_Acl | null$acloptional - the acl to check against. defaults to the currently active acl.
Returns:
bool true if the user is allowed access to the resource.

Reimplemented from P4Cms_User.

    {
        $resourceId = $resource instanceof Zend_Acl_Resource_Interface
            ? $resource->getResourceId()
            : $resource;

        // check for special (runtime) access.
        foreach ($this->_allowed as $allowed) {
            if ($allowed['resource'] !== $resourceId) {
                continue;
            }
            if (!$allowed['privilege'] || in_array($privilege, $allowed['privilege'])) {
                return true;
            }
        }

        return parent::isAllowed($resource, $privilege, $acl);
    }

Member Data Documentation

Cron_Model_User::$_allowed = array() [protected]

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