/** * View a users profile. * * @return void * @author Merrick Christensen */ public function action_index($user = NULL) { $this->template->content = View::factory('profile/index'); $this->template->top = View::factory('profile/topper'); $this->template->styles = array('public/js/vendor/rating/jquery.rating.css' => 'screen', 'public/js/vendor/datepicker/jquery-ui-1.8.5.custom.css' => 'screen'); $this->template->scripts = array('public/js/vendor/jquery.tools.min.js', 'public/js/vendor/jquery-ui-1.8.5.custom.min.js', "public/js/vendor/jquery.scrollTo-min.js", 'public/js/vendor/jquery.jcarousel.js', "public/js/profile/profile.js"); $feed = array(); // If no user is requested, use their own. if ($user === NULL) { if ($this->user->id) { if (empty($this->user->lastlive)) { $this->user->lastlive = Date('Y-m-d H:i:s'); $this->user->save(); } $gameUser = Helper_Game::getUser($this->user->id); $account = $this->user; $pageData = array('user' => $account, 'owner' => $this->user, 'user_owns_page' => TRUE, 'is_approved' => Helper_Account::is_approved($account), 'isaFan' => TRUE, 'loggedin' => TRUE, 'reel' => Reel_Owner::factory(ORM::factory('photo')->where('user_id', '=', $this->user->id)->or_where('moderation_status_id', '=', '1')->order_by("created", "DESC")), 'achievements' => $gameUser->achievements, 'following' => $gameUser->following, 'followers' => $gameUser->followers); $feed = Helper_Game::activities($this->user->id); } else { Message::set(Message::NOTICE, 'You must be logged in to view your profile!'); Request::instance()->redirect('/'); } } else { if (is_numeric($user)) { $account = ORM::factory('user')->where('id', '=', $user)->find(); } else { $account = ORM::factory('user')->where('vanity_url', '=', $user)->find(); } if ($account->loaded()) { if (Helper_Account::is_approved($account)) { $gameUser = Helper_Game::getUser($account->id); $pageData = array('user' => $account, 'owner' => $this->user, 'user_owns_page' => $account->id == $this->user->id, 'is_approved' => true, 'isaFan' => $this->user->id ? Helper_Game::getUser($this->user->id)->isFollowing($account->id) : false, 'loggedin' => $this->user->id !== null, 'reel' => Reel::factory(ORM::factory('photo')->where('user_id', '=', $account->id)->order_by("created", "DESC")), 'moderation_reel' => NULL, 'achievements' => $gameUser->achievements); $feed = Helper_Game::myActivities($account->id); } else { Message::set(Message::NOTICE, 'User has not been approved!'); Request::instance()->redirect('/'); } } else { Message::set(Message::NOTICE, 'User does not exist!'); Request::instance()->redirect('/'); } } $this->template->content->feed = ''; $feeds = self::feedViews($feed); foreach ($feeds as $f) { $this->template->content->feed .= $f; } $this->template->content->set($pageData); $this->template->top->set($pageData); $this->template->top->photos = $account->viewablePhotos()->order_by(DB::expr('RAND()'))->limit(30)->find_all(); }