You are here

function _invite_admin_overview in Invite 5.2

Return a list of all users that have invited someone.

1 call to _invite_admin_overview()
invite_admin_overview in ./invite.module
Menu callback; return a list of all users that have invited someone.

File

./invite_admin.inc, line 172
Administration functions for invite module.

Code

function _invite_admin_overview() {
  $header = array(
    array(
      'data' => t('Username'),
      'field' => 'u1.name',
      'sort' => 'asc',
    ),
    array(
      'data' => t('Total'),
      'field' => 'invites',
    ),
    t('Successful'),
    t('Pending'),
    t('Expired'),
    t('Remaining'),
    t('Operations'),
  );
  $now = time();
  $filter = $filter_args = $query = NULL;
  $output = drupal_get_form('invite_admin_filter_form');
  if (isset($_SESSION[INVITE_ADMIN_SESSION])) {
    $filter = " INNER JOIN {users} u2 ON u2.uid = i.invitee WHERE LOWER(u2.name) LIKE LOWER('%s%%')";
    $filter_args = $_SESSION[INVITE_ADMIN_SESSION];
    $query = 'filter=' . $filter_args;
    unset($_SESSION[INVITE_ADMIN_SESSION]);
  }
  $sql = "SELECT i.uid, u1.name, COUNT(*) AS invites, u1.data FROM {invite} i INNER JOIN {users} u1 ON u1.uid = i.uid" . $filter . " GROUP BY i.uid, u1.name, u1.data";
  $sql .= tablesort_sql($header);
  $count_sql = "SELECT COUNT(DISTINCT i.uid) FROM {invite} i" . $filter;
  $result = pager_query($sql, 50, 0, $count_sql, $filter_args);
  $rows = array();
  while ($row = db_fetch_object($result)) {
    $cells = array();
    $cells[] = theme('username', $row);
    $cells[] = $row->invites;
    $cells[] = invite_count($row->uid, 'accepted');
    $cells[] = invite_count($row->uid, 'pending');
    $cells[] = invite_count($row->uid, 'expired');
    $remaining = invite_get_remaining_invites($row);
    $cells[] = $remaining == INVITE_UNLIMITED ? '∞' : $remaining;
    $cells[] = l(t('details'), "admin/user/invite/details/{$row->uid}", array(), $query);
    $rows[] = $cells;
  }
  $output .= theme('table', $header, $rows, array(
    'id' => 'invite',
  ));
  if (!$rows) {
    $output .= t('No inviters found.');
  }
  else {
    $output .= theme('pager', array(), 50, 0);
  }
  return $output;
}