You are here

function og_role_watchdog_grants in Role Watchdog 7.2

Same name and namespace in other branches
  1. 6.2 modules/og_role_watchdog/og_role_watchdog.pages.inc \og_role_watchdog_grants()
  2. 6 modules/og_role_watchdog/og_role_watchdog.pages.inc \og_role_watchdog_grants()
  3. 7 modules/og_role_watchdog/og_role_watchdog.pages.inc \og_role_watchdog_grants()
1 string reference to 'og_role_watchdog_grants'
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 77
User page callbacks for the role_watchdog module.

Code

function og_role_watchdog_grants($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.aid = 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',
    'action',
    'aid',
    'stamp',
  ))
    ->fields('u', array(
    'name',
  ))
    ->fields('orw', array(
    'gid',
  ))
    ->condition('rw.uid', $account->uid)
    ->orderBy('rw.stamp', 'DESC')
    ->execute()
    ->fetchAllAssoc('hid');
  $actions = array(
    t('removed from'),
    t('added to'),
    t('requested by'),
    t('approved for'),
    t('blocked'),
    t('unblocked'),
    t('rejected for'),
  );
  foreach ($result as $hid => $row) {
    list($group_name, $role) = _og_role_watchdog_row_group_name($row->gid, $row->rid, $row->orid, $roles);
    $rows2[] = array(
      format_date($row->stamp),
      $group_name,
      $role,
      $actions[$row->action],
      $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.');
}