| 5 user.module | user_filters() |
| 6 user.module | user_filters() |
| 7 user.module | user_filters() |
| 8 user.module | user_filters() |
List user administration filters that can be applied.
3 calls to user_filters()
2 string references to 'user_filters'
File
- modules/
user/ user.module, line 2006 - Enables the user registration and login system.
Code
function user_filters() {
// Regular filters
$filters = array();
$roles = user_roles(TRUE);
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,
'join' => '',
);
}
$options = array();
foreach (module_list() as $module) {
if ($permissions = module_invoke($module, 'perm')) {
asort($permissions);
foreach ($permissions as $permission) {
$options[t('@module module', array('@module' => $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',
'join' => '',
'options' => array(
1 => t('active'),
0 => t('blocked'),
),
);
return $filters;
}
Login or register to post comments
Comments
Override this function
Why can modules not override this function? Applying a patch to this function, like the module subuser does, is just plain ugly, and I'd like to be able to control which form items, permissions, or roles, the user can select from.
A custom hook
Hi bartl, we found ourselves with the same problem so we "invented" a new hook; the only catch is that you have to modify this file to add the hook call just before the return, something like:
<?php
/** hook_user_filters(&$filters) */
foreach (module_list() as $module) {
$function = $module .'_user_filters';
if (function_exists($function)) {
$function($filters);
}
}
return $filters;
?>
Oh god, not even a drupal_alter() or anything :/
Oh god, not even a drupal_alter() or anything :/ Will have to just hack the form and hope nothing else relies on this function.