From 212badff4dd8610f53ecd1ce908489907e8a043f Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Thu, 28 Oct 2010 03:59:40 +0000 Subject: [PATCH] message MDL-24879 added something to cron to remove read notifications --- admin/settings/subsystems.php | 3 +++ lang/en/admin.php | 2 ++ lib/cronlib.php | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/admin/settings/subsystems.php b/admin/settings/subsystems.php index 2d89e975654..ceccfe54692 100644 --- a/admin/settings/subsystems.php +++ b/admin/settings/subsystems.php @@ -17,6 +17,9 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page $optionalsubsystems->add(new admin_setting_configcheckbox('messaginghidereadnotifications', get_string('messaginghidereadnotifications', 'admin'), get_string('configmessaginghidereadnotifications','admin'), 0)); + $options = array(DAYSECS=>get_string('secondstotime86400'), WEEKSECS=>get_string('secondstotime604800'), 2620800=>get_string('nummonths', 'moodle', 1), 15724800=>get_string('nummonths', 'moodle', 6),0=>get_string('never')); + $optionalsubsystems->add(new admin_setting_configselect('messagingdeletereadnotificationsdelay', get_string('messagingdeletereadnotificationsdelay', 'admin'), get_string('configmessagingdeletereadnotificationsdelay', 'admin'), 604800, $options)); + $optionalsubsystems->add(new admin_setting_configcheckbox('enablestats', get_string('enablestats', 'admin'), get_string('configenablestats', 'admin'), 0)); $optionalsubsystems->add(new admin_setting_configcheckbox('enablerssfeeds', get_string('enablerssfeeds', 'admin'), get_string('configenablerssfeeds', 'admin'), 0)); diff --git a/lang/en/admin.php b/lang/en/admin.php index 2a0c18dfffa..e69364fa7bc 100755 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -259,6 +259,7 @@ $string['configmemcachedhosts'] = 'For memcached. Comma-separated list of hosts $string['configmemcachedpconn'] = 'For memcached. Use persistent connections. Use carefully -- it can make Apache/PHP crash after a restart of the memcached daemon.'; $string['configmessaging'] = 'Should the messaging system between site users be enabled?'; $string['configmessaginghidereadnotifications'] = 'Hide read notifications of events like forum posts when viewing messaging history'; +$string['configmessagingdeletereadnotificationsdelay'] = 'Read notifications can be deleted to save space. How long after a notification is read 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.'; @@ -691,6 +692,7 @@ $string['memcachedhosts'] = 'memcached hosts'; $string['memcachedpconn'] = 'memcached use persistent connections'; $string['messaging'] = 'Enable messaging system'; $string['messaginghidereadnotifications'] = 'Hide read notifications'; +$string['messagingdeletereadnotificationsdelay'] = 'Delete read notifications'; $string['minpassworddigits'] = 'Digits'; $string['minpasswordlength'] = 'Password length'; $string['minpasswordlower'] = 'Lowercase letters'; diff --git a/lib/cronlib.php b/lib/cronlib.php index 8fd64a44886..cc5bf04ac66 100644 --- a/lib/cronlib.php +++ b/lib/cronlib.php @@ -324,6 +324,12 @@ function cron_run() { build_context_path(); mtrace ('Built context paths'); + if (!empty($CFG->messagingdeletereadnotificationsdelay)) { + $notificationdeletetime = time() - $CFG->messagingdeletereadnotificationsdelay; //604800; //1 week ago + $DB->delete_records_select('message_read', 'notification=1 AND timeread<:notificationdeletetime', array('notificationdeletetime'=>$notificationdeletetime)); + mtrace('Cleaned up read notifications'); + } + mtrace("Finished clean-up tasks..."); } // End of occasional clean-up tasks