Exemple #1
0
 /**
  * Get the number of items posted by this user for each catagory
  *
  * @return array with the activity for each content type.
  */
 public function getActivity()
 {
     // Get the number of questions posted
     $question = new \Bjurnemark\Question\Question();
     $question->setDI($this->di);
     $numQuestions = $question->getUserStats($this->id);
     // Get the number of answers posted
     $answer = new \Bjurnemark\Answer\Answer();
     $answer->setDI($this->di);
     $numAnswers = $answer->getUserStats($this->id);
     // Get the number of comments posted
     $comment = new \Bjurnemark\Comment\Comment();
     $comment->setDI($this->di);
     $numComments = $comment->getUserStats($this->id);
     $activity = ['numQuestions' => $numQuestions['count'], 'numAnswers' => $numAnswers['count'], 'numComments' => $numComments['count'], 'points' => $numQuestions['count'] * VAL_QUESTION + $numAnswers['count'] * VAL_ANSWER + $numComments['count'] * VAL_COMMENT + ($numQuestions['score'] + $numAnswers['score'] + $numComments['score']) * VAL_SCORE];
     return $activity;
 }
 /**
  * View active users.
  *
  * @return void
  */
 public function activeAction()
 {
     // Get a handle to a question object
     $question = new \Bjurnemark\Question\Question();
     $question->setDI($this->di);
     // Get the ids of the most active users
     $userIds = $question->getActiveUsers();
     $data = array();
     // Fetch each user and add the gravatar image
     foreach ($userIds as $id) {
         $this->user->find($id);
         $gravatar = $this->user->getGravatar(60);
         $this->user->image = "<img class='login-logo' src='{$gravatar}' alt='account'/>";
         // Clone user (otherwise passed by reference)
         $data[] = clone $this->user;
     }
     $this->views->add('user/list', ['data' => $data, 'title' => "Frågvisaste användarna"]);
 }