Commit 7343c13e authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Don't send inactive email unless an inactivity time is set

parent 03ba33da
...@@ -1136,28 +1136,30 @@ function auth_handle_account_expiries() { ...@@ -1136,28 +1136,30 @@ function auth_handle_account_expiries() {
} }
// Inactivity (lastlogin is too old) if ($expire) {
if ($users = get_records_sql_array('SELECT u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, u.admin, u.staff // Inactivity (lastlogin is too old)
FROM {usr} u if ($users = get_records_sql_array('SELECT u.id, u.username, u.firstname, u.lastname, u.preferredname, u.email, u.admin, u.staff
WHERE (? - ' . db_format_tsfield('u.lastlogin', false) . ') > ' . ($expire - $warn) . ' FROM {usr} u
AND inactivemailsent = 0', array(time()))) { WHERE (? - ' . db_format_tsfield('u.lastlogin', false) . ') > ' . ($expire - $warn) . '
foreach ($users as $user) { AND inactivemailsent = 0', array(time()))) {
$displayname = display_name($user); foreach ($users as $user) {
email_user($user, null, get_string('accountinactivewarning'), $displayname = display_name($user);
get_string('accountinactivewarningtext', 'mahara', $displayname, $sitename, $daystoexpire, $sitename), email_user($user, null, get_string('accountinactivewarning'),
get_string('accountinactivewarninghtml', 'mahara', $displayname, $sitename, $daystoexpire, $sitename) get_string('accountinactivewarningtext', 'mahara', $displayname, $sitename, $daystoexpire, $sitename),
); get_string('accountinactivewarninghtml', 'mahara', $displayname, $sitename, $daystoexpire, $sitename)
set_field('usr', 'inactivemailsent', 1, 'id', $user->id); );
set_field('usr', 'inactivemailsent', 1, 'id', $user->id);
}
} }
}
// Actual inactive users
// Actual inactive users if ($users = get_records_sql_array('SELECT u.id
if ($users = get_records_sql_array('SELECT u.id FROM {usr} u
FROM {usr} u WHERE (? - ' . db_format_tsfield('lastlogin', false) . ') > ?', array(time(), $expire))) {
WHERE (? - ' . db_format_tsfield('lastlogin', false) . ') > ?', array(time(), $expire))) { // Users have become inactive!
// Users have become inactive! foreach ($users as $user) {
foreach ($users as $user) { deactivate_user($user->id);
deactivate_user($user->id); }
} }
} }
......
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