function logintoboggan_cron in LoginToboggan 7
Same name and namespace in other branches
- 8 logintoboggan.module \logintoboggan_cron()
- 6 logintoboggan.module \logintoboggan_cron()
Implement hook_cron().
File
- ./
logintoboggan.module, line 27 - LoginToboggan module
Code
function logintoboggan_cron() {
// If set password is enabled, and a purge interval is set, check for
// unvalidated users to purge.
if (($purge_interval = variable_get('logintoboggan_purge_unvalidated_user_interval', 0)) && !variable_get('user_email_verification', TRUE)) {
$validating_id = logintoboggan_validating_id();
// As a safety check, make sure that we have a non-core role as the
// pre-auth role -- otherwise skip.
if (!in_array($validating_id, array(
DRUPAL_ANONYMOUS_RID,
DRUPAL_AUTHENTICATED_RID,
))) {
$purge_time = REQUEST_TIME - $purge_interval;
$accounts = db_query("SELECT u.uid, u.name FROM {users} u INNER JOIN {users_roles} ur ON u.uid = ur.uid WHERE ur.rid = :rid AND u.created < :created", array(
':rid' => $validating_id,
':created' => $purge_time,
));
$purged_users = array();
$uids = array();
foreach ($accounts as $account) {
$uids[] = $account->uid;
$purged_users[] = check_plain($account->name);
}
// Delete the users from the system.
user_delete_multiple($uids);
// Log the purged users.
if (!empty($purged_users)) {
watchdog('logintoboggan', 'Purged the following unvalidated users: !purged_users', array(
'!purged_users' => theme('item_list', array(
'items' => $purged_users,
)),
));
}
}
}
}