diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-07-27 20:37:50 -0500 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-07-27 20:37:50 -0500 |
commit | a79e3b341578696c1dd6720d7589b10a3226dbb5 (patch) | |
tree | 6b42e6554e796b1c46ff65ee3c277b57feaa1a10 /phpBB/phpbb/cron/task | |
parent | 26dac64d45944dce14b33a9c82e531f01f9a623f (diff) | |
download | forums-a79e3b341578696c1dd6720d7589b10a3226dbb5.tar forums-a79e3b341578696c1dd6720d7589b10a3226dbb5.tar.gz forums-a79e3b341578696c1dd6720d7589b10a3226dbb5.tar.bz2 forums-a79e3b341578696c1dd6720d7589b10a3226dbb5.tar.xz forums-a79e3b341578696c1dd6720d7589b10a3226dbb5.zip |
[ticket/11373] Prune old read notifications with cron
PHPBB3-11373
Diffstat (limited to 'phpBB/phpbb/cron/task')
-rw-r--r-- | phpBB/phpbb/cron/task/core/prune_notifications.php | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/phpBB/phpbb/cron/task/core/prune_notifications.php b/phpBB/phpbb/cron/task/core/prune_notifications.php new file mode 100644 index 0000000000..6d38091e9f --- /dev/null +++ b/phpBB/phpbb/cron/task/core/prune_notifications.php @@ -0,0 +1,75 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Prune notifications cron task. +* +* @package phpBB3 +*/ +class phpbb_cron_task_core_prune_notifications extends phpbb_cron_task_base +{ + protected $config; + protected $notification_manager; + + /** + * Constructor. + * + * @param phpbb_config $config The config + * @param phpbb_notification_manager $notification_manager Notification manager + */ + public function __construct(phpbb_config $config, phpbb_notification_manager $notification_manager) + { + $this->config = $config; + $this->notification_manager = $notification_manager; + } + + /** + * Runs this cron task. + * + * @return null + */ + public function run() + { + // time minus expire days in seconds + $timestamp = time() - ($this->config['read_notification_expire_days'] * 60 * 60 * 24); + $this->notification_manager->prune_notifications($timestamp); + } + + /** + * Returns whether this cron task can run, given current board configuration.= + * + * @return bool + */ + public function is_runnable() + { + return (bool) $this->config['read_notification_expire_days']; + } + + /** + * Returns whether this cron task should run now, because enough time + * has passed since it was last run. + * + * The interval between prune notifications is specified in board + * configuration. + * + * @return bool + */ + public function should_run() + { + return $this->config['read_notification_last_gc'] < time() - $this->config['read_notification_gc']; + } +} |