/** * info card for this role * * @view /views/scripts/role/info.phtml * @access public * @todo show permissions to ressources */ public function infoAction() { $roleRow = new Admin_Model_DbRow_Role($this->dbRole->find($this->checkRoleIdParam())); $groups = array(); $users = array(); $inherits = array(); foreach ($this->dbRoleMember->getRoleBindingTo($roleRow->get('id'), 'group') as $row) { $groups[] = new Admin_Model_DbRow_Group($row); } foreach ($this->dbRoleMember->getRoleBindingTo($roleRow->get('id'), 'user') as $row) { $users[] = new Admin_Model_DbRow_User($row); } foreach ($this->dbRoleInherit->getRoleInheritance($roleRow->get('id')) as $row) { $inherits[] = new Admin_Model_DbRow_Role($row); } $this->view->role = $roleRow; $this->view->groups = $groups; $this->view->users = $users; $this->view->inherits = $inherits; }
/** * Delete a role * * @return array */ public function saveDeleteRoleAction() { $roleModel = new Admin_Model_DbTable_Acl_Role(); $roleMembers = new Admin_Model_DbTable_Acl_RoleMember(); $roleInherits = new Admin_Model_DbTable_Acl_RoleInherit(); $ruleModel = new Admin_Model_DbTable_Acl_Rule(); $roleRow = $roleModel->find($this->request->getParam('id', 0)); if ($roleRow->count() !== 1) { return $this->responseFailure('Failed saving informations', 'Invalid call. No valid role id provided'); } else { $row = $roleRow->current(); $roleRow = new Admin_Model_DbRow_Role($roleRow->current()); $row->delete(); // delete the entries from other tables that refer to this role // members, inherited roles, ACL Rules! $roleMembers->deleteWithRoleId($roleRow->get('id')); $roleInherits->deleteWithRoleId($roleRow->get('id')); $ruleModel->deleteWithRoleId($roleRow->get('id')); return $this->responseSuccess(); } }