1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Joas Schilling <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
6
|
|
|
* @license AGPL-3.0 |
7
|
|
|
* |
8
|
|
|
* This code is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
10
|
|
|
* as published by the Free Software Foundation. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU Affero General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
18
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
19
|
|
|
* |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace OCA\Activity\BackgroundJob; |
23
|
|
|
|
24
|
|
|
use OC\BackgroundJob\TimedJob; |
25
|
|
|
use OCA\Activity\AppInfo\Application; |
26
|
|
|
use OCA\Activity\Data; |
27
|
|
|
use OCP\IConfig; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Class ExpireActivities |
31
|
|
|
* |
32
|
|
|
* @package OCA\Activity\BackgroundJob |
33
|
|
|
*/ |
34
|
|
|
class ExpireActivities extends TimedJob { |
35
|
|
|
/** @var Data */ |
36
|
|
|
protected $data; |
37
|
|
|
/** @var IConfig */ |
38
|
|
|
protected $config; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param Data $data |
42
|
|
|
* @param IConfig $config |
43
|
|
|
*/ |
44
|
3 |
|
public function __construct(Data $data = null, IConfig $config = null) { |
45
|
|
|
// Run once per day |
46
|
3 |
|
$this->setInterval(60 * 60 * 24); |
47
|
|
|
|
48
|
3 |
|
if ($data === null || $config === null) { |
49
|
2 |
|
$this->fixDIForJobs(); |
50
|
|
|
} else { |
51
|
1 |
|
$this->data = $data; |
52
|
1 |
|
$this->config = $config; |
53
|
|
|
} |
54
|
3 |
|
} |
55
|
|
|
|
56
|
2 |
|
protected function fixDIForJobs() { |
57
|
2 |
|
$application = new Application(); |
58
|
|
|
|
59
|
2 |
|
$this->data = $application->getContainer()->query('ActivityData'); |
60
|
2 |
|
$this->config = \OC::$server->getConfig(); |
61
|
2 |
|
} |
62
|
|
|
|
63
|
3 |
|
protected function run($argument) { |
64
|
|
|
// Remove activities that are older then one year |
65
|
3 |
|
$expireDays = $this->config->getSystemValue('activity_expire_days', 365); |
66
|
3 |
|
$this->data->expire($expireDays); |
67
|
3 |
|
} |
68
|
|
|
} |
69
|
|
|
|