コード例 #1
0
 public function index()
 {
     $wid = (int) $_GET['wid'];
     $page = (int) $_GET['page'];
     $type = $_GET['type'];
     if ($type == 'u') {
         if ($this->userId) {
             $user = new ProfileAction();
             $userRelation = $user->getFriendRelation($wid);
             if ($userRelation == ('me' || 'friend' || 'request')) {
                 $info = getUserBasicInfo($wid);
                 $title = $info['name'];
                 $pic = $info['pic_square'];
             } else {
                 $this->redirect('', '', 'home');
             }
         } else {
             $this->redirect('', '', 'index');
         }
     } else {
         if ($type == 'g') {
             $map = array();
             $map['id'] = $wid;
             $group = D('Group')->find($map);
             if (empty($group)) {
                 $this->redirect('', '', 'home');
             } else {
                 if (empty($this->userId)) {
                     if ($group['privacy'] == 'OPEN') {
                         $title = $group['name'];
                         $groupAccess = 'GUEST';
                     } else {
                         $this->redirect('', '', 'index');
                     }
                 } else {
                     $map = array();
                     $map['uid'] = $this->userId;
                     $map['gid'] = $wid;
                     $member = D('GroupMember')->findAll($map);
                     if (empty($member) && $group['privacy'] != 'OPEN') {
                         $this->redirect('', '', 'home');
                     } else {
                         if (empty($member) && $group['privacy'] == 'OPEN') {
                             $title = $group['name'];
                             $groupAccess = 'USER_GUEST';
                         } else {
                             $title = $group['name'];
                             $groupAccess = strtoupper($member['title']);
                         }
                     }
                 }
             }
         } else {
             $this->redirect('', '', 'home');
         }
     }
     $listRows = 10;
     $Wall = $this->getWall($wid, $type, $listRows, $page);
     $this->assign('wall', $Wall);
     $this->assign('type', $type);
     $this->assign('title', $title);
     $this->assign('pic', $pic);
     $this->assign('groupAccess', $groupAccess);
     $this->assign('userRelation', $userRelation);
     $this->display();
 }
コード例 #2
0
 public function index()
 {
     $uid = (int) $_GET['id'];
     if (empty($uid)) {
         if (empty($this->userId)) {
             $this->redirect('', '', 'index');
         } else {
             $uid = $this->userId;
             $Profile = $this->userInfo;
         }
     } else {
         if (empty($this->userId)) {
             $this->redirect('', '', 'index');
         } else {
             if ($uid == $this->userId) {
                 $uid = $this->userId;
                 $Profile = $this->userInfo;
             } else {
                 $user = new ProfileAction();
                 $userRelation = $user->getFriendRelation($uid);
                 if ($userRelation == 'stranger') {
                     $this->redirect('', '', 'profile', '', array('id' => $uid));
                 }
             }
         }
     }
     $dao = D('User');
     $Profile = $dao->find($uid);
     $this->assign('profile', $Profile);
     /*
      * get current user's friends
      */
     $currentUserFriend = getFriend($uid);
     $i = 0;
     $j = 1;
     foreach ($currentUserFriend as &$key) {
         $key = array('uid' => current(array_diff($key, array($uid))));
         $key += array('userInfo' => getUserBasicInfo($key['uid']));
         $key += array('key' => $i);
         $key += array('id' => $j);
         $j++;
         if ($i == 9) {
             $i = 0;
         } else {
             $i++;
         }
     }
     $this->assign('currentUserFriend', $currentUserFriend);
     /*
      * get user count
      */
     $friendCount = count($currentUserFriend);
     $this->assign('friendCount', $friendCount);
     /*
      * get header
      */
     $name = '<a href="' . url('', '', 'profile', '', array('id' => $uid)) . '">' . $Profile['name'] . '</a>';
     $pageHeader = sprintf(L('_friends_header'), $name);
     if ($currentUserFriend) {
         $pageSubheader = sprintf(L('_friends_subheader1'), $name, $friendCount);
     } else {
         $pageSubheader = sprintf(L('_friends_subheader2'), $name);
     }
     $this->assign('pageHeader', $pageHeader);
     $this->assign('pageSubheader', $pageSubheader);
     $this->display();
 }