當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。