diff options
Diffstat (limited to 'apps/files_trashbin/lib/Sabre/TrashFolderFolder.php')
-rw-r--r-- | apps/files_trashbin/lib/Sabre/TrashFolderFolder.php | 91 |
1 files changed, 2 insertions, 89 deletions
diff --git a/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php b/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php index 4ee9a0e2db0..5332b7dd4c0 100644 --- a/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php +++ b/apps/files_trashbin/lib/Sabre/TrashFolderFolder.php @@ -21,95 +21,8 @@ declare(strict_types=1); * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ -namespace OCA\Files_Trashbin\Sabre; - -use OCP\Files\FileInfo; -use Sabre\DAV\Exception\Forbidden; -use Sabre\DAV\Exception\NotFound; -use Sabre\DAV\ICollection; - -class TrashFolderFolder extends AbstractTrash implements ICollection, ITrash { - - /** @var string */ - private $root; - - /** @var string */ - private $userId; - - /** @var string */ - private $location; - - public function __construct(string $root, - string $userId, - FileInfo $data, - string $location) { - $this->root = $root; - $this->userId = $userId; - $this->location = $location; - parent::__construct($data); - } - - public function createFile($name, $data = null) { - throw new Forbidden(); - } - - public function createDirectory($name) { - throw new Forbidden(); - } - - public function getChild($name): ITrash { - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); - - foreach ($entries as $entry) { - if ($entry->getName() === $name) { - if ($entry->getType() === FileInfo::TYPE_FOLDER) { - return new TrashFolderFolder($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation()); - } - return new TrashFolderFile($this->root . '/' . $this->getName(), $this->userId, $entry, $this->getOriginalLocation()); - } - } - throw new NotFound(); - } - - public function getChildren(): array { - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); - - $children = array_map(function (FileInfo $entry) { - if ($entry->getType() === FileInfo::TYPE_FOLDER) { - return new TrashFolderFolder($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation()); - } - return new TrashFolderFile($this->root.'/'.$this->getName(), $this->userId, $entry, $this->getOriginalLocation()); - }, $entries); - - return $children; - } - - public function childExists($name): bool { - $entries = \OCA\Files_Trashbin\Helper::getTrashFiles($this->root . '/' . $this->getName(), $this->userId); - - foreach ($entries as $entry) { - if ($entry->getName() === $name) { - return true; - } - } - - return false; - } - - public function delete() { - \OCA\Files_Trashbin\Trashbin::delete($this->root . '/' . $this->getName(), $this->userId, null); - } - - public function setName($name) { - throw new Forbidden(); - } - - public function restore(): bool { - return \OCA\Files_Trashbin\Trashbin::restore($this->root . '/' . $this->getName(), $this->data->getName(), null); - } +namespace OCA\Files_Trashbin\Sabre; - public function getOriginalLocation(): string { - return $this->location . '/' . $this->getFilename(); - } +class TrashFolderFolder extends AbstractTrashFolder { } |