Файл: phpbb/cron/task/core/prune_notifications.php
Строк: 93
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbbcrontaskcore;
/**
* Prune notifications cron task.
*/
class prune_notifications extends phpbbcrontaskbase
{
protected $config;
protected $notification_manager;
/**
* Constructor.
*
* @param phpbbconfigconfig $config The config
* @param phpbbnotificationmanager $notification_manager Notification manager
*/
public function __construct(phpbbconfigconfig $config, phpbbnotificationmanager $notification_manager)
{
$this->config = $config;
$this->notification_manager = $notification_manager;
}
/**
* {@inheritdoc}
*/
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);
}
/**
* {@inheritdoc}
*/
public function is_runnable()
{
return (bool) $this->config['read_notification_expire_days'];
}
/**
* {@inheritdoc}
*/
public function should_run()
{
return $this->config['read_notification_last_gc'] < time() - $this->config['read_notification_gc'];
}
}