MDL-64400 core_messages: Allow cron to delete unread notifications too
This commit is contained in:
@@ -15,8 +15,28 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('messaging', new lang_string('messaging', 'admin'), new lang_string('configmessaging','admin'), 1));
|
||||
|
||||
$options = array(DAYSECS=>new lang_string('secondstotime86400'), WEEKSECS=>new lang_string('secondstotime604800'), 2620800=>new lang_string('nummonths', 'moodle', 1), 15724800=>new lang_string('nummonths', 'moodle', 6),0=>new lang_string('never'));
|
||||
$optionalsubsystems->add(new admin_setting_configselect('messagingdeletereadnotificationsdelay', new lang_string('messagingdeletereadnotificationsdelay', 'admin'), new lang_string('configmessagingdeletereadnotificationsdelay', 'admin'), 604800, $options));
|
||||
$options = array(
|
||||
DAYSECS => new lang_string('secondstotime86400'),
|
||||
WEEKSECS => new lang_string('secondstotime604800'),
|
||||
2620800 => new lang_string('nummonths', 'moodle', 1),
|
||||
7862400 => new lang_string('nummonths', 'moodle', 3),
|
||||
15724800 => new lang_string('nummonths', 'moodle', 6),
|
||||
0 => new lang_string('never')
|
||||
);
|
||||
$optionalsubsystems->add(new admin_setting_configselect(
|
||||
'messagingdeletereadnotificationsdelay',
|
||||
new lang_string('messagingdeletereadnotificationsdelay', 'admin'),
|
||||
new lang_string('configmessagingdeletereadnotificationsdelay', 'admin'),
|
||||
604800,
|
||||
$options)
|
||||
);
|
||||
$optionalsubsystems->add(new admin_setting_configselect(
|
||||
'messagingdeleteallnotificationsdelay',
|
||||
new lang_string('messagingdeleteallnotificationsdelay', 'admin'),
|
||||
new lang_string('configmessagingdeleteallnotificationsdelay', 'admin'),
|
||||
2620800,
|
||||
$options)
|
||||
);
|
||||
|
||||
$optionalsubsystems->add(new admin_setting_configcheckbox('messagingallowemailoverride', new lang_string('messagingallowemailoverride', 'admin'), new lang_string('configmessagingallowemailoverride','admin'), 0));
|
||||
|
||||
|
||||
@@ -275,6 +275,7 @@ $string['configmaxevents'] = 'Events to Lookahead';
|
||||
$string['configmessaging'] = 'Should the messaging system between site users be enabled?';
|
||||
$string['configmessagingallowemailoverride'] = 'Allow users to have email message notifications sent to an email address other than the email address in their profile';
|
||||
$string['configmessagingdeletereadnotificationsdelay'] = 'Read notifications can be deleted to save space. How long after a notification is read can it be deleted?';
|
||||
$string['configmessagingdeleteallnotificationsdelay'] = 'Read and unread notifications can be deleted to save space. How long after a notification is created can it be deleted?';
|
||||
$string['configminpassworddigits'] = 'Passwords must have at least these many digits.';
|
||||
$string['configminpasswordlength'] = 'Passwords must be at least these many characters long.';
|
||||
$string['configminpasswordlower'] = 'Passwords must have at least these many lower case letters.';
|
||||
@@ -747,6 +748,7 @@ $string['mediapluginyoutube'] = 'Enable YouTube links filter';
|
||||
$string['messaging'] = 'Enable messaging system';
|
||||
$string['messagingallowemailoverride'] = 'Notification email override';
|
||||
$string['messagingdeletereadnotificationsdelay'] = 'Delete read notifications';
|
||||
$string['messagingdeleteallnotificationsdelay'] = 'Delete all notifications';
|
||||
$string['minpassworddigits'] = 'Digits';
|
||||
$string['minpasswordlength'] = 'Password length';
|
||||
$string['minpasswordlower'] = 'Lowercase letters';
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user