From c6f138ff12f015543f92d07fb5c93c083a246bab Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sat, 15 Dec 2012 18:35:17 -0600 Subject: [PATCH] [ticket/11103] Prune notifications function To delete all notifications before a certain time PHPBB3-11103 --- phpBB/includes/notification/manager.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index 90916401c0..a5e1b09754 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -713,7 +713,7 @@ class phpbb_notification_manager * is disabled so that all those notifications are hidden and do not * cause errors * - * @param string $item_type + * @param string $item_type Type identifier of the subscription */ public function disable_notifications($item_type) { @@ -729,7 +729,7 @@ class phpbb_notification_manager * This should be called when an extension which has notification types * is purged so that all those notifications are removed * - * @param string $item_type + * @param string $item_type Type identifier of the subscription */ public function purge_notifications($item_type) { @@ -745,7 +745,7 @@ class phpbb_notification_manager * that was disabled is re-enabled so that all those notifications that * were hidden are shown again * - * @param string $item_type + * @param string $item_type Type identifier of the subscription */ public function enable_notifications($item_type) { @@ -755,6 +755,18 @@ class phpbb_notification_manager $this->db->sql_query($sql); } + /** + * Delete all notifications older than a certain time + * + * @param int $timestamp Unix timestamp to delete all notifications that were created before + */ + public function prune_notifications($timestamp) + { + $sql = 'DELETE FROM ' . $this->notifications_table . ' + WHERE time < ' . (int) $timestamp; + $this->db->sql_query($sql); + } + /** * Helper to get the notifications item type class and set it up */