예제 #1
0
 /**
  * Shows the user profile
  *
  * @param int    $id       User id
  * @param string $username User name
  */
 public function viewAction($id, $username)
 {
     $user = $id ? Users::findFirstById($id) : Users::findFirstByLogin($username);
     if (!$user) {
         $user = Users::findFirstByName($username);
     }
     if (!$user) {
         $this->flashSession->error('The user does not exist');
         $this->response->redirect();
         return;
     }
     $this->view->setVar('user', $user);
     $parametersNumberPosts = ['users_id = ?0 AND deleted = 0', 'bind' => [$user->id]];
     $this->view->setVar('numberPosts', Posts::count($parametersNumberPosts));
     $parametersNumberReplies = ['users_id = ?0', 'bind' => [$user->id]];
     $this->view->setVar('numberReplies', PostsReplies::count($parametersNumberReplies));
     $parametersActivities = ['users_id = ?0', 'bind' => [$user->id], 'order' => 'created_at DESC', 'limit' => 15];
     $this->view->setVar('activities', Activities::find($parametersActivities));
     $users = Users::find(['columns' => 'id', 'conditions' => 'karma != 0', 'order' => 'karma DESC']);
     $ranking = count($users);
     foreach ($users as $position => $everyUser) {
         if ($everyUser->id == $user->id) {
             $ranking = $position + 1;
             break;
         }
     }
     $this->gravatar->setSize(220);
     $this->view->setVars(['ranking' => $ranking, 'total_ranking' => count($users), 'avatar' => $this->gravatar->getAvatar($user->email)]);
     $this->tag->setTitle('Profile - ' . $this->escaper->escapeHtml($user->name));
 }
예제 #2
0
 /**
  * Shows the user profile
  */
 public function userAction($id, $username)
 {
     if ($id) {
         $user = Users::findFirstById($id);
     } else {
         $user = Users::findFirstByLogin($username);
         if (!$user) {
             $user = Users::findFirstByName($username);
         }
     }
     if (!$user) {
         $this->flashSession->error('The user does not exist');
         return $this->response->redirect();
     }
     $this->view->user = $user;
     $parametersNumberPosts = array('users_id = ?0 AND deleted = 0', 'bind' => array($user->id));
     $this->view->numberPosts = Posts::count($parametersNumberPosts);
     $parametersNumberReplies = array('users_id = ?0', 'bind' => array($user->id));
     $this->view->numberReplies = PostsReplies::count($parametersNumberReplies);
     $parametersActivities = array('users_id = ?0', 'bind' => array($user->id), 'order' => 'created_at DESC', 'limit' => 15);
     $this->view->activities = Activities::find($parametersActivities);
     $users = Users::find(array('columns' => 'id', 'conditions' => 'karma != 0', 'order' => 'karma DESC'));
     $ranking = count($users);
     foreach ($users as $position => $everyUser) {
         if ($everyUser->id == $user->id) {
             $ranking = $position + 1;
             break;
         }
     }
     $this->view->ranking = $ranking;
     $this->view->total_ranking = count($users);
     $this->tag->setTitle('Profile - ' . $this->escaper->escapeHtml($user->name));
 }
예제 #3
0
 /**
  * Shows the latest activity on the forum
  */
 public function activityAction($offset = 0)
 {
     $parameters = ['order' => 'created_at DESC', 'limit' => ['number' => self::POSTS_IN_PAGE, 'offset' => 0]];
     $this->view->setVars(['total' => Activities::count(), 'activities' => Activities::find($parameters)]);
     $this->tag->setTitle('Recent Activity on the Forum');
 }