You are here

function theme_invite_stats_ranking in Invite 5.2

Same name and namespace in other branches
  1. 5 invite_stats.module \theme_invite_stats_ranking()
  2. 6.2 invite_stats.module \theme_invite_stats_ranking()
  3. 7.2 modules/invite_stats/invite_stats.module \theme_invite_stats_ranking()

Theme the Top inviters/user rank block.

Parameters

$inviters: An array of arrays consisting of the user id and invite count.

$rank: The rank of the first inviter in the list.

2 theme calls to theme_invite_stats_ranking()
invite_stats_display_top_inviters in ./invite_stats.module
Render the "Top inviters" block.
invite_stats_display_user_rank in ./invite_stats.module
Render the displayed user's rank block.

File

./invite_stats.module, line 170
Displays some statistics about sent invitations.

Code

function theme_invite_stats_ranking($inviters, $rank = 1) {
  if ($inviters) {
    global $user;
    $header = array();
    $rows = array();
    $prev_count = 0;
    foreach ($inviters as $inviter) {
      $row = array();
      if ($inviter->count != $prev_count) {
        $row[] = array(
          'data' => "{$rank}.",
          'style' => 'width: 5%',
        );
        $prev_count = $inviter->count;
        $rank++;
      }
      else {
        $row[] = '';
      }
      $row[] = theme('username', user_load(array(
        'uid' => $inviter->uid,
      )));
      $row[] = array(
        'data' => theme('invite_stats_count', $inviter->count),
        'align' => 'right',
      );
      $rows[] = array(
        'data' => $row,
        'class' => $inviter->uid == $user->uid ? 'current-user' : '',
      );
    }
    return theme('table', $header, $rows, array(
      'id' => 'invite-ranks',
    ));
  }
}