public function update($role_id)
 {
     $role_id = $role_id + 0;
     $model = new \Model\RoleModel();
     if (IS_POST) {
         if ($data = $model->create(I('post.'), 2)) {
             if ($model->save($data) !== false) {
                 $this->success('修改角色成功', U('showlist'), 1);
                 exit;
             }
             $this->error('修改角色失败');
         }
         $this->error($model->getError());
     }
     //获取所有的权限
     $priv_model = new \Model\PrivilegeModel();
     $priv_list = $priv_model->getTree();
     $this->assign('priv_list', $priv_list);
     //获取要修改角色的信息
     $role_info = $model->find($role_id);
     $this->assign('role_info', $role_info);
     $priv_info = M('RolePrivilege')->where("role_id={$role_id}")->select();
     $this->assign('priv_info', $priv_info);
     $this->display();
 }
示例#2
0
 public function update($role_id)
 {
     $role = new \Model\RoleModel();
     if (!empty($_POST)) {
         //搜集所有字段
         if ($role->save($_POST)) {
             $this->redirect('showlist', array(), 2, "修改角色成功");
         }
     }
     $info = $role->find($role_id);
     $this->assign('info', $info);
     $this->display();
 }