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


PHP Mage_Api2_Model_Acl_Global_Role::getConfigNodeName方法代码示例

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


在下文中一共展示了Mage_Api2_Model_Acl_Global_Role::getConfigNodeName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getResourcesPermissions

 /**
  * Get resources permissions for selected role
  *
  * @return array
  */
 public function getResourcesPermissions()
 {
     if (null === $this->_resourcesPermissions) {
         $roleConfigNodeName = $this->_role->getConfigNodeName();
         $rulesPairs = array();
         $allowedType = Mage_Api2_Model_Acl_Global_Rule_Permission::TYPE_ALLOW;
         if ($this->_role) {
             /** @var $rules Mage_Api2_Model_Resource_Acl_Global_Rule_Collection */
             $rules = Mage::getResourceModel('api2/acl_global_rule_collection');
             $rules->addFilterByRoleId($this->_role->getId());
             /** @var $rule Mage_Api2_Model_Acl_Global_Rule */
             foreach ($rules as $rule) {
                 $resourceId = $rule->getResourceId();
                 $rulesPairs[$resourceId]['privileges'][$roleConfigNodeName][$rule->getPrivilege()] = $allowedType;
             }
         } else {
             //make resource "all" as default for new item
             $rulesPairs = array(Mage_Api2_Model_Acl_Global_Rule::RESOURCE_ALL => $allowedType);
         }
         //set permissions to resources
         /** @var $config Mage_Api2_Model_Config */
         $config = Mage::getModel('api2/config');
         /** @var $privilegeSource Mage_Api2_Model_Acl_Global_Rule_Privilege */
         $privilegeSource = Mage::getModel('api2/acl_global_rule_privilege');
         $privileges = array_keys($privilegeSource->toArray());
         /** @var $node Varien_Simplexml_Element */
         foreach ($config->getResources() as $resourceType => $node) {
             $resourceId = (string) $resourceType;
             $allowedRoles = (array) $node->privileges;
             $allowedPrivileges = array();
             if (isset($allowedRoles[$roleConfigNodeName])) {
                 $allowedPrivileges = $allowedRoles[$roleConfigNodeName];
             }
             foreach ($privileges as $privilege) {
                 if (empty($allowedPrivileges[$privilege]) && isset($rulesPairs[$resourceId][$roleConfigNodeName]['privileges'][$privilege])) {
                     unset($rulesPairs[$resourceId][$roleConfigNodeName]['privileges'][$privilege]);
                 } elseif (!empty($allowedPrivileges[$privilege]) && !isset($rulesPairs[$resourceId][$roleConfigNodeName]['privileges'][$privilege])) {
                     $deniedType = Mage_Api2_Model_Acl_Global_Rule_Permission::TYPE_DENY;
                     $rulesPairs[$resourceId]['privileges'][$roleConfigNodeName][$privilege] = $deniedType;
                 }
             }
         }
         $this->_resourcesPermissions = $rulesPairs;
     }
     return $this->_resourcesPermissions;
 }
开发者ID:ravi2jdesign,项目名称:solvingmagento_1.7.0,代码行数:51,代码来源:ResourcePermission.php


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