You are here

function user_filters in Drupal 5

Same name and namespace in other branches
  1. 6 modules/user/user.module \user_filters()
  2. 7 modules/user/user.module \user_filters()

List user administration filters that can be applied.

3 calls to user_filters()
user_build_filter_query in modules/user/user.module
Build query for user administration filters based on session.
user_filter_form in modules/user/user.module
Return form for user administration filters.
user_filter_form_submit in modules/user/user.module
Process result from user administration filter form.

File

modules/user/user.module, line 2508
Enables the user registration and login system.

Code

function user_filters() {

  // Regular filters
  $filters = array();
  $roles = user_roles(1);
  unset($roles[DRUPAL_AUTHENTICATED_RID]);

  // Don't list authorized role.
  if (count($roles)) {
    $filters['role'] = array(
      'title' => t('role'),
      'where' => "ur.rid = %d",
      'options' => $roles,
    );
  }
  $options = array();
  $t_module = t('module');
  foreach (module_list() as $module) {
    if ($permissions = module_invoke($module, 'perm')) {
      asort($permissions);
      foreach ($permissions as $permission) {
        $options["{$module} {$t_module}"][$permission] = t($permission);
      }
    }
  }
  ksort($options);
  $filters['permission'] = array(
    'title' => t('permission'),
    'join' => 'LEFT JOIN {permission} p ON ur.rid = p.rid',
    'where' => " ((p.perm IS NOT NULL AND p.perm LIKE '%%%s%%') OR u.uid = 1) ",
    'options' => $options,
  );
  $filters['status'] = array(
    'title' => t('status'),
    'where' => 'u.status = %d',
    'options' => array(
      1 => t('active'),
      0 => t('blocked'),
    ),
  );
  return $filters;
}