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 <tobia@ledfan.be>
This commit is contained in:
Tobia De Koninck 2017-12-19 08:43:08 +01:00
parent 6859e5a22a
commit 7f18a8d19f
1 changed files with 16 additions and 0 deletions

View File

@ -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]);