Commit b47b62e1 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Don't send expiry/inactivity warnings to deleted users (bug #903485)



Users are emailed on cron to warn them about impending account expiry,
inactivity, or institution membership expiry, but deleted users are
included in the list, resulting in attempts to send email to invalid
addresses.

Change-Id: I5c95c927863330dc51aa632cc9aded75ea9b65e5
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent a2ac7c27
......@@ -1395,7 +1395,7 @@ function auth_handle_account_expiries() {
if ($users = get_records_sql_array('SELECT u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, u.admin, u.staff
FROM {usr} u
WHERE ' . db_format_tsfield('u.expiry', false) . ' < ?
AND expirymailsent = 0', array(time() + $warn))) {
AND expirymailsent = 0 AND deleted = 0', array(time() + $warn))) {
foreach ($users as $user) {
$displayname = display_name($user);
_email_or_notify($user, get_string('accountexpirywarning'),
......@@ -1422,7 +1422,7 @@ function auth_handle_account_expiries() {
if ($users = get_records_sql_array('SELECT u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, u.admin, u.staff
FROM {usr} u
WHERE (? - ' . db_format_tsfield('u.lastlogin', false) . ') > ' . ($expire - $warn) . '
AND inactivemailsent = 0', array(time()))) {
AND inactivemailsent = 0 AND deleted = 0', array(time()))) {
foreach ($users as $user) {
$displayname = display_name($user);
_email_or_notify($user, get_string('accountinactivewarning'),
......@@ -1457,7 +1457,7 @@ function auth_handle_account_expiries() {
INNER JOIN {usr_institution} ui ON u.id = ui.usr
INNER JOIN {institution} i ON ui.institution = i.name
WHERE ' . db_format_tsfield('ui.expiry', false) . ' < ?
AND ui.expirymailsent = 0', array(time() + $warn))) {
AND ui.expirymailsent = 0 AND u.deleted = 0', array(time() + $warn))) {
foreach ($users as $user) {
$displayname = display_name($user);
_email_or_notify($user, get_string('institutionmembershipexpirywarning'),
......
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