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


PHP Zend_Acl_Role_Interface::getRoleId方法代码示例

本文整理汇总了PHP中Zend_Acl_Role_Interface::getRoleId方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Acl_Role_Interface::getRoleId方法的具体用法?PHP Zend_Acl_Role_Interface::getRoleId怎么用?PHP Zend_Acl_Role_Interface::getRoleId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Acl_Role_Interface的用法示例。


在下文中一共展示了Zend_Acl_Role_Interface::getRoleId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

 /**
  * 判断是否有访问某个游戏的条件
  * 
  * @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

示例4: 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

示例5: 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

示例6: 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 UserModel) {
         throw new Exception('Resource must be an instance of UserModel');
     }
     return $role->getRoleId() === $resource->getRoleId();
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:29,代码来源:SameRole.php

示例7: array

    /**
     * Returns the rules associated with a Resource and a Role, or null if no such rules exist
     *
     * If either $resource or $role is null, this means that the rules returned are for all Resources or all Roles,
     * respectively. Both can be null to return the default rule set for all Resources and all Roles.
     *
     * If the $create parameter is true, then a rule set is first created and then returned to the caller.
     *
     * @param  Zend_Acl_Resource_Interface $resource
     * @param  Zend_Acl_Role_Interface     $role
     * @param  boolean                     $create
     * @return array|null
     */
    protected function &_getRules(Zend_Acl_Resource_Interface $resource = null, Zend_Acl_Role_Interface $role = null,
                                  $create = false)
    {
        // create a reference to null
        $null = null;
        $nullRef =& $null;

        // follow $resource
        do {
            if (null === $resource) {
                $visitor =& $this->_rules['allResources'];
                break;
            }
            $resourceId = $resource->getResourceId();
            if (!isset($this->_rules['byResourceId'][$resourceId])) {
                if (!$create) {
                    return $nullRef;
                }
                $this->_rules['byResourceId'][$resourceId] = array();
            }
            $visitor =& $this->_rules['byResourceId'][$resourceId];
        } while (false);


        // follow $role
        if (null === $role) {
            if (!isset($visitor['allRoles'])) {
                if (!$create) {
                    return $nullRef;
                }
                $visitor['allRoles']['byPrivilegeId'] = array();
            }
            return $visitor['allRoles'];
        }
        $roleId = $role->getRoleId();
        if (!isset($visitor['byRoleId'][$roleId])) {
            if (!$create) {
                return $nullRef;
            }
            $visitor['byRoleId'][$roleId]['byPrivilegeId'] = array();
            $visitor['byRoleId'][$roleId]['allPrivileges'] = array('type' => null, 'assert' => null);
        }
        return $visitor['byRoleId'][$roleId];
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:57,代码来源:Acl.php

示例8: has

 /**
  * Returns true if and only if the Role exists in the registry
  *
  * The $role parameter can either be a Role or a Role identifier.
  *
  * @param  Zend_Acl_Role_Interface|string $role
  * @return boolean
  */
 public function has($role)
 {
     if ($role instanceof Zend_Acl_Role_Interface) {
         $roleId = $role->getRoleId();
     } else {
         $roleId = (string) $role;
     }
     return isset($this->_roles[$roleId]);
 }
开发者ID:NaszvadiG,项目名称:ci-beam,代码行数:17,代码来源:Registry.php

示例9: assert

 public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
 {
     if (ProfileTable::PUBLIC_FLAG_FRIEND == $resource->getPublicFlag()) {
         return 'self' === $role->getRoleId() || 'friend' === $role->getRoleId();
     }
     if (ProfileTable::PUBLIC_FLAG_PRIVATE == $resource->getPublicFlag()) {
         return 'self' === $role->getRoleId();
     }
     return true;
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:10,代码来源:MemberProfileTable.class.php

示例10: array

 protected function &_getRules($type, $name, Zend_Acl_Role_Interface $role = null, $create = false)
 {
     // create a reference to null
     $null = null;
     $nullRef =& $null;
     // follow $resource
     do {
         if (null === $name) {
             $visitor =& $this->_rules['all' . $type . 's'];
             break;
         }
         if (!isset($this->_rules['by' . $type . 'Id'][$name])) {
             if (!$create) {
                 return $nullRef;
             }
             $this->_rules['by' . $type . 'Id'][$name] = array();
         }
         $visitor =& $this->_rules['by' . $type . 'Id'][$name];
     } while (false);
     // follow $role
     if (null === $role) {
         if (!isset($visitor['allRoles'])) {
             if (!$create) {
                 return $nullRef;
             }
             $visitor['allRoles'] = array();
         }
         return $visitor['allRoles'];
     }
     $roleId = $role->getRoleId();
     if (!isset($visitor['byRoleId'][$roleId])) {
         if (!$create) {
             return $nullRef;
         }
         $visitor['byRoleId'][$roleId] = array();
     }
     return $visitor['byRoleId'][$roleId];
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:38,代码来源:Acl.php

示例11: removeRole

 /**
  * Removes the Role from the registry
  *
  * The $role parameter can either be a Role or a Role identifier.
  *
  * @param  Zend_Acl_Role_Interface|string $role
  * @uses   Zend_Acl::removeRole()
  * @return Zend_Acl Provides a fluent interface
  */
 public function removeRole($role)
 {
     if ($this->hasCachingAdapter()) {
         $this->_checkCaching();
     }
     $roleId = $role instanceof Zend_Acl_Role_Interface ? $role->getRoleId() : (string) $role;
     $this->_setRoleUnloaded($roleId);
     $arrRoles = $this->_getAdapter()->removeRole($roleId);
     foreach ($arrRoles as $role) {
         if ($this->hasRole($role) && $role != $roleId) {
             parent::removeRole($role);
         }
         if ($this->hasRoleLoaded($role)) {
             $this->_setRoleUnloaded($role);
         }
         //Zum Cachen freigeben
         if ($this->hasCachingAdapter()) {
             $this->_getCachingAdapter()->change($role, null);
         }
     }
     //Zum Cachen freigeben:
     if ($this->hasCachingAdapter()) {
         $this->_getCachingAdapter()->change($roleId, null);
     }
     return parent::removeRole($roleId);
 }
开发者ID:BackupTheBerlios,项目名称:dkplusengine,代码行数:35,代码来源:Adaptable.php

示例12: assert

 public function assert(Zend_Acl $acl, Zend_Acl_Role_Interface $role = null, Zend_Acl_Resource_Interface $resource = null, $privilege = null)
 {
     global $db;
     //If asserting is off then return true right away
     if (isset($resource->assert) && $resource->assert == false || isset($acl->_entrada_last_query) && isset($acl->_entrada_last_query->assert) && $acl->_entrada_last_query->assert == false) {
         return true;
     }
     if (isset($resource->eform_id)) {
         $eform_id = $resource->eform_id;
     } else {
         if (isset($acl->_entrada_last_query->eform_id)) {
             $eform_id = $acl->_entrada_last_query->eform_id;
         } else {
             //Parse out the user ID and course ID
             $resource_id = $resource->getResourceId();
             $resource_type = preg_replace('/[0-9]+/', "", $resource_id);
             if ($resource_type !== "evaluationform") {
                 //This only asserts for users authoring evaluation forms.
                 return false;
             }
             $eform_id = preg_replace('/[^0-9]+/', "", $resource_id);
         }
     }
     $role_id = $role->getRoleId();
     $access_id = preg_replace('/[^0-9]+/', "", $role_id);
     $query = "SELECT `user_id` FROM `" . AUTH_DATABASE . "`.`user_access`\n\t\t\t\t\tWHERE `id` = " . $db->qstr($access_id);
     $user_id = $db->GetOne($query);
     if (!isset($user_id) || !$user_id) {
         $role_id = $acl->_entrada_last_query_role->getRoleId();
         $access_id = preg_replace('/[^0-9]+/', "", $role_id);
         $query = "SELECT `user_id` FROM `" . AUTH_DATABASE . "`.`user_access`\n\t\t\t\t\t\tWHERE `id` = " . $db->qstr($access_id);
         $user_id = $db->GetOne($query);
     }
     $permissions = Models_Evaluation::getFormAuthorPermissions($eform_id);
     if ($permissions) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:nadeemshafique,项目名称:entrada-1x,代码行数:40,代码来源:entrada_acl.inc.php

示例13: loadRole

 /**
  * <p>Lädt eine Rolle.</p>
  * <p>Der zurückgegebene Array sieht ist wie folgt aufgebaut:
  * <code>
  * $array = array(
  *	0 => array(
  *		0 => 'role1',
  *		1 => array()
  *	),
  *	1 => array(
  *		0 => 'role2',
  *		1 => array()
  *	),
  *	2 => array(
  *		0 => 'role3',
  *		1 => array('role2')
  *	),
  *	3 => array(
  *		0 => 'role4',
  *		1 => array('role1', 'role2')
  *	)
  * );
  * </code>
  * </p>
  * @param Zend_Acl_Role_Interface|string|null $role
  * @return array
  */
 public function loadRole($role)
 {
     $roleId = $role instanceof Zend_Acl_Role_Interface ? $role->getRoleId() : (string) $role;
     $arrRoles = $this->_loadRoles($roleId);
     $arrReturn = array();
     foreach ($arrRoles as $role) {
         $arrReturn[] = array(0 => $role[$this->_getRoleColumn(self::ROLE_NAME)], 1 => $role['parent']);
     }
     return $arrReturn;
 }
开发者ID:BackupTheBerlios,项目名称:dkplusengine,代码行数:37,代码来源:Db.php


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