From 5c2692a8ea6de0a5e0ccfa0a2b9508d2d62266c6 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 8 Nov 2015 16:36:36 -0800 Subject: no comment permission bug, also implement delete() in RedDirectory per Waitman --- include/RedDAV/RedDirectory.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include') diff --git a/include/RedDAV/RedDirectory.php b/include/RedDAV/RedDirectory.php index 87bdf8f13..8d8af5bd3 100644 --- a/include/RedDAV/RedDirectory.php +++ b/include/RedDAV/RedDirectory.php @@ -362,6 +362,27 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota { } } + /** + * @brief delete directory + */ + + public function delete() { + logger('delete file ' . basename($this->red_path), LOGGER_DEBUG); + + if ((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id, $this->auth->observer, 'write_storage'))) { + throw new DAV\Exception\Forbidden('Permission denied.'); + } + + if ($this->auth->owner_id !== $this->auth->channel_id) { + if (($this->auth->observer !== $this->data['creator']) || intval($this->data['is_dir'])) { + throw new DAV\Exception\Forbidden('Permission denied.'); + } + } + + attach_delete($this->auth->owner_id, $this->folder_hash); + } + + /** * @brief Checks if a child exists. * -- cgit v1.2.3