From ef06d6bdaaa5b0686bd1f6fb32866cfe36481434 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20M=C3=BCller?= Date: Tue, 2 Feb 2016 13:07:14 +0100 Subject: [PATCH] Deleting a shared calendar results in unshare --- apps/dav/lib/caldav/calendar.php | 16 ++++- .../tests/CalDAV/sharing-calendars.xml | 67 +++++++++++++++++++ apps/dav/tests/unit/caldav/calendartest.php | 41 ++++++++++++ 3 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 apps/dav/tests/unit/caldav/calendartest.php diff --git a/apps/dav/lib/caldav/calendar.php b/apps/dav/lib/caldav/calendar.php index 7822c703e91..f34ecfd5791 100644 --- a/apps/dav/lib/caldav/calendar.php +++ b/apps/dav/lib/caldav/calendar.php @@ -72,9 +72,21 @@ class Calendar extends \Sabre\CalDAV\Calendar implements IShareable { } function getOwner() { - if (isset($this->calendarInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'])) { - return $this->calendarInfo['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal']; + if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { + return $this->calendarInfo['{http://owncloud.org/ns}owner-principal']; } return parent::getOwner(); } + + function delete() { + if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) { + /** @var CalDavBackend $calDavBackend */ + $calDavBackend = $this->caldavBackend; + $calDavBackend->updateShares($this, [], [ + 'href' => "principal:" . parent::getOwner() + ]); + return; + } + parent::delete(); + } } diff --git a/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml b/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml index 2204ca3af69..a5fabcf6e82 100644 --- a/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml +++ b/apps/dav/tests/travis/caldavtest/tests/CalDAV/sharing-calendars.xml @@ -278,6 +278,73 @@ + + Un-share by delete + + DELETE + $calendarhome2:/shared_shared_by_user01/ + + statusCode + + + + + Original calendar still exists + + PROPFIND + $calendarhome1:/shared/ +
+ Depth + 0 +
+ + text/xml; charset=utf-8 + Resource/CalDAV/sharing/calendars/read-write/4.xml + + + xmlElementMatch + + exists + $verify-property-prefix:/{DAV:}owner/{DAV:}href[=$principaluri1:] + $verify-property-prefix:/{DAV:}resourcetype/{DAV:}collection + $verify-property-prefix:/{DAV:}resourcetype/{urn:ietf:params:xml:ns:caldav}calendar + + $verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}read + $verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}write + $verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}bind + $verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}unbind + + + + notexists + $verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}admin + $verify-property-prefix:/{DAV:}current-user-privilege-set/{DAV:}privilege/{DAV:}all + + +
+
+ + Shared calendar no longer exists Depth:1 + + PROPFIND + $calendarhome2: +
+ Depth + 1 +
+ + text/xml; charset=utf-8 + Resource/CalDAV/sharing/calendars/read-write/4.xml + + + xmlElementMatch + + notexists + $multistatus-response-prefix:[^{DAV:}href=$calendarhome2:/shared_shared_by_user01/] + + +
+