forked from phpbb-extensions/autogroups
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautogroups_check.php
executable file
·70 lines (63 loc) · 1.54 KB
/
autogroups_check.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
*
* Auto Groups extension for the phpBB Forum Software package.
*
* @copyright (c) 2014 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace phpbb\autogroups\cron;
/**
* Auto groups cron task.
*/
class autogroups_check extends \phpbb\cron\task\base
{
/** @var \phpbb\config\config */
protected $config;
/** @var \phpbb\autogroups\conditions\manager */
protected $manager;
/**
* Constructor
*
* @param \phpbb\config\config $config Config object
* @param \phpbb\autogroups\conditions\manager $manager Auto groups condition manager object
* @access public
*/
public function __construct(\phpbb\config\config $config, \phpbb\autogroups\conditions\manager $manager)
{
$this->config = $config;
$this->manager = $manager;
}
/**
* Runs this cron task.
*
* @return null
*/
public function run()
{
$this->manager->check_conditions();
$this->config->set('autogroups_last_run', time(), false); // TODO: move this into the check_conditions() method?
}
/**
* Returns whether this cron task can run, given current board configuration.
*
* If warnings are set to never expire, this cron task will not run.
*
* @return bool
*/
public function is_runnable()
{
return true;
}
/**
* Returns whether this cron task should run now, because enough time
* has passed since it was last run (24 hours).
*
* @return bool
*/
public function should_run()
{
return $this->config['autogroups_last_run'] < strtotime('24 hours ago');
}
}