You are here

function theme_invite_stats_ranking in Invite 7.2

Same name and namespace in other branches
  1. 5.2 invite_stats.module \theme_invite_stats_ranking()
  2. 5 invite_stats.module \theme_invite_stats_ranking()
  3. 6.2 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 modules/invite_stats/invite_stats.module
Render the "Top inviters" block.
invite_stats_display_user_rank in modules/invite_stats/invite_stats.module
Render the displayed user's rank block.

File

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

Code

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