diff --git a/apps/dav/lib/caldav/calendar.php b/apps/dav/lib/caldav/calendar.php index 7822c703e9..f34ecfd579 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 2204ca3af6..a5fabcf6e8 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/] + + +
+