function purge_users_blocked_user_ids in Auto Purge Users 7
Same name and namespace in other branches
- 8.3 purge_users.module \purge_users_blocked_user_ids()
- 8 purge_users.module \purge_users_blocked_user_ids()
- 8.2 purge_users.module \purge_users_blocked_user_ids()
- 7.2 purge_users.module \purge_users_blocked_user_ids()
Get blocked user ids.
Parameters
array $param: Form parameters.
array $user_roles: Selected users roles.
Return value
mixed Blocked user ids.
2 calls to purge_users_blocked_user_ids()
- purge_users_cron in ./
purge_users.module - Implements hook_cron().
- purge_users_get_users_list in ./
purge_users.module - Get users ids to cancel.
File
- ./
purge_users.module, line 252 - Purge users module file.
Code
function purge_users_blocked_user_ids(array $param, array $user_roles = array()) {
// Get a time stamp according to the period selected.
$blockdate = '';
if (!empty($param['blocked_value'])) {
$blockdate = strtotime('-' . $param['blocked_value'] . ' ' . $param['blocked_period']);
}
// Query through db table to get users ids.
$query = db_select('users', 'u');
$query
->leftjoin('users_roles', 'ur', 'ur.uid = u.uid');
$query
->fields('u', array(
'uid',
));
$query
->condition('u.uid', 1, '>');
if (!empty($param['blocked_period'])) {
$query
->condition('u.created', $blockdate, '<');
$query
->condition('u.login', $blockdate, '<');
$query
->condition('u.login', 0, '!=');
$query
->condition('u.status', 0);
}
if (in_array(DRUPAL_AUTHENTICATED_RID, $user_roles)) {
$db_or = db_or();
$db_or
->condition('ur.rid', NULL);
$db_or
->condition('ur.rid', $user_roles, 'IN');
$query
->condition($db_or);
}
else {
$query
->condition('ur.rid', $user_roles, 'IN');
}
$uids = $query
->execute()
->fetchCol();
return $uids;
}