function og_role_watchdog_history in Role Watchdog 7.2
Same name and namespace in other branches
- 6.2 modules/og_role_watchdog/og_role_watchdog.pages.inc \og_role_watchdog_history()
- 6 modules/og_role_watchdog/og_role_watchdog.pages.inc \og_role_watchdog_history()
- 7 modules/og_role_watchdog/og_role_watchdog.pages.inc \og_role_watchdog_history()
Display tab page from menu callback.
Parameters
$account: User object.
1 string reference to 'og_role_watchdog_history'
- og_role_watchdog_menu_alter in modules/
og_role_watchdog/ og_role_watchdog.module - Implementation of hook_menu_alter
File
- modules/
og_role_watchdog/ og_role_watchdog.pages.inc, line 14 - User page callbacks for the role_watchdog module.
Code
function og_role_watchdog_history($account) {
$output = '';
$rows = $rows2 = array();
$roles = user_roles();
$header = array(
array(
'data' => t('Date'),
'style' => 'width: 25%;',
),
array(
'data' => t('Group'),
'style' => 'width: 20%;',
),
array(
'data' => t('Role'),
'style' => 'width: 20%;',
),
array(
'data' => t('Change'),
'style' => 'width: 15%;',
),
array(
'data' => t('User'),
'style' => 'width: 20%;',
),
);
$view_profile = user_access('access user profiles');
$query = db_select('role_watchdog', 'rw');
$query
->innerJoin('users', 'u', 'rw.uid = u.uid');
$query
->leftJoin('og_role_watchdog', 'orw', 'orw.hid = rw.hid');
$query
->addField('orw', 'rid', 'orid');
$result = $query
->extend('PagerDefault')
->limit(variable_get('role_watchdog_pager', 50))
->fields('rw', array(
'hid',
'rid',
'uid',
'action',
'stamp',
))
->fields('u', array(
'name',
))
->fields('orw', array(
'gid',
))
->condition('rw.aid', $account->uid)
->orderBy('rw.stamp', 'DESC')
->execute()
->fetchAllAssoc('hid');
$actions = array(
t('removed by'),
t('added by'),
t('requested for'),
t('approved by'),
t('blocked by'),
t('unblocked by'),
t('rejected by'),
);
foreach ($result as $hid => $row) {
list($group_name, $role) = _og_role_watchdog_row_group_name($row->gid, $row->rid, $row->orid, $roles);
$rows[] = array(
format_date($row->stamp),
$group_name,
$role,
$actions[$row->action],
$view_profile ? l($row->name, 'user/' . $row->uid) : $row->name,
);
}
if (sizeof($rows)) {
$output .= theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'style' => 'width: 99%;',
),
));
$output .= theme('pager', array(
'tags' => NULL,
));
}
return $output ? $output : t('No role history found.');
}