Beispiel #1
0
 public function view($username)
 {
     $user = get_user($username);
     if ($user) {
         $this->data['page']['title'] = "Profile of " . $user->row('username') . "";
         $this->data['user'] = array('username' => $user->row('username'), 'email' => $user->row('email'), 'register_date' => $user->row('register_date'), 'karma' => get_user_karma($user->row('id')), 'average_karma' => calculate_average_karma($user->row('id')), 'average_submissions' => calculate_average_submissions($user->row('id')), 'meta' => $this->wolfauth->get_user_meta($user->row('id')));
         $this->parser->parse('profile', $this->data);
     }
 }
Beispiel #2
0
 /**
  * Calculate Average KArma
  * 
  * Calculates a users average karma score
  * 
  * @param int $user_id
  * 
  */
 public function calculate_average_karma($user_id)
 {
     $user = get_user_by_id($user_id);
     $karma = get_user_karma($user_id);
     if ($user) {
         $days = ceil(abs($user->row('register_date') - now()) / 86400);
         $average = round($karma / $days, 2);
         return $average;
     }
 }