1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* @copyright 2018, Roeland Jago Douma <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @author Roeland Jago Douma <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @license GNU AGPL version 3 or any later version |
9
|
|
|
* |
10
|
|
|
* This program is free software: you can redistribute it and/or modify |
11
|
|
|
* it under the terms of the GNU Affero General Public License as |
12
|
|
|
* published by the Free Software Foundation, either version 3 of the |
13
|
|
|
* License, or (at your option) any later version. |
14
|
|
|
* |
15
|
|
|
* This program is distributed in the hope that it will be useful, |
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
* GNU Affero General Public License for more details. |
19
|
|
|
* |
20
|
|
|
* You should have received a copy of the GNU Affero General Public License |
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
namespace OCA\Files_Trashbin\Sabre; |
25
|
|
|
|
26
|
|
|
use OCP\Files\FileInfo; |
27
|
|
|
use Sabre\DAV\Exception\Forbidden; |
28
|
|
|
use Sabre\DAV\IFile; |
29
|
|
|
|
30
|
|
|
class TrashFolderFile extends AbstractTrash implements IFile, ITrash { |
31
|
|
|
/** @var string */ |
32
|
|
|
private $root; |
33
|
|
|
|
34
|
|
|
/** @var string */ |
35
|
|
|
private $userId; |
36
|
|
|
|
37
|
|
|
/** @var string */ |
38
|
|
|
private $location; |
39
|
|
|
|
40
|
|
View Code Duplication |
public function __construct(string $root, |
41
|
|
|
string $userId, |
42
|
|
|
FileInfo $data, |
43
|
|
|
string $location) { |
44
|
|
|
$this->root = $root; |
45
|
|
|
$this->userId = $userId; |
46
|
|
|
$this->location = $location; |
47
|
|
|
parent::__construct($data); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function put($data) { |
51
|
|
|
throw new Forbidden(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function get() { |
55
|
|
|
return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function delete() { |
59
|
|
|
\OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function setName($name) { |
63
|
|
|
throw new Forbidden(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function restore(): bool { |
67
|
|
|
return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getOriginalLocation(): string { |
71
|
|
|
return $this->location . '/' . $this->getFilename(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|