/** * Shows the details of a role * */ public function detailsAction() { $this->view->acl = array('index' => $this->_helper->hasAccess('index'), 'edit' => $this->_helper->hasAccess('edit'), 'delete' => $this->_helper->hasAccess('delete'), 'application-access' => $this->_helper->hasAccess('application-access'), 'remote-access' => $this->_helper->hasAccess('remote-access')); $roleId = $this->_getParam('roleId', null); if (is_null($roleId)) { throw new Ot_Exception_Input('msg-error-roleIdNotSet'); } $role = new Ot_Model_DbTable_Role(); $thisRole = $role->find($roleId); if (is_null($thisRole)) { throw new Ot_Exception_Data('msg-error-noRole'); } $inheritRoleName = ''; if ($thisRole['inheritRoleId'] != 0) { $inheritRole = $role->find($thisRole['inheritRoleId']); $inheritRoleName = $inheritRole->name; } $defaultRole = $role->find($this->_helper->configVar('defaultRole')); $resources = $this->_acl->getResources($thisRole['roleId']); foreach ($resources as &$r) { foreach ($r as &$c) { $c['someAccess'] = false; foreach ($c['part'] as $p) { if ($p['access']) { $c['someaccess'] = true; } } } unset($c); } unset($r); $remoteAcl = new Ot_Acl('remote'); $remoteResources = $remoteAcl->getRemoteResources($thisRole['roleId']); foreach ($remoteResources as &$r) { foreach ($r as &$c) { $c['someAccess'] = false; foreach ($c['part'] as $p) { if ($p['access']) { $c['someaccess'] = true; } } } } unset($r); if ($this->_request->isPost()) { if (!in_array($_POST['scope'], array('application', 'remote'))) { throw new Ot_Exception('Scope not found.'); } $scope = $_POST['scope']; unset($_POST['scope']); $rules = $this->_processAccessList($_POST, $thisRole->inheritRoleId, $scope); $role->assignRulesForRole($thisRole->roleId, $scope, $rules); $logOptions = array('attributeName' => 'accessRole', 'attributeId' => $thisRole->roleId); $this->_helper->log(Zend_Log::INFO, 'Role ' . $thisRole->name . ' was modified', $logOptions); $this->_helper->messenger->addSuccess('Role permissions were set successfully'); $this->_helper->redirector->gotoRoute(array('controller' => 'acl', 'action' => 'details', 'roleId' => $thisRole->roleId, 'scope' => $scope), 'ot', true); } $this->_helper->pageTitle("ot-acl-details:title", $thisRole->name); $this->view->assign(array('inheritRole' => $inheritRoleName, 'remoteResources' => $remoteResources, 'guestHasAccess' => $this->_helper->hasAccess('index', 'ot_api', $this->_helper->configVar('defaultRole')), 'defaultRole' => $defaultRole, 'role' => $thisRole->toArray(), 'resources' => $resources, 'scope' => $this->_getParam('scope', 'application'), 'children' => $this->_acl->getChildrenOfRole($thisRole->roleId))); }