Файл: forsoc.ru/phpbb/cron/task/core/tidy_search.php
Строк: 120
<?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;
/**
* Tidy search cron task.
*
* Will only run when the currently selected search backend supports tidying.
*/
class tidy_search extends phpbbcrontaskbase
{
/**
* phpBB root path
* @var string
*/
protected $phpbb_root_path;
/**
* PHP file extension
* @var string
*/
protected $php_ext;
/**
* Auth object
* @var phpbbauthauth
*/
protected $auth;
/**
* Config object
* @var phpbbconfigconfig
*/
protected $config;
/**
* Database object
* @var phpbbdbdriverdriver_interface
*/
protected $db;
/**
* User object
* @var phpbbuser
*/
protected $user;
/**
* Event dispatcher object
* @var phpbbeventdispatcher_interface
*/
protected $phpbb_dispatcher;
/**
* Constructor.
*
* @param string $phpbb_root_path The phpBB root path
* @param string $php_ext The PHP file extension
* @param phpbbauthauth $auth The auth object
* @param phpbbconfigconfig $config The config object
* @param phpbbdbdriverdriver_interface $db The database object
* @param phpbbuser $user The user object
* @param phpbbeventdispatcher_interface $phpbb_dispatcher The event dispatcher object
*/
public function __construct($phpbb_root_path, $php_ext, phpbbauthauth $auth, phpbbconfigconfig $config, phpbbdbdriverdriver_interface $db, phpbbuser $user, phpbbeventdispatcher_interface $phpbb_dispatcher)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->auth = $auth;
$this->config = $config;
$this->db = $db;
$this->user = $user;
$this->phpbb_dispatcher = $phpbb_dispatcher;
}
/**
* Runs this cron task.
*
* @return null
*/
public function run()
{
$search_type = $this->config['search_type'];
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;
$search = new $search_type($error, $this->phpbb_root_path, $this->php_ext, $this->auth, $this->config, $this->db, $this->user, $this->phpbb_dispatcher);
if (!$error)
{
$search->tidy();
}
}
/**
* Returns whether this cron task can run, given current board configuration.
*
* Search cron task is runnable in all normal use. It may not be
* runnable if the search backend implementation selected in board
* configuration does not exist.
*
* @return bool
*/
public function is_runnable()
{
return class_exists($this->config['search_type']);
}
/**
* Returns whether this cron task should run now, because enough time
* has passed since it was last run.
*
* The interval between search tidying is specified in board
* configuration.
*
* @return bool
*/
public function should_run()
{
return $this->config['search_last_gc'] < time() - $this->config['search_gc'];
}
}