2018-09-03 19:30:10 +03:00
|
|
|
<?php
|
2018-09-10 15:40:35 +03:00
|
|
|
declare(strict_types=1);
|
2018-09-03 19:30:10 +03:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2018 Robin Appelman <robin@icewind.nl>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Files_Trashbin\Sabre;
|
|
|
|
|
2018-09-10 15:40:35 +03:00
|
|
|
use OCA\Files_Trashbin\Trash\ITrashItem;
|
|
|
|
use OCA\Files_Trashbin\Trash\ITrashManager;
|
2018-09-03 19:30:10 +03:00
|
|
|
use OCP\Files\FileInfo;
|
2018-09-10 15:40:35 +03:00
|
|
|
use OCP\IUser;
|
2018-09-03 19:30:10 +03:00
|
|
|
|
|
|
|
abstract class AbstractTrash implements ITrash {
|
2018-09-10 15:40:35 +03:00
|
|
|
/** @var ITrashItem */
|
2018-09-03 19:30:10 +03:00
|
|
|
protected $data;
|
|
|
|
|
2018-09-10 15:40:35 +03:00
|
|
|
/** @var ITrashManager */
|
|
|
|
protected $trashManager;
|
|
|
|
|
2018-10-17 16:21:09 +03:00
|
|
|
public function __construct(ITrashManager $trashManager, ITrashItem $data) {
|
2018-09-10 15:40:35 +03:00
|
|
|
$this->trashManager = $trashManager;
|
2018-09-03 19:30:10 +03:00
|
|
|
$this->data = $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFilename(): string {
|
|
|
|
return $this->data->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDeletionTime(): int {
|
2018-09-10 15:40:35 +03:00
|
|
|
return $this->data->getDeletedTime();
|
2018-09-03 19:30:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getFileId(): int {
|
|
|
|
return $this->data->getId();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFileInfo(): FileInfo {
|
|
|
|
return $this->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSize(): int {
|
|
|
|
return $this->data->getSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLastModified(): int {
|
|
|
|
return $this->data->getMtime();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getContentType(): string {
|
|
|
|
return $this->data->getMimetype();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getETag(): string {
|
|
|
|
return $this->data->getEtag();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): string {
|
|
|
|
return $this->data->getName();
|
|
|
|
}
|
2018-09-10 15:40:35 +03:00
|
|
|
|
|
|
|
public function getOriginalLocation(): string {
|
2018-10-17 16:21:09 +03:00
|
|
|
return $this->data->getOriginalLocation();
|
2018-09-10 15:40:35 +03:00
|
|
|
}
|
|
|
|
|
2019-10-02 17:36:53 +03:00
|
|
|
public function getTitle(): string {
|
|
|
|
return $this->data->getTitle();
|
|
|
|
}
|
|
|
|
|
2018-09-10 15:40:35 +03:00
|
|
|
public function delete() {
|
2018-10-17 16:21:09 +03:00
|
|
|
$this->trashManager->removeItem($this->data);
|
2018-09-10 15:40:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function restore(): bool {
|
|
|
|
$this->trashManager->restoreItem($this->data);
|
|
|
|
return true;
|
|
|
|
}
|
2018-09-03 19:30:10 +03:00
|
|
|
}
|