@@ -29,95 +29,95 @@ |
||
| 29 | 29 | use Sabre\DAV\ICollection; |
| 30 | 30 | |
| 31 | 31 | class TrashFolder implements ICollection, ITrash { |
| 32 | - /** @var string */ |
|
| 33 | - private $userId; |
|
| 34 | - |
|
| 35 | - /** @var FileInfo */ |
|
| 36 | - private $data; |
|
| 37 | - |
|
| 38 | - public function __construct(string $root, string $userId, FileInfo $data) { |
|
| 39 | - $this->userId = $userId; |
|
| 40 | - $this->data = $data; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - public function createFile($name, $data = null) { |
|
| 44 | - throw new Forbidden(); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function createDirectory($name) { |
|
| 48 | - throw new Forbidden(); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function getChild($name): ITrash { |
|
| 52 | - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->getName(), $this->userId); |
|
| 53 | - |
|
| 54 | - foreach ($entries as $entry) { |
|
| 55 | - if ($entry->getName() === $name) { |
|
| 56 | - if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 57 | - return new TrashFolderFolder($this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 58 | - } |
|
| 59 | - return new TrashFolderFile($this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - throw new NotFound(); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function getChildren(): array { |
|
| 67 | - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->getName(), $this->userId); |
|
| 68 | - |
|
| 69 | - $children = array_map(function (FileInfo $entry) { |
|
| 70 | - if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 71 | - return new TrashFolderFolder($this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 72 | - } |
|
| 73 | - return new TrashFolderFile($this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 74 | - }, $entries); |
|
| 75 | - |
|
| 76 | - return $children; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - public function childExists($name): bool { |
|
| 80 | - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->getName(), $this->userId); |
|
| 81 | - |
|
| 82 | - foreach ($entries as $entry) { |
|
| 83 | - if ($entry->getName() === $name) { |
|
| 84 | - return true; |
|
| 85 | - } |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - return false; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - public function delete() { |
|
| 92 | - \OCA\Files_Trashbin\Trashbin::delete($this->data->getName(), $this->userId, $this->getLastModified()); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function getName(): string { |
|
| 96 | - return $this->data->getName() . '.d' . $this->getLastModified(); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - public function setName($name) { |
|
| 100 | - throw new Forbidden(); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - public function getLastModified(): int { |
|
| 104 | - return $this->data->getMtime(); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function restore(): bool { |
|
| 108 | - return \OCA\Files_Trashbin\Trashbin::restore($this->getName(), $this->data->getName(), $this->getLastModified()); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - public function getFilename(): string { |
|
| 112 | - return $this->data->getName(); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - public function getOriginalLocation(): string { |
|
| 116 | - return $this->data['extraData']; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - public function getDeletionTime(): int { |
|
| 120 | - return $this->getLastModified(); |
|
| 121 | - } |
|
| 32 | + /** @var string */ |
|
| 33 | + private $userId; |
|
| 34 | + |
|
| 35 | + /** @var FileInfo */ |
|
| 36 | + private $data; |
|
| 37 | + |
|
| 38 | + public function __construct(string $root, string $userId, FileInfo $data) { |
|
| 39 | + $this->userId = $userId; |
|
| 40 | + $this->data = $data; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + public function createFile($name, $data = null) { |
|
| 44 | + throw new Forbidden(); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + public function createDirectory($name) { |
|
| 48 | + throw new Forbidden(); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function getChild($name): ITrash { |
|
| 52 | + $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->getName(), $this->userId); |
|
| 53 | + |
|
| 54 | + foreach ($entries as $entry) { |
|
| 55 | + if ($entry->getName() === $name) { |
|
| 56 | + if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 57 | + return new TrashFolderFolder($this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 58 | + } |
|
| 59 | + return new TrashFolderFile($this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + throw new NotFound(); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function getChildren(): array { |
|
| 67 | + $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->getName(), $this->userId); |
|
| 68 | + |
|
| 69 | + $children = array_map(function (FileInfo $entry) { |
|
| 70 | + if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 71 | + return new TrashFolderFolder($this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 72 | + } |
|
| 73 | + return new TrashFolderFile($this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 74 | + }, $entries); |
|
| 75 | + |
|
| 76 | + return $children; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + public function childExists($name): bool { |
|
| 80 | + $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->getName(), $this->userId); |
|
| 81 | + |
|
| 82 | + foreach ($entries as $entry) { |
|
| 83 | + if ($entry->getName() === $name) { |
|
| 84 | + return true; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + return false; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + public function delete() { |
|
| 92 | + \OCA\Files_Trashbin\Trashbin::delete($this->data->getName(), $this->userId, $this->getLastModified()); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function getName(): string { |
|
| 96 | + return $this->data->getName() . '.d' . $this->getLastModified(); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + public function setName($name) { |
|
| 100 | + throw new Forbidden(); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + public function getLastModified(): int { |
|
| 104 | + return $this->data->getMtime(); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function restore(): bool { |
|
| 108 | + return \OCA\Files_Trashbin\Trashbin::restore($this->getName(), $this->data->getName(), $this->getLastModified()); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public function getFilename(): string { |
|
| 112 | + return $this->data->getName(); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + public function getOriginalLocation(): string { |
|
| 116 | + return $this->data['extraData']; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + public function getDeletionTime(): int { |
|
| 120 | + return $this->getLastModified(); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | } |
@@ -28,77 +28,77 @@ |
||
| 28 | 28 | use Sabre\DAV\IFile; |
| 29 | 29 | |
| 30 | 30 | class TrashFolderFile implements IFile, ITrash { |
| 31 | - /** @var string */ |
|
| 32 | - private $root; |
|
| 33 | - |
|
| 34 | - /** @var string */ |
|
| 35 | - private $userId; |
|
| 36 | - |
|
| 37 | - /** @var FileInfo */ |
|
| 38 | - private $data; |
|
| 39 | - |
|
| 40 | - /** @var string */ |
|
| 41 | - private $location; |
|
| 42 | - |
|
| 43 | - public function __construct(string $root, |
|
| 44 | - string $userId, |
|
| 45 | - FileInfo $data, |
|
| 46 | - string $location) { |
|
| 47 | - $this->root = $root; |
|
| 48 | - $this->userId = $userId; |
|
| 49 | - $this->data = $data; |
|
| 50 | - $this->location = $location; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - public function put($data) { |
|
| 54 | - throw new Forbidden(); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - public function get() { |
|
| 58 | - return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb'); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - public function getContentType(): string { |
|
| 62 | - return $this->data->getMimetype(); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - public function getETag(): string { |
|
| 66 | - return $this->data->getEtag(); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public function getSize(): int { |
|
| 70 | - return $this->data->getSize(); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - public function delete() { |
|
| 74 | - \OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - public function getName(): string { |
|
| 78 | - return $this->data->getName(); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - public function setName($name) { |
|
| 82 | - throw new Forbidden(); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - public function getLastModified(): int { |
|
| 86 | - return $this->data->getMtime(); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - public function restore(): bool { |
|
| 90 | - return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - public function getFilename(): string { |
|
| 94 | - return $this->data->getName(); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - public function getOriginalLocation(): string { |
|
| 98 | - return $this->location . '/' . $this->getFilename(); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - public function getDeletionTime(): int { |
|
| 102 | - return $this->getLastModified(); |
|
| 103 | - } |
|
| 31 | + /** @var string */ |
|
| 32 | + private $root; |
|
| 33 | + |
|
| 34 | + /** @var string */ |
|
| 35 | + private $userId; |
|
| 36 | + |
|
| 37 | + /** @var FileInfo */ |
|
| 38 | + private $data; |
|
| 39 | + |
|
| 40 | + /** @var string */ |
|
| 41 | + private $location; |
|
| 42 | + |
|
| 43 | + public function __construct(string $root, |
|
| 44 | + string $userId, |
|
| 45 | + FileInfo $data, |
|
| 46 | + string $location) { |
|
| 47 | + $this->root = $root; |
|
| 48 | + $this->userId = $userId; |
|
| 49 | + $this->data = $data; |
|
| 50 | + $this->location = $location; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + public function put($data) { |
|
| 54 | + throw new Forbidden(); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + public function get() { |
|
| 58 | + return $this->data->getStorage()->fopen($this->data->getInternalPath(), 'rb'); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + public function getContentType(): string { |
|
| 62 | + return $this->data->getMimetype(); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + public function getETag(): string { |
|
| 66 | + return $this->data->getEtag(); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public function getSize(): int { |
|
| 70 | + return $this->data->getSize(); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + public function delete() { |
|
| 74 | + \OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + public function getName(): string { |
|
| 78 | + return $this->data->getName(); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + public function setName($name) { |
|
| 82 | + throw new Forbidden(); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + public function getLastModified(): int { |
|
| 86 | + return $this->data->getMtime(); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + public function restore(): bool { |
|
| 90 | + return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + public function getFilename(): string { |
|
| 94 | + return $this->data->getName(); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + public function getOriginalLocation(): string { |
|
| 98 | + return $this->location . '/' . $this->getFilename(); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + public function getDeletionTime(): int { |
|
| 102 | + return $this->getLastModified(); |
|
| 103 | + } |
|
| 104 | 104 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | public function delete() { |
| 74 | - \OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null); |
|
| 74 | + \OCA\Files_Trashbin\Trashbin::delete($this->root.'/'.$this->getName(), $this->userId, null); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | public function getName(): string { |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function restore(): bool { |
| 90 | - return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null); |
|
| 90 | + return \OCA\Files_Trashbin\Trashbin::restore($this->root.'/'.$this->getName(), $this->data->getName(), null); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | public function getFilename(): string { |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function getOriginalLocation(): string { |
| 98 | - return $this->location . '/' . $this->getFilename(); |
|
| 98 | + return $this->location.'/'.$this->getFilename(); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public function getDeletionTime(): int { |
@@ -24,11 +24,11 @@ |
||
| 24 | 24 | namespace OCA\Files_Trashbin\Sabre; |
| 25 | 25 | |
| 26 | 26 | interface ITrash { |
| 27 | - public function restore(): bool; |
|
| 27 | + public function restore(): bool; |
|
| 28 | 28 | |
| 29 | - public function getFilename(): string; |
|
| 29 | + public function getFilename(): string; |
|
| 30 | 30 | |
| 31 | - public function getOriginalLocation(): string; |
|
| 31 | + public function getOriginalLocation(): string; |
|
| 32 | 32 | |
| 33 | - public function getDeletionTime(): int; |
|
| 33 | + public function getDeletionTime(): int; |
|
| 34 | 34 | } |
@@ -31,39 +31,39 @@ |
||
| 31 | 31 | |
| 32 | 32 | class PropfindPlugin extends ServerPlugin { |
| 33 | 33 | |
| 34 | - const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename'; |
|
| 35 | - const TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location'; |
|
| 36 | - const TRASHBIN_DELETION_TIME = '{http://nextcloud.org/ns}trashbin-deletion-time'; |
|
| 34 | + const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename'; |
|
| 35 | + const TRASHBIN_ORIGINAL_LOCATION = '{http://nextcloud.org/ns}trashbin-original-location'; |
|
| 36 | + const TRASHBIN_DELETION_TIME = '{http://nextcloud.org/ns}trashbin-deletion-time'; |
|
| 37 | 37 | |
| 38 | - /** @var Server */ |
|
| 39 | - private $server; |
|
| 38 | + /** @var Server */ |
|
| 39 | + private $server; |
|
| 40 | 40 | |
| 41 | - public function __construct() { |
|
| 42 | - } |
|
| 41 | + public function __construct() { |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function initialize(Server $server) { |
|
| 45 | - $this->server = $server; |
|
| 44 | + public function initialize(Server $server) { |
|
| 45 | + $this->server = $server; |
|
| 46 | 46 | |
| 47 | - $this->server->on('propFind', [$this, 'propFind']); |
|
| 48 | - } |
|
| 47 | + $this->server->on('propFind', [$this, 'propFind']); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - public function propFind(PropFind $propFind, INode $node) { |
|
| 52 | - if (!($node instanceof ITrash)) { |
|
| 53 | - return; |
|
| 54 | - } |
|
| 51 | + public function propFind(PropFind $propFind, INode $node) { |
|
| 52 | + if (!($node instanceof ITrash)) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - $propFind->handle(self::TRASHBIN_FILENAME, function() use ($node) { |
|
| 57 | - return $node->getFilename(); |
|
| 58 | - }); |
|
| 56 | + $propFind->handle(self::TRASHBIN_FILENAME, function() use ($node) { |
|
| 57 | + return $node->getFilename(); |
|
| 58 | + }); |
|
| 59 | 59 | |
| 60 | - $propFind->handle(self::TRASHBIN_ORIGINAL_LOCATION, function() use ($node) { |
|
| 61 | - return $node->getOriginalLocation(); |
|
| 62 | - }); |
|
| 60 | + $propFind->handle(self::TRASHBIN_ORIGINAL_LOCATION, function() use ($node) { |
|
| 61 | + return $node->getOriginalLocation(); |
|
| 62 | + }); |
|
| 63 | 63 | |
| 64 | - $propFind->handle(self::TRASHBIN_DELETION_TIME, function () use ($node) { |
|
| 65 | - return $node->getDeletionTime(); |
|
| 66 | - }); |
|
| 67 | - } |
|
| 64 | + $propFind->handle(self::TRASHBIN_DELETION_TIME, function () use ($node) { |
|
| 65 | + return $node->getDeletionTime(); |
|
| 66 | + }); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | 69 | } |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | return $node->getOriginalLocation(); |
| 62 | 62 | }); |
| 63 | 63 | |
| 64 | - $propFind->handle(self::TRASHBIN_DELETION_TIME, function () use ($node) { |
|
| 64 | + $propFind->handle(self::TRASHBIN_DELETION_TIME, function() use ($node) { |
|
| 65 | 65 | return $node->getDeletionTime(); |
| 66 | 66 | }); |
| 67 | 67 | } |
@@ -28,66 +28,66 @@ |
||
| 28 | 28 | use Sabre\DAV\IFile; |
| 29 | 29 | |
| 30 | 30 | class TrashFile implements IFile, ITrash { |
| 31 | - /** @var string */ |
|
| 32 | - private $userId; |
|
| 31 | + /** @var string */ |
|
| 32 | + private $userId; |
|
| 33 | 33 | |
| 34 | - /** @var FileInfo */ |
|
| 35 | - private $data; |
|
| 34 | + /** @var FileInfo */ |
|
| 35 | + private $data; |
|
| 36 | 36 | |
| 37 | - public function __construct(string $userId, FileInfo $data) { |
|
| 38 | - $this->userId = $userId; |
|
| 39 | - $this->data = $data; |
|
| 40 | - } |
|
| 37 | + public function __construct(string $userId, FileInfo $data) { |
|
| 38 | + $this->userId = $userId; |
|
| 39 | + $this->data = $data; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public function put($data) { |
|
| 43 | - throw new Forbidden(); |
|
| 44 | - } |
|
| 42 | + public function put($data) { |
|
| 43 | + throw new Forbidden(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - public function get() { |
|
| 47 | - return $this->data->getStorage()->fopen($this->data->getInternalPath().'.d'.$this->getLastModified(), 'rb'); |
|
| 48 | - } |
|
| 46 | + public function get() { |
|
| 47 | + return $this->data->getStorage()->fopen($this->data->getInternalPath().'.d'.$this->getLastModified(), 'rb'); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - public function getContentType(): string { |
|
| 51 | - return $this->data->getMimetype(); |
|
| 52 | - } |
|
| 50 | + public function getContentType(): string { |
|
| 51 | + return $this->data->getMimetype(); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function getETag(): string { |
|
| 55 | - return $this->data->getEtag(); |
|
| 56 | - } |
|
| 54 | + public function getETag(): string { |
|
| 55 | + return $this->data->getEtag(); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function getSize(): int { |
|
| 59 | - return $this->data->getSize(); |
|
| 60 | - } |
|
| 58 | + public function getSize(): int { |
|
| 59 | + return $this->data->getSize(); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - public function delete() { |
|
| 63 | - \OCA\Files_Trashbin\Trashbin::delete($this->data->getName(), $this->userId, $this->getLastModified()); |
|
| 64 | - } |
|
| 62 | + public function delete() { |
|
| 63 | + \OCA\Files_Trashbin\Trashbin::delete($this->data->getName(), $this->userId, $this->getLastModified()); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public function getName(): string { |
|
| 67 | - return $this->data->getName() . '.d' . $this->getLastModified(); |
|
| 68 | - } |
|
| 66 | + public function getName(): string { |
|
| 67 | + return $this->data->getName() . '.d' . $this->getLastModified(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function setName($name) { |
|
| 71 | - throw new Forbidden(); |
|
| 72 | - } |
|
| 70 | + public function setName($name) { |
|
| 71 | + throw new Forbidden(); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public function getLastModified(): int { |
|
| 75 | - return $this->data->getMtime(); |
|
| 76 | - } |
|
| 74 | + public function getLastModified(): int { |
|
| 75 | + return $this->data->getMtime(); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - public function restore(): bool { |
|
| 79 | - return \OCA\Files_Trashbin\Trashbin::restore($this->getName(), $this->data->getName(), $this->getLastModified()); |
|
| 80 | - } |
|
| 78 | + public function restore(): bool { |
|
| 79 | + return \OCA\Files_Trashbin\Trashbin::restore($this->getName(), $this->data->getName(), $this->getLastModified()); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - public function getFilename(): string { |
|
| 83 | - return $this->data->getName(); |
|
| 84 | - } |
|
| 82 | + public function getFilename(): string { |
|
| 83 | + return $this->data->getName(); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function getOriginalLocation(): string { |
|
| 87 | - return $this->data['extraData']; |
|
| 88 | - } |
|
| 86 | + public function getOriginalLocation(): string { |
|
| 87 | + return $this->data['extraData']; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - public function getDeletionTime(): int { |
|
| 91 | - return $this->getLastModified(); |
|
| 92 | - } |
|
| 90 | + public function getDeletionTime(): int { |
|
| 91 | + return $this->getLastModified(); |
|
| 92 | + } |
|
| 93 | 93 | } |
@@ -30,106 +30,106 @@ |
||
| 30 | 30 | |
| 31 | 31 | class TrashFolderFolder implements ICollection, ITrash { |
| 32 | 32 | |
| 33 | - /** @var string */ |
|
| 34 | - private $root; |
|
| 35 | - |
|
| 36 | - /** @var string */ |
|
| 37 | - private $userId; |
|
| 38 | - |
|
| 39 | - /** @var FileInfo */ |
|
| 40 | - private $data; |
|
| 41 | - |
|
| 42 | - /** @var string */ |
|
| 43 | - private $location; |
|
| 44 | - |
|
| 45 | - public function __construct(string $root, |
|
| 46 | - string $userId, |
|
| 47 | - FileInfo $data, |
|
| 48 | - string $location) { |
|
| 49 | - $this->root = $root; |
|
| 50 | - $this->userId = $userId; |
|
| 51 | - $this->data = $data; |
|
| 52 | - $this->location = $location; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - public function createFile($name, $data = null) { |
|
| 56 | - throw new Forbidden(); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - public function createDirectory($name) { |
|
| 60 | - throw new Forbidden(); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - public function getChild($name): ITrash { |
|
| 64 | - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); |
|
| 65 | - |
|
| 66 | - foreach ($entries as $entry) { |
|
| 67 | - if ($entry->getName() === $name) { |
|
| 68 | - if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 69 | - return new TrashFolderFolder($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 70 | - } |
|
| 71 | - return new TrashFolderFile($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - throw new NotFound(); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - public function getChildren(): array { |
|
| 79 | - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); |
|
| 80 | - |
|
| 81 | - $children = array_map(function (FileInfo $entry) { |
|
| 82 | - if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 83 | - return new TrashFolderFolder($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 84 | - } |
|
| 85 | - return new TrashFolderFile($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 86 | - }, $entries); |
|
| 87 | - |
|
| 88 | - return $children; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - public function childExists($name): bool { |
|
| 92 | - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); |
|
| 93 | - |
|
| 94 | - foreach ($entries as $entry) { |
|
| 95 | - if ($entry->getName() === $name) { |
|
| 96 | - return true; |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - return false; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - public function delete() { |
|
| 104 | - \OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - public function getName(): string { |
|
| 108 | - return $this->data->getName(); |
|
| 109 | - |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - public function setName($name) { |
|
| 113 | - throw new Forbidden(); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - public function getLastModified(): int { |
|
| 117 | - return $this->data->getMtime(); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - public function restore(): bool { |
|
| 121 | - return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - public function getFilename(): string { |
|
| 125 | - return $this->data->getName(); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - public function getOriginalLocation(): string { |
|
| 129 | - return $this->location . '/' . $this->getFilename(); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - public function getDeletionTime(): int { |
|
| 133 | - return $this->getLastModified(); |
|
| 134 | - } |
|
| 33 | + /** @var string */ |
|
| 34 | + private $root; |
|
| 35 | + |
|
| 36 | + /** @var string */ |
|
| 37 | + private $userId; |
|
| 38 | + |
|
| 39 | + /** @var FileInfo */ |
|
| 40 | + private $data; |
|
| 41 | + |
|
| 42 | + /** @var string */ |
|
| 43 | + private $location; |
|
| 44 | + |
|
| 45 | + public function __construct(string $root, |
|
| 46 | + string $userId, |
|
| 47 | + FileInfo $data, |
|
| 48 | + string $location) { |
|
| 49 | + $this->root = $root; |
|
| 50 | + $this->userId = $userId; |
|
| 51 | + $this->data = $data; |
|
| 52 | + $this->location = $location; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + public function createFile($name, $data = null) { |
|
| 56 | + throw new Forbidden(); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + public function createDirectory($name) { |
|
| 60 | + throw new Forbidden(); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + public function getChild($name): ITrash { |
|
| 64 | + $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); |
|
| 65 | + |
|
| 66 | + foreach ($entries as $entry) { |
|
| 67 | + if ($entry->getName() === $name) { |
|
| 68 | + if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 69 | + return new TrashFolderFolder($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 70 | + } |
|
| 71 | + return new TrashFolderFile($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + throw new NotFound(); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + public function getChildren(): array { |
|
| 79 | + $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); |
|
| 80 | + |
|
| 81 | + $children = array_map(function (FileInfo $entry) { |
|
| 82 | + if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
|
| 83 | + return new TrashFolderFolder($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 84 | + } |
|
| 85 | + return new TrashFolderFile($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 86 | + }, $entries); |
|
| 87 | + |
|
| 88 | + return $children; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + public function childExists($name): bool { |
|
| 92 | + $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); |
|
| 93 | + |
|
| 94 | + foreach ($entries as $entry) { |
|
| 95 | + if ($entry->getName() === $name) { |
|
| 96 | + return true; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + return false; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + public function delete() { |
|
| 104 | + \OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + public function getName(): string { |
|
| 108 | + return $this->data->getName(); |
|
| 109 | + |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + public function setName($name) { |
|
| 113 | + throw new Forbidden(); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + public function getLastModified(): int { |
|
| 117 | + return $this->data->getMtime(); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + public function restore(): bool { |
|
| 121 | + return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + public function getFilename(): string { |
|
| 125 | + return $this->data->getName(); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + public function getOriginalLocation(): string { |
|
| 129 | + return $this->location . '/' . $this->getFilename(); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + public function getDeletionTime(): int { |
|
| 133 | + return $this->getLastModified(); |
|
| 134 | + } |
|
| 135 | 135 | } |
@@ -61,14 +61,14 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | public function getChild($name): ITrash { |
| 64 | - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); |
|
| 64 | + $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root.'/'.$this->getName(), $this->userId); |
|
| 65 | 65 | |
| 66 | 66 | foreach ($entries as $entry) { |
| 67 | 67 | if ($entry->getName() === $name) { |
| 68 | 68 | if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
| 69 | - return new TrashFolderFolder($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 69 | + return new TrashFolderFolder($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 70 | 70 | } |
| 71 | - return new TrashFolderFile($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 71 | + return new TrashFolderFile($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public function getChildren(): array { |
| 79 | - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); |
|
| 79 | + $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root.'/'.$this->getName(), $this->userId); |
|
| 80 | 80 | |
| 81 | - $children = array_map(function (FileInfo $entry) { |
|
| 81 | + $children = array_map(function(FileInfo $entry) { |
|
| 82 | 82 | if ($entry->getType() === FileInfo::TYPE_FOLDER) { |
| 83 | 83 | return new TrashFolderFolder($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation()); |
| 84 | 84 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function childExists($name): bool { |
| 92 | - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); |
|
| 92 | + $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root.'/'.$this->getName(), $this->userId); |
|
| 93 | 93 | |
| 94 | 94 | foreach ($entries as $entry) { |
| 95 | 95 | if ($entry->getName() === $name) { |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | public function delete() { |
| 104 | - \OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null); |
|
| 104 | + \OCA\Files_Trashbin\Trashbin::delete($this->root.'/'.$this->getName(), $this->userId, null); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function getName(): string { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public function restore(): bool { |
| 121 | - return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null); |
|
| 121 | + return \OCA\Files_Trashbin\Trashbin::restore($this->root.'/'.$this->getName(), $this->data->getName(), null); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | public function getFilename(): string { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | public function getOriginalLocation(): string { |
| 129 | - return $this->location . '/' . $this->getFilename(); |
|
| 129 | + return $this->location.'/'.$this->getFilename(); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | public function getDeletionTime(): int { |