function user_build_filter_query
Extends a query object for user administration filters based on session.
Parameters
$query: Query object that should be filtered.
2 calls to user_build_filter_query()
- database_test_theme_tablesort in modules/
simpletest/ tests/ database_test.module - Output a form without setting a header sort.
- user_admin_account in modules/
user/ user.admin.inc - Form builder; User administration page.
File
-
modules/
user/ user.module, line 3546
Code
function user_build_filter_query(SelectQuery $query) {
$filters = user_filters();
// Extend Query with filter conditions.
foreach (isset($_SESSION['user_overview_filter']) ? $_SESSION['user_overview_filter'] : array() as $filter) {
list($key, $value) = $filter;
// This checks to see if this permission filter is an enabled permission for
// the authenticated role. If so, then all users would be listed, and we can
// skip adding it to the filter query.
if ($key == 'permission') {
$account = new stdClass();
$account->uid = 'user_filter';
$account->roles = array(
DRUPAL_AUTHENTICATED_RID => 1,
);
if (user_access($value, $account)) {
continue;
}
$users_roles_alias = $query->join('users_roles', 'ur', '%alias.uid = u.uid');
$permission_alias = $query->join('role_permission', 'p', $users_roles_alias . '.rid = %alias.rid');
$query->condition($permission_alias . '.permission', $value);
}
elseif ($key == 'role') {
$users_roles_alias = $query->join('users_roles', 'ur', '%alias.uid = u.uid');
$query->condition($users_roles_alias . '.rid', $value);
}
else {
$query->condition($filters[$key]['field'], $value);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.