1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) 2018 Robin Appelman <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @license GNU AGPL version 3 or any later version |
7
|
|
|
* |
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
11
|
|
|
* License, or (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Affero General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace OCA\Files_Trashbin\Sabre; |
24
|
|
|
|
25
|
|
|
use OCA\Files_Trashbin\Trash\ITrashItem; |
26
|
|
|
use OCA\Files_Trashbin\Trash\ITrashManager; |
27
|
|
|
use OCP\Files\FileInfo; |
28
|
|
|
use OCP\IUser; |
29
|
|
|
|
30
|
|
|
abstract class AbstractTrash implements ITrash { |
31
|
|
|
/** @var ITrashItem */ |
32
|
|
|
protected $data; |
33
|
|
|
|
34
|
|
|
/** @var ITrashManager */ |
35
|
|
|
protected $trashManager; |
36
|
|
|
|
37
|
|
|
public function __construct(ITrashManager $trashManager, ITrashItem $data) { |
38
|
|
|
$this->trashManager = $trashManager; |
39
|
|
|
$this->data = $data; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getFilename(): string { |
43
|
|
|
return $this->data->getName(); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getDeletionTime(): int { |
47
|
|
|
return $this->data->getDeletedTime(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getFileId(): int { |
51
|
|
|
return $this->data->getId(); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getFileInfo(): FileInfo { |
55
|
|
|
return $this->data; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getSize(): int { |
59
|
|
|
return $this->data->getSize(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getLastModified(): int { |
63
|
|
|
return $this->data->getMtime(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getContentType(): string { |
67
|
|
|
return $this->data->getMimetype(); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getETag(): string { |
71
|
|
|
return $this->data->getEtag(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getName(): string { |
75
|
|
|
return $this->data->getName(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getOriginalLocation(): string { |
79
|
|
|
return $this->data->getOriginalLocation(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getTitle(): string { |
83
|
|
|
return $this->data->getTitle(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public function delete() { |
87
|
|
|
$this->trashManager->removeItem($this->data); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function restore(): bool { |
91
|
|
|
$this->trashManager->restoreItem($this->data); |
92
|
|
|
return true; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|