/** * 权限列表 */ public function assignAction() { $this->view->roles = $this->role->getAll(); $this->view->roleId = (int) $this->_request->getParam('role_id'); if ($this->view->roleId == 0) { $this->view->roleId = $this->view->roles[0]['role_id']; //获取第一个角色 } elseif (!$this->role->idExists($this->view->roleId)) { $this->view->feedback(array('title' => '发生错误', 'message' => '指定的角色 ID 不存在或者已经被删除')); } $this->view->layout = array('title' => '管理后台 - 添加规则'); $this->view->ruleGroup = $this->rule->getRuleGroup(); $this->view->allowRules = $this->acl->getRoleAllowRule($this->view->roleId); }
/** * 添加规则 * @param string $resName * @param string $privName */ protected function _add($resName, $privName) { $data = array('res_name' => $resName, 'priv_name' => $privName); $this->db->insert('acl_rule', $data); $ruleId = $this->db->lastInsertId(); $roleModel = new RoleModel($this->_modName); $roleList = $roleModel->getAll(); $data = array(); foreach ($roleList as $role) { $data = array('rule_id' => $ruleId, 'role_id' => $role['role_id'], 'permit' => 0); $this->db->insert('acl', $data); } }