Ejemplo n.º 1
0
 /**
  * 生成新用户 - 通用入口
  *
  * @param string $username 用户名
  * @param string $nickname 昵称
  * @param string $avatar 头像链接
  * @return int 用户id
  */
 protected static function createUser($username, $nickname, $avatar)
 {
     $newUserInfo = array();
     $newUserInfo['username'] = $username;
     $newUserInfo['nickname'] = $nickname;
     $newUserInfo['avatar'] = !empty($avatar) ? $avatar : '';
     $newUserInfo['salt'] = PhalApi_Tool::createRandStr(32);
     $newUserInfo['password'] = '******';
     $newUserInfo['reg_time'] = $_SERVER['REQUEST_TIME'];
     $userModel = new Model_User_User();
     return $userModel->insert($newUserInfo);
 }
Ejemplo n.º 2
0
 public function getUserInfo($userId)
 {
     $rs = array();
     $userId = intval($userId);
     if ($userId <= 0) {
         return $rs;
     }
     $model = new Model_User_User();
     $rs = $model->get($userId, 'id, username, nickname, avatar');
     //按需获取
     if (empty($rs)) {
         return $rs;
     }
     $rs['user_id'] = intval($rs['id']);
     unset($rs['id']);
     return $rs;
 }