MDL-64400 core_messages: Allow cron to delete unread notifications too

This commit is contained in:
Amaia Anabitarte
2018-12-27 09:15:53 +01:00
parent 38a1b4f203
commit 57afd82ab0
4 changed files with 33 additions and 5 deletions
+8 -3
View File
@@ -46,13 +46,18 @@ class messaging_cleanup_task extends scheduled_task {
$timenow = time();
// Cleanup messaging.
// Cleanup read and unread notifications.
if (!empty($CFG->messagingdeleteallnotificationsdelay)) {
$notificationdeletetime = $timenow - $CFG->messagingdeleteallnotificationsdelay;
$params = array('notificationdeletetime' => $notificationdeletetime);
$DB->delete_records_select('notifications', 'timecreated < :notificationdeletetime', $params);
}
// Cleanup read notifications.
if (!empty($CFG->messagingdeletereadnotificationsdelay)) {
$notificationdeletetime = $timenow - $CFG->messagingdeletereadnotificationsdelay;
$params = array('notificationdeletetime' => $notificationdeletetime);
$DB->delete_records_select('notifications', 'timeread < :notificationdeletetime', $params);
}
}
}