当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Acl_Role_Interface类代码示例

本文整理汇总了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;
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:32,代码来源:Acl.php

示例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;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:39,代码来源:Registry.php

示例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;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:45,代码来源:SameScope.php

示例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');
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:41,代码来源:ActivatedApplicationOriginatedSms.php

示例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;
 }
开发者ID:starflash,项目名称:ZtChart-ZF1-Example,代码行数:13,代码来源:GameType.php

示例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();
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:16,代码来源:Storage.php

示例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);
 }
开发者ID:alvsgithub,项目名称:Newscoop,代码行数:17,代码来源:Storage.php

示例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();
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:26,代码来源:Impersonating.php

示例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();
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:28,代码来源:FilterSameOrg.php

示例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;
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:15,代码来源:OrgConfig.php

示例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);
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:30,代码来源:ServiceProviderEnabler.php

示例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;
     }
 }
开发者ID:GEANT,项目名称:CORE,代码行数:25,代码来源:UserCanUpdateSessionAssertion.php

示例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();
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:30,代码来源:SameServiceProviderCommercial.php

示例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]);
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:30,代码来源:ChildOrganizationType.php

示例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;
     }
 }
开发者ID:GEANT,项目名称:CORE,代码行数:26,代码来源:UserCanUpdatePresentationAssertion.php


注:本文中的Zend_Acl_Role_Interface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。