function index($id = null) { //name of folder and file $u = new Login(); $requestController = new Friend_Request(); // only me get access right now $friendCon = new Friend(); $this->view->styles = array(); array_push($this->view->styles, URL . "/Public/bootstrap/css/styles.css"); array_push($this->view->styles, URL . "/Public/bootstrap/css/post.css"); if ($id == null || $id == Session::get('id')) { $this->view->me = true; $this->view->id = Session::get('id'); $this->view->access = true; $this->view->user = $u::getUser(Session::get('id')); $this->view->posts = $this->getPosts(Session::get('id')); } else { $this->view->me = false; if ($friendCon->isFriend(Session::get('id'), $id)) { $this->view->access = true; $this->view->posts = $this->getPosts($id); } else { $this->view->access = false; $this->view->requested = $requestController->isRequested($id); $this->view->posts = $this->getPosts($id, "public"); } $this->view->id = $id; $this->view->user = $u::getUser($id); } $this->view->render('post/index'); }
public function actionView($userId, $part = 'joins') { $user = User::get($userId); RAssert::not_null($user); $data = array('user' => $user, 'part' => $part); if (Rays::isLogin()) { $loginUser = Rays::user(); $friend = new Friend(); $friend->uid = Rays::user()->id; $friend->fid = $user->id; $data['canAdd'] = $loginUser->id != $user->id && !Friend::isFriend($loginUser->id, $userId); $data['canCancel'] = $loginUser->id != $user->id && !$data['canAdd']; } $page = $this->getPage("page"); $pageSize = $this->getPageSize("pageSize", 10); $count = 0; switch ($part) { case 'joins': $pageSize = $this->getPageSize("pageSize", 5); $data['userGroup'] = GroupUser::getGroups(GroupUser::find("userId", $userId)->join("group")->order_desc("groupId")->range(($page - 1) * $pageSize, $pageSize)); $count = User::countGroups($userId); break; case 'posts': $data['postTopics'] = Topic::find("userId", $userId)->join("group")->order_desc("id")->range(($page - 1) * $pageSize, $pageSize); $count = User::countPosts($userId); break; case 'likes': $data['likeTopics'] = RatingPlus::getUserPlusTopics($userId, ($page - 1) * $pageSize, $pageSize); $count = RatingPlus::countUserPostsPlus($userId); break; case 'profile': break; default: return; } if (Rays::isAjax()) { echo empty($data['userGroup']) ? 'nomore' : $this->renderPartial("_common._groups_list", ["groups" => $data['userGroup']], true); exit; } if ($part == "posts" || $part == "likes") { if ($count > $pageSize) { $pager = new RPager("page", $count, $pageSize, RHtml::siteUrl("user/view/" . $userId . "/" . $part), $page); $data['pager'] = $pager->showPager(); } } if ($part == "joins") { $this->addCss('/public/css/group.css'); $this->addJs('/public/js/masonry.pkgd.min.js'); } //$this->addJs("/public/js/jquery.dotdotdot.min.js"); $this->setHeaderTitle($user->name); $this->render('view', $data, false); // Need to be complete because the codes below will increase the counter every time this page is viewed $counter = new Counter(); $counter->increaseCounter($user->id, User::ENTITY_TYPE); }