From 4e2f9ce05ba8b8a8d695fc85b5ef56b35e2d59cb Mon Sep 17 00:00:00 2001 From: Joas Schilling <nickvergessen@owncloud.com> Date: Fri, 12 Feb 2016 14:38:43 +0100 Subject: [PATCH] Convert the old principal to the new principal before getting calendars --- apps/dav/lib/caldav/caldavbackend.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/caldav/caldavbackend.php b/apps/dav/lib/caldav/caldavbackend.php index c674876598..7f6810fb1e 100644 --- a/apps/dav/lib/caldav/caldavbackend.php +++ b/apps/dav/lib/caldav/caldavbackend.php @@ -138,6 +138,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @return array */ function getCalendarsForUser($principalUri) { + $principalUri = $this->convertPrincipal($principalUri, true); $fields = array_values($this->propertyMap); $fields[] = 'id'; $fields[] = 'uri'; @@ -164,7 +165,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar = [ 'id' => $row['id'], 'uri' => $row['uri'], - 'principaluri' => $row['principaluri'], + 'principaluri' => $this->convertPrincipal($row['principaluri'], false), '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), @@ -1093,7 +1094,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $newValues = []; foreach($mutations as $propertyName=>$propertyValue) { - if ($propertyName === '{http://calendarserver.org/ns/}source') { + if ($propertyName === '{http://calendarserver.org/ns/}source') { $newValues['source'] = $propertyValue->getHref(); } else { $fieldName = $this->subscriptionPropertyMap[$propertyName]; @@ -1373,4 +1374,14 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription return $this->sharingBackend->applyShareAcl($resourceId, $acl); } + private function convertPrincipal($principalUri, $toV2) { + if ($this->principalBackend->getPrincipalPrefix() === 'principals') { + list(, $name) = URLUtil::splitPath($principalUri); + if ($toV2 === true) { + return "principals/users/$name"; + } + return "principals/$name"; + } + return $principalUri; + } } -- GitLab