aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/lib/Expiration.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin/lib/Expiration.php')
-rw-r--r--apps/files_trashbin/lib/Expiration.php50
1 files changed, 22 insertions, 28 deletions
diff --git a/apps/files_trashbin/lib/Expiration.php b/apps/files_trashbin/lib/Expiration.php
index 5705fc23b8a..0bbe39a9314 100644
--- a/apps/files_trashbin/lib/Expiration.php
+++ b/apps/files_trashbin/lib/Expiration.php
@@ -1,28 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Victor Dubiniuk <dubiniuk@owncloud.com>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_Trashbin;
@@ -35,9 +16,6 @@ class Expiration {
public const DEFAULT_RETENTION_OBLIGATION = 30;
public const NO_OBLIGATION = -1;
- /** @var ITimeFactory */
- private $timeFactory;
-
/** @var string */
private $retentionObligation;
@@ -50,8 +28,10 @@ class Expiration {
/** @var bool */
private $canPurgeToSaveSpace;
- public function __construct(IConfig $config,ITimeFactory $timeFactory) {
- $this->timeFactory = $timeFactory;
+ public function __construct(
+ IConfig $config,
+ private ITimeFactory $timeFactory,
+ ) {
$this->setRetentionObligation($config->getSystemValue('trashbin_retention_obligation', 'auto'));
}
@@ -115,6 +95,20 @@ class Expiration {
}
/**
+ * Get minimal retention obligation as a timestamp
+ *
+ * @return int|false
+ */
+ public function getMinAgeAsTimestamp() {
+ $minAge = false;
+ if ($this->isEnabled() && $this->minAge !== self::NO_OBLIGATION) {
+ $time = $this->timeFactory->getTime();
+ $minAge = $time - ($this->minAge * 86400);
+ }
+ return $minAge;
+ }
+
+ /**
* @return bool|int
*/
public function getMaxAgeAsTimestamp() {