[ticket/11103] Prune notifications function

To delete all notifications before a certain time

PHPBB3-11103
This commit is contained in:
Nathan Guse 2012-12-15 18:35:17 -06:00
parent c9ca705149
commit c6f138ff12

View file

@ -713,7 +713,7 @@ class phpbb_notification_manager
* is disabled so that all those notifications are hidden and do not * is disabled so that all those notifications are hidden and do not
* cause errors * cause errors
* *
* @param string $item_type * @param string $item_type Type identifier of the subscription
*/ */
public function disable_notifications($item_type) 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 * This should be called when an extension which has notification types
* is purged so that all those notifications are removed * 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) 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 * that was disabled is re-enabled so that all those notifications that
* were hidden are shown again * were hidden are shown again
* *
* @param string $item_type * @param string $item_type Type identifier of the subscription
*/ */
public function enable_notifications($item_type) public function enable_notifications($item_type)
{ {
@ -755,6 +755,18 @@ class phpbb_notification_manager
$this->db->sql_query($sql); $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 * Helper to get the notifications item type class and set it up
*/ */