コード例 #1
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 ($uid == $this->userId) {
             $uid = $this->userId;
             $Profile = $this->userInfo;
         } else {
             $dao = D('User');
             $Profile = $dao->find($uid);
             if (empty($Profile)) {
                 $this->redirect('', '', 'home');
             }
             if (empty($this->userId)) {
                 $this->redirect('', '', 'people', '', array('name' => str_replace(' ', '-', $Profile['name']), 'id' => $uid));
             }
         }
     }
     $this->assign('profile', $Profile);
     /*
      * get current user's friends
      */
     $currentUserFriend = getFriend($uid);
     foreach ($currentUserFriend as &$key) {
         $key = array('uid' => current(array_diff($key, array($uid))));
     }
     /*
      * get friend relation
      */
     $userRelation = $this->getFriendRelation($uid);
     $this->assign('userRelation', $userRelation);
     /*
      * redirect for stranger
      */
     if ($userRelation == 'stranger') {
         $this->redirect('', '', 's', '', array('id' => $uid));
     }
     /*
      * get friend subheader
      */
     $friendCount = count($currentUserFriend);
     if (!$currentUserFriend) {
         $friendSubheader = L('_friend_subheader3');
     } else {
         if ($friendCount > 1) {
             $friendSubheader = '<a href="' . url('', '', 'friends', '', array('id' => $uid)) . '">' . sprintf(L('_friend_subheader1'), $friendCount) . '</a>';
         } else {
             $friendSubheader = '<a href="' . url('', '', 'friends', '', array('id' => $uid)) . '">' . sprintf(L('_friend_subheader2'), $friendCount) . '</a>';
         }
     }
     $this->assign('friendCount', $friendCount);
     $this->assign('friendSubheader', $friendSubheader);
     /*
      * get user info
      */
     shuffle($currentUserFriend);
     $j = 0;
     for ($i = 0; $i < $friendCount; $i++) {
         $friend_uid = $currentUserFriend[$i]['uid'];
         $currentUserFriendShuffle[$i]['uid'] = $friend_uid;
         $currentUserFriendShuffle[$i]['userInfo'] = getUserBasicInfo($friend_uid);
         $currentUserFriendShuffle[$i]['key'] = $j;
         $currentUserFriendShuffle[$i]['id'] = $i + 1;
         if ($j == 2) {
             $j = 0;
         } else {
             $j++;
         }
         if ($i == 5) {
             break;
         }
     }
     $this->assign('currentUserFriend', $currentUserFriendShuffle);
     /*
      * get user group
      */
     $userGroupAll = getUserGroup($uid);
     $userGroup = array();
     if (empty($userGroupAll)) {
         $userGroup = $userGroupAll;
     } else {
         if ($this->userId == $uid) {
             $userGroup = $userGroupAll;
             foreach ($userGroup as &$key) {
                 $map['id'] = $key['gid'];
                 $info = D('Group')->find($map);
                 $key += array('info' => $info);
             }
         } else {
             $j = 0;
             for ($i = 0; $i < count($userGroupAll); $i++) {
                 $map['id'] = $userGroupAll[$i]['gid'];
                 $info = D('Group')->find($map);
                 if ($info['privacy'] != 'SECRET') {
                     $userGroup[$j] = $userGroupAll[$i] + array('info' => $info);
                     $j++;
                 }
             }
         }
     }
     $this->assign('userGroup', $userGroup);
     /*
      * get user wall
      */
     $listRows = 5;
     $WallCls = new WallAction();
     $Wall = $WallCls->getWall($uid, 'u', $listRows, 1);
     $wallSubheader = $WallCls->getWallHeader($Wall['count'], $listRows, $uid, 'u');
     $this->assign('wall', $Wall);
     $this->assign('wallSubheader', $wallSubheader);
     $this->display();
 }
コード例 #2
0
 public function index()
 {
     $gid = (int) $_GET['id'];
     //redirect if isnt group
     if (!$gid || !getGroupInfo($gid)) {
         $this->redirect('', '', 'home');
     }
     //get group info
     $groupInfo = getGroupInfo($gid);
     $this->assign('groupInfo', $groupInfo);
     //get members
     $groupMember = getGroupMember($gid);
     $this->assign('groupMember', $groupMember);
     /*
      * check access settings
      */
     if (empty($groupMember)) {
         if (empty($this->userId)) {
             $this->redirect('', '', 'index');
         } else {
             $this->redirect('', '', 'home');
         }
     } else {
         if (empty($this->userId)) {
             if ($groupInfo['privacy'] == 'OPEN') {
                 $groupAccess = 'GUEST';
             } else {
                 $this->redirect('', '', 'index');
             }
         } else {
             $isMember = false;
             foreach ($groupMember as $key) {
                 if ($this->userId == $key['uid']) {
                     $isMember = true;
                     $groupAccess = strtoupper($key['title']);
                     break;
                 }
             }
             if (!$isMember) {
                 if ($groupInfo['privacy'] == 'OPEN') {
                     $groupAccess = 'USER_GUEST';
                 } else {
                     if ($groupInfo['privacy'] == 'CLOSED') {
                         $this->display('closed');
                         exit;
                     } else {
                         $this->redirect('', '', 'home');
                     }
                 }
             }
         }
     }
     $this->assign('groupAccess', $groupAccess);
     /*
      * group member
      */
     if ($groupMember) {
         $count = count($groupMember);
         shuffle($groupMember);
         if ($groupAccess == 'GUEST') {
             $a1 = '';
             $a2 = '';
         } else {
             $a1 = "<a href=\"" . url('', '', 'members', '', array('id' => $gid)) . "\">";
             $a2 = "</a>";
         }
         if ($count > 8) {
             $groupMemberHeader = sprintf(L('_member_subheader1'), $a1, number_format($count), $a2, 8);
         } else {
             $groupMemberHeader = sprintf(L('_member_subheader2'), $a1, $count, $a2);
         }
         //get user info
         for ($i = 0; $i < $count; $i++) {
             $uid = $groupMember[$i]['uid'];
             $groupMemberShuffle[$i]['uid'] = $uid;
             $groupMemberShuffle[$i]['userInfo'] = getUserBasicInfo($uid);
             if ($i == 7) {
                 break;
             }
         }
         $this->assign('groupMemberShuffle', $groupMemberShuffle);
     } else {
         $groupMemberHeader = L('_member_subheader3');
     }
     $this->assign('groupMemberHeader', $groupMemberHeader);
     /*
      * mini wall
      */
     $listRows = 5;
     $WallCls = new WallAction();
     $Wall = $WallCls->getWall($gid, 'g', $listRows, 1);
     $wallSubheader = $WallCls->getWallHeader($Wall['count'], $listRows, $gid, 'g');
     $this->assign('wall', $Wall);
     $this->assign('wallSubheader', $wallSubheader);
     $this->display();
 }