Ejemplo n.º 1
0
 /**
  *
  */
 public function guest()
 {
     $page = I('get.page', get_opinion('PAGER'));
     $UserLogic = new UserLogic();
     $where = array("user_level" => array('eq', 5));
     $count = $UserLogic->where($where)->count();
     if ($count != 0) {
         $Page = new GreenPage($count, $page);
         // 实例化分页类 传入总记录数
         $pager_bar = $Page->show();
         $limit = $Page->firstRow . ',' . $Page->listRows;
         $list = D('Access', 'Logic')->guestList($limit);
     }
     $this->assign('pager', $pager_bar);
     $this->assign('listname', '游客用户');
     $this->assign('list', $list);
     $this->display('userlist');
 }
Ejemplo n.º 2
0
 /**
  * 注册用户
  * @param $username
  * @param $nickname
  * @param $password
  * @param $email
  * @return string
  */
 public function register($username, $nickname, $password, $email)
 {
     $new_user_role = get_opinion('new_user_role', true, 5);
     $new_user_statue = get_opinion('new_user_statue', true, 1);
     $User = new UserLogic();
     $userDetail = $User->where(array('user_login' => $username))->select();
     if ($userDetail != '') {
         return $this->jsonResult(0, "用户名已存在");
     } else {
         // 组合用户信息并添加
         $newUserDetail = array('user_login' => $username, 'user_nicename' => $nickname, 'user_pass' => encrypt($password), 'user_email' => $email, 'user_status' => $new_user_statue);
         // 添加用户与角色关系
         $newUserDetail['user_level'] = $new_user_role;
         $Role_users = D('Role_users');
         if ($new_id = $User->add($newUserDetail)) {
             $role = array('role_id' => $new_user_role, 'user_id' => $new_id);
             if ($Role_users->add($role)) {
                 return $this->jsonResult(1, "注册成功!", U('Admin/Access/index'));
             } else {
                 return $this->jsonResult(0, "注册成功,添加用户权限失败!");
             }
         } else {
             return $this->jsonResult(0, "注册用户失败");
         }
     }
 }