You are here

public static function UserRestrictions::getRestrictionTable in User restrictions 7

1 call to UserRestrictions::getRestrictionTable()
user_restrictions_ui_overview_form in ./user_restrictions_ui.admin.inc
Form builder for the list of user restrictions.

File

./user_restrictions.classes.inc, line 161
Contains the classes used by the User restrictions module.

Class

UserRestrictions
The main class used by the User Restrictions module.

Code

public static function getRestrictionTable($header, $destination) {
  $access_types = self::getTypeOptions();
  $access_statuses = self::getStatusOptions();
  $rules = db_select('user_restrictions', 'ur')
    ->fields('ur', array(
    'urid',
    'type',
    'status',
    'mask',
    'expire',
  ))
    ->condition(db_or()
    ->condition('expire', REQUEST_TIME, '>=')
    ->condition('expire', 0))
    ->extend('PagerDefault')
    ->limit(50)
    ->extend('TableSort')
    ->orderByHeader($header)
    ->execute();
  $rows = array();
  foreach ($rules as $rule) {
    $rows[$rule->urid]['status'] = $access_statuses[$rule->status];
    $rows[$rule->urid]['type'] = $access_types[$rule->type];
    $rows[$rule->urid]['mask'] = check_plain($rule->mask);
    $rows[$rule->urid]['expire'] = $rule->expire ? format_date($rule->expire) : t('never');
    $rows[$rule->urid]['operations'] = array(
      'data' => array(
        '#theme' => 'links__user_restrictions_ui_rule_operations',
        '#links' => array(
          'edit' => array(
            'title' => t('edit'),
            'href' => 'admin/config/people/user-restrictions/' . $rule->urid . '/edit',
            'query' => $destination,
            '#attributes' => array(
              'class' => array(
                'links',
                'inline',
              ),
            ),
          ),
          'delete' => array(
            'title' => t('delete'),
            'href' => 'admin/config/people/user-restrictions/' . $rule->urid . '/delete',
            'query' => $destination,
            '#attributes' => array(
              'class' => array(
                'links',
                'inline',
              ),
            ),
          ),
        ),
      ),
    );
  }
  return $rows;
}