本文整理汇总了PHP中Zend_Acl_Role_Interface类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Acl_Role_Interface类的具体用法?PHP Zend_Acl_Role_Interface怎么用?PHP Zend_Acl_Role_Interface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Acl_Role_Interface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAcl
/**
* Get acl for role
*
* @param Zend_Acl_Role_Interface $role
* @return Zend_Acl
*/
public function getAcl(Zend_Acl_Role_Interface $role)
{
if (isset($this->cache[$role->getRoleId()])) {
return $this->cache[$role->getRoleId()];
}
$acl = new Zend_Acl();
// set resources
$resources = $this->getResources();
foreach (array_keys($resources) as $resource) {
$acl->addResource($resource);
}
// get role parents if possible
$method = self::PARENTS_METHOD;
$parents = NULL;
if (method_exists($role, $method)) {
foreach ($role->{$method}() as $parent) {
$parents[] = $parent;
$acl->addRole($parent);
$this->addRules($acl, $parent);
}
}
// set role
$acl->addRole($role, $parents);
$this->addRules($acl, $role);
return $this->cache[$role->getRoleId()] = $acl;
}
示例2: addParent
/**
* Add parent to the $role node
*
* @param \Zend_Acl_Role_Interface|string $role
* @param array|\Zend_Acl_Role_Interface|string $parents
* @return $this
* @throws \Zend_Acl_Role_Registry_Exception
*/
public function addParent($role, $parents)
{
try {
if ($role instanceof \Zend_Acl_Role_Interface) {
$roleId = $role->getRoleId();
} else {
$roleId = $role;
$role = $this->get($role);
}
} catch (\Zend_Acl_Role_Registry_Exception $e) {
throw new \Zend_Acl_Role_Registry_Exception("Child Role id '{$roleId}' does not exist");
}
if (!is_array($parents)) {
$parents = [$parents];
}
foreach ($parents as $parent) {
try {
if ($parent instanceof \Zend_Acl_Role_Interface) {
$roleParentId = $parent->getRoleId();
} else {
$roleParentId = $parent;
}
$roleParent = $this->get($roleParentId);
} catch (\Zend_Acl_Role_Registry_Exception $e) {
throw new \Zend_Acl_Role_Registry_Exception("Parent Role id '{$roleParentId}' does not exist");
}
$this->_roles[$roleId]['parents'][$roleParentId] = $roleParent;
$this->_roles[$roleParentId]['children'][$roleId] = $role;
}
return $this;
}
示例3: assert
/**
* Returns true if and only if the assertion conditions are met
*
* This method is passed the ACL, Role, Resource, and privilege to which
* the authorization query applies. If the $role, $resource, or $privilege
* parameters are null, it means that the query applies to all Roles,
* Resources, or privileges, respectively.
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $role
* @param Zend_Acl_Resource_Interface $resource
* @param string $privilege
* @return boolean
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
{
// We need specific objects to check against each other
if (NULL === $role || NULL === $resource) {
return false;
}
// Ensure we're handled User models
if (!$role instanceof UserModel) {
throw new Exception('Role must be an instance of UserModel');
}
if (!$resource instanceof WatcherModel) {
throw new Exception('Resource must be an instance of WatcherModel');
}
switch ($resource->scope) {
case 'user':
return $role->id == $resource->scopeId;
case 'apiId':
if (!$role instanceof \Application\Model\CurrentUserModel || !$role->isApiAuthUser()) {
return FALSE;
}
return $role->apiId == $resource->scopeId;
case 'token':
if (Zend_Auth::getInstance()->hasIdentity() && ($ident = Zend_Auth::getInstance()->getIdentity()) && isset($ident['token'])) {
return $ident['token'] === $resource->scopeId;
}
return false;
case 'organization':
return $role->organizationId === $resource->scopeId;
}
return false;
}
示例4: assert
/**
* Returns true if and only if the assertion conditions are met
*
* This method is passed the ACL, Role, Resource, and privilege to which
* the authorization query applies. If the $role, $resource, or $privilege
* parameters are null, it means that the query applies to all Roles,
* Resources, or privileges, respectively.
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $role
* @param Zend_Acl_Resource_Interface $resource
* @param string $privilege
* @return boolean
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
{
// We need specific objects to check against each other
if (NULL === $role) {
return false;
}
// Ensure we're handled User models
if (!$role instanceof UserModel) {
throw new Exception('Role must be an instance of UserModel');
}
// Get the organization
$orgService = \Application\Service\OrgService::getInstance();
$org = $orgService->load($role->getOrganizationId());
if ($org->getType() != OrgCustomerModel::ORG_TYPE) {
$org = $orgService->getParentByType($org, OrgCustomerModel::ORG_TYPE);
}
if ($org && !is_null($org->getSupplementaryServicesId())) {
// Check if the customer has supplementary services configured
// with application originated SMS option activated
$supplSrv = \Application\Service\SupplServicesService::getInstance();
$services = $supplSrv->load($org->getSupplementaryServicesId());
if ($services && $services->getApplicationOriginatedSms() == SupplServicesModel::ST_ACTIVATED) {
return true;
}
}
throw new Exception('Role must have applicationOriginatedSms activated');
}
示例5: assert
/**
* 判断是否有访问某个游戏的条件
*
* @see Zend_Acl_Assert_Interface::assert()
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
{
if ($this->_request->has('gametype')) {
$roleData = ZtChart_Model_Acl_Loader::getInstance()->getRole($role->getRoleId());
return in_array($this->_request->getParam('gametype'), $roleData['role_gametype']);
}
return true;
}
示例6: getRules
/**
* Get rules for role
*
* @param Zend_Acl_Role_Interface $role
* @return array
*/
public function getRules(\Zend_Acl_Role_Interface $role)
{
$em = $this->doctrine->getManager();
$queryBuilder = $em->getRepository('Newscoop\\Entity\\Acl\\Rule')->createQueryBuilder('r')->select('r.resource, r.action, r.type')->where('r.role = :role')->setParameter('role', $role->getRoleId());
if (is_a($role, '\\Newscoop\\Entity\\User\\Group')) {
// @fix WOBS-568: ignore deny rules for roles
$queryBuilder->andWhere('r.type = :allow')->setParameter('allow', 'allow');
}
return $queryBuilder->getQuery()->getArrayResult();
}
示例7: getRules
/**
* Get rules for role
*
* @param Zend_Acl_Role_Interface $role
* @return array
*/
public function getRules(\Zend_Acl_Role_Interface $role)
{
$em = $this->doctrine->getManager();
$repository = $em->getRepository('Newscoop\\Entity\\Acl\\Rule');
$criteria = array('role' => $role->getRoleId());
if (is_a($role, '\\Newscoop\\Entity\\User\\Group')) {
// @fix WOBS-568: ignore deny rules for roles
$criteria['type'] = 'allow';
}
return $repository->findBy($criteria);
}
示例8: assert
/**
* Returns true if and only if the assertion conditions are met
*
* This method is passed the ACL, Role, Resource, and privilege to which
* the authorization query applies. If the $role, $resource, or $privilege
* parameters are null, it means that the query applies to all Roles,
* Resources, or privileges, respectively.
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $role
* @param Zend_Acl_Resource_Interface $resource
* @param string $privilege
* @return boolean
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
{
// We need specific objects to check against each other
if (NULL === $role) {
return false;
}
// Ensure we're handled User models
if (!$role instanceof UserModel) {
throw new Exception('Role must be an instance of UserModel');
}
return $role->isImpersonating();
}
示例9: assert
/**
* Returns true if and only if the assertion conditions are met
*
* This method is passed the ACL, Role, Resource, and privilege to which
* the authorization query applies. If the $role, $resource, or $privilege
* parameters are null, it means that the query applies to all Roles,
* Resources, or privileges, respectively.
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $role
* @param Zend_Acl_Resource_Interface $resource
* @param string $privilege
* @return boolean
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
{
if (!$role instanceof UserModel) {
throw new Exception('Role must be an instance of UserModel');
}
if (!$resource instanceof App_ListFilter) {
throw new Exception('Resource must be an instance of App_ListFilter');
}
$filter = $resource->getOneFilterByFieldName(SimFilterFields::SERVICE_PROVIDER_COMM);
if (!$filter) {
return false;
}
return $filter->getValue() == $role->getOrganizationId();
}
示例10: assert
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
{
if (NULL === $role) {
return false;
}
// Ensure we're handled User models
if (!$role instanceof \Application\Model\UserModel) {
throw new Exception('Role must be an instance of UserModel');
}
$org = $role->getOrganization();
$orgConfig = \Application\Service\OrgService::getInstance()->getOrgConfig($org);
$keyConfig = $this->getKey();
$valueConfig = $this->getValue();
return $orgConfig->getConfig($keyConfig) == $valueConfig;
}
示例11: assert
/**
* Returns true if and only if the assertion conditions are met
*
* This method is passed the ACL, Role, Resource, and privilege to which
* the authorization query applies. If the $role, $resource, or $privilege
* parameters are null, it means that the query applies to all Roles,
* Resources, or privileges, respectively.
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $role
* @param Zend_Acl_Resource_Interface $resource
* @param null $privilege
* @return bool
* @throws Exception
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
{
if (NULL === $role || NULL === $resource) {
return false;
}
// Ensure we're handled User models
if (!$role instanceof \Application\Model\UserModel) {
throw new Exception('Role must be an instance of UserModel');
}
$org = $role->getOrganization();
if (!$org instanceof \Application\Model\Organization\OrgServiceProviderModel) {
throw new Exception('Org must be an instance of OrgServiceProviderModel');
}
return \Application\Service\OrgService::getInstance()->isEnabler($org);
}
示例12: assert
/**
* This assertion should receive the actual User objects.
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $user
* @param Zend_Acl_Resource_Interface $model
* @param $privilege
* @return bool
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $user = null, Zend_Acl_Resource_Interface $model = null, $privilege = null)
{
if ($user) {
$sessions = $user->getSessionsToChair();
} else {
return false;
}
$request = Zend_Controller_Front::getInstance()->getRequest();
$param = $request->getParam('id') ? $request->getParam('id') : $request->getParam('session_id');
// perform check
if ($param !== null && in_array((int) $param, $sessions, true)) {
return true;
} else {
return false;
}
}
示例13: assert
/**
* Returns true if and only if the assertion conditions are met
*
* This method is passed the ACL, Role, Resource, and privilege to which
* the authorization query applies. If the $role, $resource, or $privilege
* parameters are null, it means that the query applies to all Roles,
* Resources, or privileges, respectively.
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $role
* @param Zend_Acl_Resource_Interface $resource
* @param string $privilege
* @return boolean
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
{
// We need specific objects to check against each other
if (NULL === $role || NULL === $resource) {
return false;
}
// Ensure we're handled User models
if (!$role instanceof UserModel) {
throw new Exception('Role must be an instance of UserModel');
}
$orgId = $role->getOrganizationId();
if (!$resource instanceof SimModel) {
throw new Exception('Resource must be an instance of SimModel');
}
return $orgId === $resource->getServiceProviderCommercialId();
}
示例14: assert
/**
* Returns true if and only if the assertion conditions are met
*
* This method is passed the ACL, Role, Resource, and privilege to which
* the authorization query applies. If the $role, $resource, or $privilege
* parameters are null, it means that the query applies to all Roles,
* Resources, or privileges, respectively.
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $role
* @param Zend_Acl_Resource_Interface $resource
* @param string $privilege
* @return boolean
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
{
if (!$role instanceof UserModel) {
throw new Exception('Role must be an instance of UserModel');
}
if (!$resource instanceof OrgModelAbstract) {
throw new Exception('Resource must be an instance of OrgModelAbstract');
}
$type = $resource->getType();
if (!isset($this->_types[$type])) {
throw new Exception('Resource has an undefined organization type');
}
$org = $role->getOrganization();
$orgType = $org->getType();
return $this->_diff($this->_types[$orgType], $this->_types[$type]);
}
示例15: assert
/**
* This assertion should receive the actual Presentation objects.
*
* @param Zend_Acl $acl
* @param Zend_Acl_Role_Interface $user
* @param Zend_Acl_Resource_Interface $model
* @param $privilege
* @return bool
*/
public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $user = null, Zend_Acl_Resource_Interface $model = null, $privilege = null)
{
if ($user) {
$presentations = $user->getMyPresentations();
} else {
return false;
}
$request = Zend_Controller_Front::getInstance()->getRequest();
$param = $request->getParam('id') ? $request->getParam('id') : $request->getParam('presentation_id');
$presentation = $model->getPresentationById($param);
// perform check
if ($param !== null && $presentation->isBeforeEditDeadline() && in_array((int) $param, $presentations, true)) {
return true;
} else {
return false;
}
}