diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-03-12 11:20:04 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2021-05-31 07:49:19 +0200 |
commit | d6d8e9215c69a9e8d4bfa2035c657b0a037f3a2f (patch) | |
tree | 942254503672d6ab3e0b6c8fca0bd4053db352b9 /apps/dav/lib/CalDAV/CalendarHome.php | |
parent | 9e596dd0cf455dc1639141c695f89c7d936f4c0c (diff) | |
download | nextcloud-server-d6d8e9215c69a9e8d4bfa2035c657b0a037f3a2f.tar.gz nextcloud-server-d6d8e9215c69a9e8d4bfa2035c657b0a037f3a2f.zip |
Add a trashbin for calendars and calendar objects
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/lib/CalDAV/CalendarHome.php')
-rw-r--r-- | apps/dav/lib/CalDAV/CalendarHome.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/apps/dav/lib/CalDAV/CalendarHome.php b/apps/dav/lib/CalDAV/CalendarHome.php index c746ab04112..c418ff049c1 100644 --- a/apps/dav/lib/CalDAV/CalendarHome.php +++ b/apps/dav/lib/CalDAV/CalendarHome.php @@ -30,6 +30,7 @@ namespace OCA\DAV\CalDAV; use OCA\DAV\AppInfo\PluginManager; use OCA\DAV\CalDAV\Integration\ExternalCalendar; use OCA\DAV\CalDAV\Integration\ICalendarProvider; +use OCA\DAV\CalDAV\Trashbin\TrashbinHome; use Sabre\CalDAV\Backend\BackendInterface; use Sabre\CalDAV\Backend\NotificationSupport; use Sabre\CalDAV\Backend\SchedulingSupport; @@ -38,6 +39,7 @@ use Sabre\CalDAV\Schedule\Inbox; use Sabre\CalDAV\Subscriptions\Subscription; use Sabre\DAV\Exception\MethodNotAllowed; use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\INode; use Sabre\DAV\MkCol; class CalendarHome extends \Sabre\CalDAV\CalendarHome { @@ -74,8 +76,11 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome { /** * @inheritdoc */ - public function createExtendedCollection($name, MkCol $mkCol) { - $reservedNames = [BirthdayService::BIRTHDAY_CALENDAR_URI]; + public function createExtendedCollection($name, MkCol $mkCol): void { + $reservedNames = [ + BirthdayService::BIRTHDAY_CALENDAR_URI, + TrashbinHome::NAME, + ]; if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) { throw new MethodNotAllowed('The resource you tried to create has a reserved name'); @@ -104,6 +109,10 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome { $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); } + if ($this->caldavBackend instanceof CalDavBackend) { + $objects[] = new TrashbinHome($this->caldavBackend, $this->principalInfo); + } + // If the backend supports subscriptions, we'll add those as well, if ($this->caldavBackend instanceof SubscriptionSupport) { foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { @@ -127,7 +136,9 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome { } /** - * @inheritdoc + * @param string $name + * + * @return INode */ public function getChild($name) { // Special nodes @@ -140,6 +151,9 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome { if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) { return new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); } + if ($name === TrashbinHome::NAME && $this->caldavBackend instanceof CalDavBackend) { + return new TrashbinHome($this->caldavBackend, $this->principalInfo); + } // Calendars foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { |