Esempio n. 1
0
 protected function getAuthorStructure($uid)
 {
     //查询数据库中的基本信息
     $map = array('id' => $uid);
     $user = D('User/UcenterMember')->where($map)->find();
     //查询头像
     $addon = new AvatarAddon();
     $avatar = $addon->getAvatarUrl($uid);
     //返回结果
     return array('uid' => $user['id'], 'avatar_url' => $avatar, 'username' => $user['username']);
 }
Esempio n. 2
0
 public function getProfile($uid = null)
 {
     //默认查看自己的详细资料
     if (!$uid) {
         $this->requireLogin();
         $uid = $this->getUid();
     }
     //读取数据库中的用户详细资料
     $map = array('uid' => $uid);
     $user1 = D('Home/Member')->where($map)->find();
     $user2 = D('User/UcenterMember')->where(array('id' => $uid))->find();
     //获取头像信息
     $avatar = new AvatarAddon();
     $avatar_path = $avatar->getAvatarPath($uid);
     $avatar_url = getRootUrl() . $avatar->getAvatarPath($uid);
     //缩略头像
     $avatar128_path = getThumbImage($avatar_path, 128);
     $avatar128_path = '/' . $avatar128_path['src'];
     $avatar128_url = getRootUrl() . $avatar128_path;
     //获取等级
     $title = D('Usercenter/Title')->getTitle($user1['score']);
     //只返回必要的详细资料
     $this->apiSuccess("获取成功", null, array('uid' => $uid, 'avatar_url' => $avatar_url, 'avatar128_url' => $avatar128_url, 'signature' => $user1['signature'], 'email' => $user2['email'], 'mobile' => $user2['mobile'], 'score' => $user1['score'], 'name' => $user1['name'], 'sex' => $this->encodeSex($user1['sex']), 'birthday' => $user1['birthday'], 'title' => $title, 'username' => $user2['username']));
 }