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

This commit is contained in:
Amaia Anabitarte
2018-12-27 09:32:25 +01:00
parent c8b4ee45a4
commit da73f1364d
3 changed files with 32 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);
}
}
}