summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-04-24 09:17:55 +0200
committerGitHub <noreply@github.com>2017-04-24 09:17:55 +0200
commitd842b29c5b4074452433e81c2ceecb822a50364e (patch)
treed32922d78fd196f644aa212290e5b20b4a208be6 /apps/dav/lib
parent1c2cdc9d3aeae0cb1f2f5d4fe3c19f4666affddf (diff)
parentc89e057d2765f0e594224ec24fcc424b75a01a87 (diff)
downloadnextcloud-server-d842b29c5b4074452433e81c2ceecb822a50364e.tar.gz
nextcloud-server-d842b29c5b4074452433e81c2ceecb822a50364e.zip
Merge pull request #4401 from nextcloud/caldav-carddav-nc-owner-displayname
add owner-displayname property to calendars and addressbooks
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php30
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php49
-rw-r--r--apps/dav/lib/DAV/Sharing/Plugin.php1
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 f7963c0fa2b..cd010b87f08 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();
@@ -232,6 +236,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();
@@ -268,7 +274,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
return null;
}
- return [
+ $addressBook = [
'id' => $row['id'],
'uri' => $row['uri'],
'principaluri' => $row['principaluri'],
@@ -277,6 +283,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;
}
/**
@@ -298,15 +308,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;
}
/**
@@ -1086,4 +1100,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;