You are here

function user_stats_token_values in User Stats 7

Same name and namespace in other branches
  1. 5 user_stats.module \user_stats_token_values()
  2. 6 user_stats.module \user_stats_token_values()

Implements hook_token_values().

File

./user_stats.module, line 644
User Stats provides commonly requested user statistics for themers. These are:

Code

function user_stats_token_values($type, $object = NULL) {
  switch ($type) {
    case 'user':
    case 'all':
      if (isset($object)) {

        // Think this is sometimes an array (please raise this as an issue if wrong).
        $object = (object) $object;
        $uid = $object->uid;
      }
      else {
        global $user;
        $uid = $user->uid;
      }

      // Check_plain added as per Greggles suggestion: http://drupal.org/node/166305#comment-665874
      $values['reg-days'] = check_plain(user_stats_get_stats('reg_days', $uid));
      $values['login-days'] = check_plain(user_stats_get_stats('login_days', $uid));
      $values['post-days'] = check_plain(user_stats_get_stats('post_days', $uid));
      $values['post-count'] = check_plain(user_stats_get_stats('post_count', $uid));
      $values['ip-address'] = check_plain(user_stats_get_stats('ip_address', $uid));
      $values['login-count'] = check_plain(user_stats_get_stats('login_count', $uid));
      return $values;
  }
}