public function rolesAction()
 {
     $roles = $this->acl->getRoles(true);
     $roles = coll_key($roles, 'id');
     $id = I('get.id');
     if (!empty($id)) {
         $id = intval($id);
         if ($id > 0) {
             $role = $roles[$id];
             $this->assign('entity', $role);
             if (!empty($role)) {
                 if (I('get.do') == 'delete') {
                     if ($this->acl->removeRole($id)) {
                         $this->success('成功删除用户组', U('control/acl/roles'));
                         exit;
                     } else {
                         $this->error('操作失败, 请稍后重试');
                     }
                 }
             }
         }
         if (IS_POST) {
             $input = coll_elements(array('title', 'status', 'remark'), I('post.'));
             $input['title'] = trim($input['title']);
             if (empty($input['title'])) {
                 $this->error('请输入用户组名称');
             }
             $input['status'] = $input['status'] == '-1' ? '-1' : '0';
             $input['parent'] = '0';
             if (!empty($role)) {
                 //编辑组
                 $ret = $this->acl->table('__USR_ROLES__')->data($input)->where("`id`={$id}")->save();
                 if (empty($ret)) {
                     $this->error('保存用户组失败, 请稍后重试');
                 } else {
                     $this->success('成功保存用户组', U('control/acl/roles'));
                     exit;
                 }
             } else {
                 //新增组
                 $ret = $this->acl->table('__USR_ROLES__')->data($input)->add();
                 if (empty($ret)) {
                     $this->error('保存新增用户组失败, 请稍后重试');
                 } else {
                     $this->success('成功新增用户组', U('control/acl/roles'));
                     exit;
                 }
             }
         }
     }
     $this->assign('roles', $roles);
     $this->display();
 }
 public function listAction()
 {
     $condition = '';
     $pars = array();
     $users = $this->acl->table('__USR_USERS__')->where($condition)->bind($pars)->select();
     if (!empty($users)) {
         $roles = coll_key($this->roles, 'id');
         foreach ($users as &$user) {
             $user['role'] = $roles[$user['role']];
         }
     }
     $this->assign('users', $users);
     $this->display();
 }
예제 #3
0
 public function deleteAction($uid)
 {
     $uid = intval($uid);
     if ($uid == '1') {
         $this->error('创建用户不能删除');
     }
     $user = $this->acl->getUser($uid, true);
     if (empty($user)) {
         $this->error('访问错误');
     }
     $ret = $this->acl->table('__USR_USERS__')->where("`uid`={$uid}")->delete();
     if (empty($ret)) {
         $this->error('删除用户信息失败, 请稍后重试');
     } else {
         $this->success('删除成功');
     }
 }