diff options
author | Georg Ehrke <developer@georgehrke.com> | 2017-04-19 16:18:44 +0200 |
---|---|---|
committer | Georg Ehrke <developer@georgehrke.com> | 2017-04-23 11:26:49 +0200 |
commit | c89e057d2765f0e594224ec24fcc424b75a01a87 (patch) | |
tree | 7deaf5216deb215f6ab8f3fc5df7a6ba176d8c1d /apps/dav/lib | |
parent | 11c795388848807590cb56befb28cafec17be3bd (diff) | |
download | nextcloud-server-c89e057d2765f0e594224ec24fcc424b75a01a87.tar.gz nextcloud-server-c89e057d2765f0e594224ec24fcc424b75a01a87.zip |
add owner-displayname property to calendars and addressbooks
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 30 | ||||
-rw-r--r-- | apps/dav/lib/CardDAV/CardDavBackend.php | 49 | ||||
-rw-r--r-- | apps/dav/lib/DAV/Sharing/Plugin.php | 1 |
3 files changed, 70 insertions, 10 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 631593974e7..a4fed4f1982 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -248,6 +248,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar[$xmlName] = $row[$dbName]; } + $this->addOwnerPrincipal($calendar); + if (!isset($calendars[$calendar['id']])) { $calendars[$calendar['id']] = $calendar; } @@ -319,6 +321,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar[$xmlName] = $row[$dbName]; } + $this->addOwnerPrincipal($calendar); + $calendars[$calendar['id']] = $calendar; } $result->closeCursor(); @@ -359,6 +363,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription foreach($this->propertyMap as $xmlName=>$dbName) { $calendar[$xmlName] = $row[$dbName]; } + + $this->addOwnerPrincipal($calendar); + if (!isset($calendars[$calendar['id']])) { $calendars[$calendar['id']] = $calendar; } @@ -428,6 +435,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar[$xmlName] = $row[$dbName]; } + $this->addOwnerPrincipal($calendar); + if (!isset($calendars[$calendar['id']])) { $calendars[$calendar['id']] = $calendar; } @@ -492,6 +501,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar[$xmlName] = $row[$dbName]; } + $this->addOwnerPrincipal($calendar); + return $calendar; } @@ -543,6 +554,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar[$xmlName] = $row[$dbName]; } + $this->addOwnerPrincipal($calendar); + return $calendar; } @@ -587,6 +600,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar[$xmlName] = $row[$dbName]; } + $this->addOwnerPrincipal($calendar); + return $calendar; } @@ -1815,4 +1830,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription } return $principalUri; } + + private function addOwnerPrincipal(&$calendarInfo) { + $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'; + $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'; + if (isset($calendarInfo[$ownerPrincipalKey])) { + $uri = $calendarInfo[$ownerPrincipalKey]; + } else { + $uri = $calendarInfo['principaluri']; + } + + $principalInformation = $this->principalBackend->getPrincipalByPath($uri); + if (isset($principalInformation['{DAV:}displayname'])) { + $calendarInfo[$displaynameKey] = $principalInformation['{DAV:}displayname']; + } + } } diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php index 397a77c1d1b..5929e21fe58 100644 --- a/apps/dav/lib/CardDAV/CardDavBackend.php +++ b/apps/dav/lib/CardDAV/CardDavBackend.php @@ -155,6 +155,8 @@ class CardDavBackend implements BackendInterface, SyncSupport { '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', ]; + + $this->addOwnerPrincipal($addressBooks[$row['id']]); } $result->closeCursor(); @@ -206,6 +208,8 @@ class CardDavBackend implements BackendInterface, SyncSupport { '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], $readOnlyPropertyName => $readOnly, ]; + + $this->addOwnerPrincipal($addressBooks[$row['id']]); } $result->closeCursor(); @@ -233,6 +237,8 @@ class CardDavBackend implements BackendInterface, SyncSupport { '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', ]; + + $this->addOwnerPrincipal($addressBooks[$row['id']]); } $result->closeCursor(); @@ -269,7 +275,7 @@ class CardDavBackend implements BackendInterface, SyncSupport { return null; } - return [ + $addressBook = [ 'id' => $row['id'], 'uri' => $row['uri'], 'principaluri' => $row['principaluri'], @@ -278,6 +284,10 @@ class CardDavBackend implements BackendInterface, SyncSupport { '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', ]; + + $this->addOwnerPrincipal($addressBook); + + return $addressBook; } /** @@ -299,15 +309,19 @@ class CardDavBackend implements BackendInterface, SyncSupport { return null; } - return [ - 'id' => $row['id'], - 'uri' => $row['uri'], - 'principaluri' => $row['principaluri'], - '{DAV:}displayname' => $row['displayname'], - '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], - '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], - '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', - ]; + $addressBook = [ + 'id' => $row['id'], + 'uri' => $row['uri'], + 'principaluri' => $row['principaluri'], + '{DAV:}displayname' => $row['displayname'], + '{' . Plugin::NS_CARDDAV . '}addressbook-description' => $row['description'], + '{http://calendarserver.org/ns/}getctag' => $row['synctoken'], + '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', + ]; + + $this->addOwnerPrincipal($addressBook); + + return $addressBook; } /** @@ -1087,4 +1101,19 @@ class CardDavBackend implements BackendInterface, SyncSupport { } return $principalUri; } + + private function addOwnerPrincipal(&$addressbookInfo) { + $ownerPrincipalKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal'; + $displaynameKey = '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_NEXTCLOUD . '}owner-displayname'; + if (isset($addressbookInfo[$ownerPrincipalKey])) { + $uri = $addressbookInfo[$ownerPrincipalKey]; + } else { + $uri = $addressbookInfo['principaluri']; + } + + $principalInformation = $this->principalBackend->getPrincipalByPath($uri); + if (isset($principalInformation['{DAV:}displayname'])) { + $addressbookInfo[$displaynameKey] = $principalInformation['{DAV:}displayname']; + } + } } diff --git a/apps/dav/lib/DAV/Sharing/Plugin.php b/apps/dav/lib/DAV/Sharing/Plugin.php index 4cd95fe8a34..6f52721ac1e 100644 --- a/apps/dav/lib/DAV/Sharing/Plugin.php +++ b/apps/dav/lib/DAV/Sharing/Plugin.php @@ -37,6 +37,7 @@ use Sabre\HTTP\ResponseInterface; class Plugin extends ServerPlugin { const NS_OWNCLOUD = 'http://owncloud.org/ns'; + const NS_NEXTCLOUD = 'http://nextcloud.com/ns'; /** @var Auth */ private $auth; |