function referral_admin_view_roles in User Referral 7
Same name and namespace in other branches
- 5 referral.module \referral_admin_view_roles()
- 6 referral.module \referral_admin_view_roles()
1 string reference to 'referral_admin_view_roles'
- referral_menu in ./
referral.module - Implements hook_menu().
File
- ./
referral.module, line 622 - The referral module.
Code
function referral_admin_view_roles() {
$uid = (int) arg(4);
$header = array(
array(
'data' => t('User'),
'field' => 'u.name',
),
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',
),
);
$select_condition = db_select('users', 'u')
->fields('u', array(
'uid',
))
->condition('status', 1);
$query = db_select('referral', 'r');
$query
->innerJoin('users', 'u', 'u.uid = r.uid');
$result = $query
->fields('u', array(
'name',
'uid',
))
->fields('r', array(
'created',
'host',
'http_referer',
))
->condition('r.referral_uid', $uid)
->condition('r.flag', 0)
->condition('r.uid', $select_condition, 'IN')
->extend('PagerDefault')
->range(0, REFERRAL_PAGE_COUNT)
->extend('TableSort')
->orderByHeader($header)
->execute();
/*$sql = 'SELECT u.uid, u.name, r.created, r.host, r.http_referer
FROM {referral} r INNER JOIN {users} u USING(uid)
WHERE r.referral_uid = %d
AND r.flag = 0
AND r.uid IN
( SELECT u.uid FROM {users} u WHERE status = 1 )' . tablesort_sql($header);*/
$rows = array();
foreach ($result as $data) {
$referer = check_plain(_referral_column_width($data->http_referer));
$rows[] = array(
array(
'data' => l($data->name, "user/{$data->uid}"),
),
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' => '5',
),
);
}
$pager = theme('pager', array(
'tags' => array(),
));
if (!empty($pager)) {
$rows[] = array(
array(
'data' => $pager,
'colspan' => '5',
),
);
}
$user = user_load($uid);
$output = t('Unflagged referral users with roles for: @user', array(
'@user' => l($user->name, "user/{$user->uid}"),
));
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
));
return $output;
}