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


PHP Context::clearPermissionsCache方法代码示例

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


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

示例1: uninstall

 public final function uninstall($scope = null)
 {
     if ($this->isCore()) {
         throw new \Exception('Cannot uninstall core modules');
     }
     $this->_uninstall();
     $this->delete();
     $scope = $scope === null ? framework\Context::getScope()->getID() : $scope;
     framework\Settings::deleteModuleSettings($this->getName(), $scope);
     framework\Context::deleteModulePermissions($this->getName(), $scope);
     framework\Context::clearRoutingCache();
     framework\Context::clearPermissionsCache();
 }
开发者ID:pkdevboxy,项目名称:thebuggenie,代码行数:13,代码来源:Module.php

示例2: runConfigureRole

 public function runConfigureRole(framework\Request $request)
 {
     try {
         $role = new entities\Role($request['role_id']);
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('error' => $this->getI18n()->__('This is not a valid role')));
     }
     if ($role->isSystemRole()) {
         $access_level = $this->getAccessLevel($request['section'], 'core');
     } else {
         $access_level = $this->getUser()->canManageProject($role->getProject()) ? framework\Settings::ACCESS_FULL : framework\Settings::ACCESS_READ;
     }
     switch ($request['mode']) {
         case 'list_permissions':
             return $this->renderComponent('configuration/rolepermissionslist', array('role' => $role));
             break;
         case 'edit':
             if (!$access_level == framework\Settings::ACCESS_FULL) {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array('error' => $this->getI18n()->__('You do not have access to edit these permissions')));
             }
             if ($request->isPost()) {
                 $role->setName($request['name']);
                 $role->save();
                 $new_permissions = array();
                 foreach ($request['permissions'] ?: array() as $new_permission) {
                     $permission_details = explode(',', $new_permission);
                     $new_permissions[$permission_details[2]] = array('module' => $permission_details[0], 'target_id' => $permission_details[1]);
                 }
                 $existing_permissions = array();
                 foreach ($role->getPermissions() as $existing_permission) {
                     if (!array_key_exists($existing_permission->getPermission(), $new_permissions)) {
                         $role->removePermission($existing_permission);
                     } else {
                         $existing_permissions[$existing_permission->getPermission()] = $new_permissions[$existing_permission->getPermission()];
                         unset($new_permissions[$existing_permission->getPermission()]);
                     }
                 }
                 foreach ($new_permissions as $permission_key => $details) {
                     $p = new entities\RolePermission();
                     $p->setModule($details['module']);
                     $p->setPermission($permission_key);
                     if ($details['target_id']) {
                         $p->setTargetID($details['target_id']);
                     }
                     $role->addPermission($p);
                 }
                 foreach ($existing_permissions as $permission_key => $details) {
                     $p = new entities\RolePermission();
                     $p->setModule($details['module']);
                     $p->setPermission($permission_key);
                     if ($details['target_id']) {
                         $p->setTargetID($details['target_id']);
                     }
                     tables\Permissions::getTable()->addRolePermission($role, $p);
                 }
                 framework\Context::clearPermissionsCache();
                 framework\Context::cacheAllPermissions();
                 return $this->renderJSON(array('message' => $this->getI18n()->__('Permissions updated'), 'permissions_count' => count($request['permissions']), 'role_name' => $role->getName()));
             }
             return $this->renderComponent('configuration/rolepermissionsedit', array('role' => $role));
         case 'delete':
             if (!$access_level == framework\Settings::ACCESS_FULL || !$request->isPost()) {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array('error' => $this->getI18n()->__('This role cannot be removed')));
             }
             $role->delete();
             return $this->renderJSON(array('message' => $this->getI18n()->__('Role deleted')));
     }
 }
开发者ID:nrensen,项目名称:thebuggenie,代码行数:71,代码来源:Main.php

示例3: _postSave

 protected function _postSave($is_new)
 {
     tables\ScopeHostnames::getTable()->saveScopeHostnames($this->getHostnames(), $this->getID());
     // Load fixtures for this scope if it's a new scope
     if ($is_new) {
         if (!$this->isDefault()) {
             $prev_scope = framework\Context::getScope();
             framework\Context::setScope($this);
         }
         $this->loadFixtures();
         if (!$this->isDefault()) {
             Module::installModule('publish', $this);
             framework\Context::setScope($prev_scope);
             framework\Context::clearPermissionsCache();
         }
     }
 }
开发者ID:RTechSoft,项目名称:thebuggenie,代码行数:17,代码来源:Scope.php


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