function role_watchdog_grants in Role Watchdog 7
Same name and namespace in other branches
- 6.2 role_watchdog.pages.inc \role_watchdog_grants()
- 6 role_watchdog.pages.inc \role_watchdog_grants()
- 7.2 role_watchdog.pages.inc \role_watchdog_grants()
1 string reference to 'role_watchdog_grants'
- role_watchdog_menu in ./
role_watchdog.module - Implements hook_menu().
File
- ./
role_watchdog.pages.inc, line 68 - User page callbacks for the role_watchdog module.
Code
function role_watchdog_grants($account) {
$output = '';
$rows = $rows2 = array();
$roles = user_roles();
$view_profile = user_access('access user profiles');
$header = array(
array(
'data' => t('Date'),
'style' => 'width: 25%;',
),
array(
'data' => t('Role'),
'style' => 'width: 30%;',
),
array(
'data' => t('Change'),
'style' => 'width: 15%;',
),
array(
'data' => t('User'),
'style' => 'width: 40%;',
),
);
$query = db_select('role_watchdog', 'rw');
$query
->innerJoin('users', 'u', 'rw.aid = u.uid');
$result = $query
->extend('PagerDefault')
->limit(variable_get('role_watchdog_pager', 50))
->fields('rw', array(
'hid',
'rid',
'action',
'aid',
'stamp',
))
->fields('u', array(
'name',
))
->condition('rw.uid', $account->uid)
->condition('rw.rid', ROLE_WATCHDOG_NO_ROLE, '<>')
->orderBy('rw.stamp', 'DESC')
->execute()
->fetchAllAssoc('hid');
foreach ($result as $hid => $row) {
$rows2[] = array(
format_date($row->stamp),
$roles[$row->rid],
$row->action ? t('added to') : t('removed from'),
$view_profile ? l($row->name, 'user/' . $row->aid) : $row->name,
);
}
if (sizeof($rows2)) {
$output .= theme('table', array(
'header' => $header,
'rows' => $rows2,
'attributes' => array(
'style' => 'width: 99%;',
),
));
$output .= theme('pager', array(
'tags' => NULL,
));
}
return $output ? $output : t('No role grants made.');
}