diff options
author | Georg Ehrke <developer@georgehrke.com> | 2018-10-17 16:06:31 +0200 |
---|---|---|
committer | Georg Ehrke <developer@georgehrke.com> | 2018-10-22 15:48:18 +0200 |
commit | 218253db76af43a6a9d3c816633429082be33717 (patch) | |
tree | 1e6509dbfd377c175ef5561073b9ddf53bc39d32 /apps/dav/lib | |
parent | 10f0296ad6e51be99b36e2855e260f9092f61175 (diff) | |
download | nextcloud-server-218253db76af43a6a9d3c816633429082be33717.tar.gz nextcloud-server-218253db76af43a6a9d3c816633429082be33717.zip |
allow user principal search for dav displayname property
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r-- | apps/dav/lib/Connector/Sabre/Principal.php | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Principal.php b/apps/dav/lib/Connector/Sabre/Principal.php index cbfa1bc83e0..2574fbcd436 100644 --- a/apps/dav/lib/Connector/Sabre/Principal.php +++ b/apps/dav/lib/Connector/Sabre/Principal.php @@ -1,6 +1,7 @@ <?php /** * @copyright Copyright (c) 2016, ownCloud, Inc. + * @copyright Copyright (c) 2018, Georg Ehrke * * @author Bart Visscher <bartv@thisnet.nl> * @author Jakob Sack <mail@jakobsack.de> @@ -11,6 +12,7 @@ * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Thomas Tanghus <thomas@tanghus.net> * @author Vincent Petry <pvince81@owncloud.com> + * @author Georg Ehrke <oc.list@georgehrke.com> * * @license AGPL-3.0 * @@ -249,6 +251,23 @@ class Principal implements BackendInterface { }, []); break; + case '{DAV:}displayname': + $users = $this->userManager->searchDisplayName($value); + + $results[] = array_reduce($users, function(array $carry, IUser $user) use ($restrictGroups) { + // is sharing restricted to groups only? + if ($restrictGroups !== false) { + $userGroups = $this->groupManager->getUserGroupIds($user); + if (count(array_intersect($userGroups, $restrictGroups)) === 0) { + return $carry; + } + } + + $carry[] = $this->principalPrefix . '/' . $user->getUID(); + return $carry; + }, []); + break; + default: $results[] = []; break; @@ -263,11 +282,11 @@ class Principal implements BackendInterface { switch ($test) { case 'anyof': - return array_unique(array_merge(...$results)); + return array_values(array_unique(array_merge(...$results))); case 'allof': default: - return array_intersect(...$results); + return array_values(array_intersect(...$results)); } } @@ -354,6 +373,7 @@ class Principal implements BackendInterface { $principal = [ 'uri' => $this->principalPrefix . '/' . $userId, '{DAV:}displayname' => is_null($displayName) ? $userId : $displayName, + '{urn:ietf:params:xml:ns:caldav}calendar-user-type' => 'INDIVIDUAL', ]; $email = $user->getEMailAddress(); |