constraint_delay.php in Password Policy 5
File
constraints/constraint_delay.php
View source
<?php
include_once 'constraint.php';
class Delay_Constraint extends Constraint {
function validate($plaintext_password, $user = NULL) {
$last_change = db_result(db_query_range("SELECT MAX(created) FROM {password_policy_users} WHERE uid = %d", $user->uid, 0, 1));
if (!empty($last_change)) {
return time() - $this->minimumConstraintValue * 60 * 60 > $last_change;
}
return TRUE;
}
function getDescription() {
return t('Minimum number of hours between password changes.');
}
function getValidationErrorMessage() {
return t('Passwords may only be changed every %numHours @charHours.', array(
'%numHours' => $this->minimumConstraintValue,
'@charHours' => format_plural($this->minimumConstraintValue, t('hour'), t('hours')),
));
}
}