function mass_pwreset_get_uids_by_role in Mass Password Reset 7
Handler: retrieve uids from a list of roles
1 call to mass_pwreset_get_uids_by_role()
- mass_pwreset_submit in ./
mass_pwreset.admin.inc - Form submission handler for mass_pwreset_form().
File
- ./
mass_pwreset.module, line 145 - Reset user passwords and optionally notify users.
Code
function mass_pwreset_get_uids_by_role($roles = array()) {
$rid = DRUPAL_AUTHENTICATED_RID;
// If "authenticated user" role is present, select all users.
if (in_array($rid, $roles)) {
$query = db_select('users', 'u');
$query
->fields('u', array(
'uid',
'uid',
));
$query
->condition('u.uid', '0', '<>');
$query
->orderBy('u.uid');
}
else {
$query = db_select('users', 'u');
$query
->innerJoin('users_roles', 'ur', 'u.uid = ur.uid');
$query
->fields('u', array(
'uid',
'uid',
));
$query
->condition('ur.rid', $roles, 'IN');
$query
->orderBy('u.uid');
}
$result = $query
->execute()
->fetchAllKeyed();
return $result;
}