/** * Shows account information. */ public function showAction() { $this->view->title = $this->view->translate('admin_account_show'); $id = $this->getRequest()->getParam('id'); if (empty($id)) { $this->_logger->debug('Missing parameter account id.'); $this->_helper->redirector('index'); } $moduleDirectory = dirname($this->getFrontController()->getModuleDirectory()); $modulesModel = new Admin_Model_Modules($moduleDirectory); $this->view->allModules = $modulesModel->getAll(); $account = new Opus_Account($id); $this->view->account = $account; // Get all Opus_UserRoles for current Account *plus* 'guest' $roles = array(); foreach ($account->getRole() as $roleLinkModel) { $roles[] = $roleLinkModel->getModel(); } $guestRole = Opus_UserRole::fetchByName('guest'); if (!is_null($guestRole)) { $roles[] = $guestRole; } // Build module-roles table. $modulesRoles = array(); foreach ($this->view->allModules as $module) { $modulesRoles[$module] = array(); } foreach ($roles as $role) { $roleName = $role->getName(); $roleModules = $role->listAccessModules(); foreach ($roleModules as $module) { if (!array_key_exists($module, $modulesRoles)) { $modulesRoles[$module] = array(); } $modulesRoles[$module][] = $roleName; } } foreach (array_keys($modulesRoles) as $module) { $modulesRoles[$module] = array_unique($modulesRoles[$module]); sort($modulesRoles[$module]); } $this->view->modulesRoles = $modulesRoles; return $account; }
/** * Action for showing list of modules and permissions. * * @throws Exception */ public function listmoduleAction() { $id = $this->getRequest()->getParam('roleid'); if ($id == null) { throw new Exception('Role ID missing'); } $role = new Opus_UserRole($id); $roleModules = $role->listAccessModules(); if ($role->getName() !== 'guest') { $guest = Opus_UserRole::fetchByName('guest'); $guestModules = $guest->listAccessModules(); // Role 'guest' has always access to 'default' module if (!in_array('default', $guestModules)) { $guestModules[] = 'default'; } $this->view->guestModules = $guestModules; } else { // Role 'guest' has alreays access to 'default' module if (!in_array('default', $roleModules)) { $roleModules[] = 'default'; } } $moduleDirectory = dirname($this->getFrontController()->getModuleDirectory()); $modulesModel = new Admin_Model_Modules($moduleDirectory); $transitions = Controller_Helper_Workflow::getWorkflowResources(); $this->view->loginNames = $role->getAllAccountNames(); $this->view->roleId = $role->getId(); $this->view->roleName = $role->getName(); $this->view->modules = $roleModules; $this->view->allModules = $modulesModel->getAll(); $this->view->allResources = $this->getAllResources(); $this->view->allWorkflow = $transitions; }