From 7f18a8d19f879d19440c67641d04656deb705cd5 Mon Sep 17 00:00:00 2001 From: Tobia De Koninck Date: Tue, 19 Dec 2017 08:43:08 +0100 Subject: [PATCH] Don't show users which e-mail address match if they belong to a group we may not share with Signed-off-by: Tobia De Koninck --- .../lib/Controller/ShareesAPIController.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 33341d20b5c..5e601f75b95 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -614,6 +614,22 @@ class ShareesAPIController extends OCSController { $exactEmailMatch = strtolower($emailAddress) === $lowerSearch; if (isset($contact['isLocalSystemBook'])) { + if ($this->shareWithGroupOnly) { + /* + * Check if the user may share with the user associated with the e-mail of the just found contact + */ + $userGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser()); + $found = false; + foreach ($userGroups as $userGroup) { + if ($this->groupManager->isInGroup($contact['UID'], $userGroup)) { + $found = true; + break; + } + } + if (!$found) { + continue; + } + } if ($exactEmailMatch) { try { $cloud = $this->cloudIdManager->resolveCloudId($contact['CLOUD'][0]); -- 2.39.5