You are here

function role_watchdog_report in Role Watchdog 6

Same name and namespace in other branches
  1. 6.2 role_watchdog.pages.inc \role_watchdog_report()
  2. 7.2 role_watchdog.pages.inc \role_watchdog_report()
  3. 7 role_watchdog.pages.inc \role_watchdog_report()
1 string reference to 'role_watchdog_report'
role_watchdog_menu in ./role_watchdog.module
Implementation of hook_menu().

File

./role_watchdog.pages.inc, line 94
User page callbacks for the role_watchdog module.

Code

function role_watchdog_report() {
  $output = '';
  $rows = $rows2 = array();
  $roles = user_roles();
  $header = array(
    array(
      'data' => t('Admin'),
      'style' => 'width: 20%;',
    ),
    array(
      'data' => t('Date'),
      'style' => 'width: 25%;',
    ),
    array(
      'data' => t('Role'),
      'style' => 'width: 20%;',
    ),
    array(
      'data' => t('Change'),
      'style' => 'width: 15%;',
    ),
    array(
      'data' => t('User'),
      'style' => 'width: 20%;',
    ),
  );
  $grants_query = 'SELECT rw.rid, rw.action, rw.aid, rw.stamp, u.name as name, u2.name as admin, rw.aid as uid, rw.uid as adminid FROM {role_watchdog} rw INNER JOIN {users} u ON (rw.aid = u.uid) INNER JOIN {users} u2 ON (rw.uid = u2.uid) ORDER BY rw.stamp DESC';
  $items_per_page = variable_get('role_watchdog_pager', 50);
  $result = pager_query($grants_query, $items_per_page, 0, "SELECT COUNT(*) from {role_watchdog} rw", $account->uid, $account->uid);
  $rows2 = _role_watchdog_history_rows($result, $roles, array(
    t('removed from'),
    t('added to'),
    t('requested by'),
    t('approved for'),
  ));
  if (sizeof($rows2)) {
    $output .= theme('table', $header, $rows2, array(
      'style' => 'width: 99%;',
    ));
    if ($pager = theme('pager', NULL, $items_per_page, 0)) {
      $output .= $pager;
    }
  }
  return $output ? $output : t('No role grants made.');
}