You are here

function role_watchdog_report in Role Watchdog 7

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

File

./role_watchdog.pages.inc, line 122
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%;',
    ),
  );
  $query = db_select('role_watchdog', 'rw');
  $query
    ->innerJoin('users', 'u', 'rw.aid = u.uid');
  $query
    ->innerJoin('users', 'u2', 'rw.uid = u2.uid');
  $query
    ->addField('u2', 'name', 'admin');
  $query
    ->addField('rw', 'uid', 'adminid');
  $query
    ->addField('rw', 'aid', '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.rid', ROLE_WATCHDOG_NO_ROLE, '<>')
    ->orderBy('rw.stamp', 'DESC')
    ->execute()
    ->fetchAllAssoc('hid');
  $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', array(
      'header' => $header,
      'rows' => $rows2,
      'attributes' => array(
        'style' => 'width: 99%;',
      ),
    ));
    $output .= theme('pager', array(
      'tags' => NULL,
    ));
  }
  return $output ? $output : t('No role grants made.');
}