Commit 5d4accc6 authored by Andrew Robert Nicols's avatar Andrew Robert Nicols
Browse files

Send password reminder e-mails even if email is disabled for a user (bug #689045)



A message also alerts the requestor if the e-mail address is over the
bounce threshold.
Signed-off-by: default avatarAndrew Robert Nicols <andrew.nicols@luns.net.uk>
Signed-off-by: default avatarRuslan Kabalin <ruslan.kabalin@luns.net.uk>
parent e38ab3b5
......@@ -149,6 +149,8 @@ function forgotpass_submit(Pieform $form, $values) {
$pwrequest->key = get_random_key();
$sitename = get_config('sitename');
$fullname = display_name($user);
// Override the disabled status of this e-mail address
$user->ignoredisabled = true;
email_user($user, null,
get_string('forgotusernamepasswordemailsubject', 'mahara', $sitename),
get_string('forgotusernamepasswordemailmessagetext', 'mahara',
......@@ -171,13 +173,21 @@ function forgotpass_submit(Pieform $form, $values) {
catch (SQLException $e) {
die_info(get_string('forgotpassemailsendunsuccessful'));
}
catch (EmailDisabledException $e) {
die_info(get_string('forgotpassemaildisabled'));
}
catch (EmailException $e) {
die_info(get_string('forgotpassemailsendunsuccessful'));
}
// Add a note if this e-mail address is over the bounce threshold to
// warn users that they may not receive the e-mail
if ($mailinfo = get_record_select('artefact_internal_profile_email', '"owner" = ? AND principal = 1', array($user->id))) {
if (check_overcount($mailinfo)) {
$SESSION->add_info_msg(get_string('forgotpassemailsentanyway'));
}
}
// Unsetting disabled status overriding
unset($user->ignoredisabled);
// Add a marker in the session to say that the user has registered
$_SESSION['pwchangerequested'] = true;
......
......@@ -394,7 +394,7 @@ $string['forgotusernamepasswordemailmessagehtml'] = '<p>Dear %s,</p>
<p>Regards, %s Site Administrator</p>';
$string['forgotpassemailsendunsuccessful'] = 'Sorry, it appears that the e-mail could not be sent successfully. This is our fault, please try again shortly';
$string['forgotpassemaildisabled'] = 'Sorry, email is disabled for the email address or username you entered. Please contact an administrator to reset your password.';
$string['forgotpassemailsentanyway'] = 'An e-mail was sent to the address stored for this user, but the address may not be correct or the recipient server is returning messages. Please contact your Mahara administrator to reset your password if you do not receive the e-mail.';
$string['forgotpassnosuchemailaddressorusername'] = 'The email address or username you entered doesn\'t match any users for this site';
$string['forgotpasswordenternew'] = 'Please enter your new password to continue';
$string['nosuchpasswordrequest'] = 'No such password request';
......
......@@ -288,7 +288,7 @@ function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml='',
throw new InvalidArgumentException("empty user given to email_user");
}
if (!$mailinfo = can_receive_email($userto)) {
if (!$userto->ignoredisabled && !$mailinfo = can_receive_email($userto)) {
throw new EmailDisabledException("email for this user has been disabled");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment