Commit 2c4e8fe6 authored by catch's avatar catch

Issue #2024985 by tim.plunkett: Remove obsolete user_build_filter_query().

parent 93ea9a47
......@@ -213,7 +213,6 @@ function database_test_theme_tablesort($form, &$form_state) {
$query = db_select('users', 'u');
$query->condition('u.uid', 0, '<>');
user_build_filter_query($query);
$count_query = clone $query;
$count_query->addExpression('COUNT(u.uid)');
......
......@@ -20,7 +20,6 @@ function user_admin_account() {
$query = db_select('users', 'u');
$query->condition('u.uid', 0, '<>');
user_build_filter_query($query);
$count_query = clone $query;
$count_query->addExpression('COUNT(u.uid)');
......
......@@ -2062,92 +2062,6 @@ function user_multiple_cancel_confirm_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/people';
}
/**
* List user administration filters that can be applied.
*/
function user_filters() {
// Regular filters
$filters = array();
$roles = user_role_names(TRUE);
unset($roles[DRUPAL_AUTHENTICATED_RID]); // Don't list authorized role.
if (count($roles)) {
$filters['role'] = array(
'title' => t('role'),
'field' => 'ur.rid',
'options' => array(
'[any]' => t('any'),
) + $roles,
);
}
$options = array();
foreach (module_implements('permission') as $module) {
$function = $module . '_permission';
if ($permissions = $function()) {
asort($permissions);
foreach ($permissions as $permission => $description) {
$options[t('@module module', array('@module' => $module))][$permission] = t($permission);
}
}
}
ksort($options);
$filters['permission'] = array(
'title' => t('permission'),
'options' => array(
'[any]' => t('any'),
) + $options,
);
$filters['status'] = array(
'title' => t('status'),
'field' => 'u.status',
'options' => array(
'[any]' => t('any'),
1 => t('active'),
0 => t('blocked'),
),
);
return $filters;
}
/**
* Extends a query object for user administration filters based on session.
*
* @param $query
* Query object that should be filtered.
*/
function user_build_filter_query(SelectInterface $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') {
$roles = user_roles(FALSE, $value);
if (isset($roles[DRUPAL_AUTHENTICATED_RID])) {
continue;
}
if (!empty($roles)) {
$value = array_keys($roles);
}
else {
// There's no role that has this permission set value to an impossible
// rid so that no users are matched.
$value = array('');
}
}
if ($key == 'permission' || $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);
}
}
}
/**
* Returns HTML for a user signature.
*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment