You are here

function og_role_watchdog_history in Role Watchdog 6

Same name and namespace in other branches
  1. 6.2 modules/og_role_watchdog/og_role_watchdog.pages.inc \og_role_watchdog_history()
  2. 7.2 modules/og_role_watchdog/og_role_watchdog.pages.inc \og_role_watchdog_history()
  3. 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%;',
    ),
  );
  $history_query = 'SELECT rw.rid, orw.gid, rw.action, rw.uid, rw.stamp, u.name, n.title, n.nid FROM {role_watchdog} rw LEFT JOIN {og_role_watchdog} orw ON (orw.hid = rw.hid) LEFT JOIN {node} n ON (orw.gid = n.nid) INNER JOIN {users} u ON (rw.uid = u.uid) WHERE rw.aid=%d ORDER BY rw.stamp DESC';
  $items_per_page = variable_get('role_watchdog_pager', 50);
  $result = pager_query($history_query, $items_per_page, 0, "SELECT COUNT(*) from {role_watchdog} rw WHERE rw.aid=%d", $account->uid);
  $rows = _og_role_watchdog_history_rows($result, $roles, array(
    t('removed by'),
    t('added by'),
    t('requested by'),
    t('approved for'),
  ));
  if (sizeof($rows)) {
    $output .= '<h3>' . t('Role History') . '</h3>' . theme('table', $header, $rows, array(
      'style' => 'width: 99%;',
    ));
    if ($pager = theme('pager', NULL, $items_per_page, 0)) {
      $output .= $pager;
    }
  }
  return $output ? $output : t('No role history found.');
}