You are here

function referral_admin_view_unflagged in User Referral 6

Same name and namespace in other branches
  1. 5 referral.module \referral_admin_view_unflagged()
  2. 7 referral.module \referral_admin_view_unflagged()
1 string reference to 'referral_admin_view_unflagged'
referral_menu in ./referral.module

File

./referral.module, line 409

Code

function referral_admin_view_unflagged() {
  $header = array(
    array(
      'data' => t('Referring User'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('# Unflagged'),
      'field' => 'cnt',
    ),
    array(
      'data' => t('Last'),
      'field' => 'last',
      'sort' => 'desc',
    ),
    array(
      'data' => t('Operations'),
    ),
  );
  $sql = 'SELECT r.referral_uid, u.name, COUNT(*) AS cnt, MAX(r.created) AS last
    FROM {referral} r INNER JOIN {users} u ON(r.referral_uid = u.uid)
    WHERE r.flag = 0
    AND r.uid IN
    ( SELECT u.uid FROM {users} u WHERE status = 1 )
    GROUP BY r.referral_uid' . tablesort_sql($header);
  $result = pager_query($sql, REFERRAL_PAGE_COUNT);
  while ($data = db_fetch_object($result)) {
    $rows[] = array(
      array(
        'data' => l($data->name, "user/{$data->referral_uid}"),
      ),
      array(
        'data' => $data->cnt,
      ),
      array(
        'data' => format_date($data->last, 'custom', REFERRAL_DATE_FORMAT),
      ),
      array(
        'data' => l(t('details'), "admin/reports/referral/roles/{$data->referral_uid}") . ' | ' . l(t('flag'), "admin/referral/flag/{$data->referral_uid}"),
      ),
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No data.'),
        'colspan' => '4',
      ),
    );
  }
  $pager = theme('pager', NULL, REFERRAL_PAGE_COUNT, 0);
  if (!empty($pager)) {
    $rows[] = array(
      array(
        'data' => $pager,
        'colspan' => '4',
      ),
    );
  }
  return theme('table', $header, $rows);
}