function _password_policy_expire_query_users in Password Policy 7.2
Queries users who are candidates for an expiration warning.
They are "candidates" in that they may or may not be covered by the expiration policy.
Parameters
int $notice_int: Beginning of notice (i.e. warning) interval, in seconds since the Unix epoch.
string $policy_name: Policy name.
Return value
array Array of candidates for password expiration warning, containing information pertaining to expiration.
1 call to _password_policy_expire_query_users()
- PasswordPolicyExpire::cron in plugins/
item/ expire.inc - Cron task for expiration plugin.
File
- plugins/
item/ expire.inc, line 152
Code
function _password_policy_expire_query_users($notice_int, $policy_name) {
$current_pw_query = db_select('password_policy_history', 'c');
$current_pw_query
->fields('c', array(
'uid',
))
->groupBy('uid')
->addExpression('MAX(created)', 'created');
$query = db_select('password_policy_history', 'p');
$query
->fields('p', array(
'uid',
'hid',
'created',
));
// Join to our active password so we are only looking at the most recent.
$query
->join($current_pw_query, 'c', 'p.created = c.created AND p.uid = c.uid');
// Add negative join to remove all items that have already sent this notice.
$query
->leftJoin('password_policy_notice_history', 'nh', 'nh.hid = p.hid AND nh.name = :policy_name AND nh.timeframe = :notice_int', array(
':policy_name' => $policy_name,
':notice_int' => $notice_int,
));
$query
->isNull('nh.hid');
// Check to see if the password needs a warning notification.
$query
->condition('p.created', REQUEST_TIME - $notice_int, '<');
// Package up the candidates and return them.
$candidates = array();
$result = $query
->execute();
foreach ($result as $row) {
$candidates[$row->uid] = $row;
}
return $candidates;
}