You are here

function referral_admin_view_details in User Referral 6

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

File

./referral.module, line 370

Code

function referral_admin_view_details() {
  $uid = (int) arg(4);
  $ref_user = user_load(array(
    'uid' => $uid,
  ));
  $header = array(
    array(
      'data' => t('User'),
      'field' => 'u.name',
    ),
    array(
      'data' => t('Flag'),
      'field' => 'r.flag',
    ),
    array(
      'data' => t('Roles'),
    ),
    array(
      'data' => t('Time'),
      'field' => 'r.created',
      'sort' => 'desc',
    ),
    array(
      'data' => t('IP Address'),
      'field' => 'r.host',
    ),
    array(
      'data' => t('Referrer'),
      'field' => 'r.http_referer',
    ),
  );
  $sql = 'SELECT u.uid, r.flag, u.name, r.created, r.host, r.http_referer
    FROM {referral} r INNER JOIN {users} u USING(uid)
    WHERE r.referral_uid = %d
    AND u.status = 1' . tablesort_sql($header);
  $result = pager_query($sql, REFERRAL_PAGE_COUNT, 0, NULL, $uid);
  while ($data = db_fetch_object($result)) {
    $referer = check_plain(_referral_column_width($data->http_referer));
    $rows[] = array(
      array(
        'data' => l($data->name, "user/{$data->uid}"),
      ),
      array(
        'data' => $data->flag ? 'Yes' : 'No',
      ),
      array(
        'data' => implode(',', _referral_get_user_roles($data->uid)),
      ),
      array(
        'data' => format_date($data->created, 'custom', REFERRAL_DATE_FORMAT),
      ),
      array(
        'data' => l($data->host, "http://whois.domaintools.com/{$data->host}"),
      ),
      array(
        'data' => l($referer, $data->http_referer),
      ),
    );
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('No data.'),
        'colspan' => '6',
      ),
    );
  }
  $pager = theme('pager', NULL, REFERRAL_PAGE_COUNT, 0);
  if (!empty($pager)) {
    $rows[] = array(
      array(
        'data' => $pager,
        'colspan' => '6',
      ),
    );
  }
  return theme('table', $header, $rows);
}