]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't show users which e-mail address match if they belong to a group we may not... 7567/head
authorTobia De Koninck <tobia@ledfan.be>
Tue, 19 Dec 2017 07:43:08 +0000 (08:43 +0100)
committerTobia De Koninck <tobia@ledfan.be>
Tue, 19 Dec 2017 07:43:08 +0000 (08:43 +0100)
Signed-off-by: Tobia De Koninck <tobia@ledfan.be>
apps/files_sharing/lib/Controller/ShareesAPIController.php

index 33341d20b5c8f64fc3e1c443cbc16806399c3863..5e601f75b959e969e742544fc42c55e6837bfb99 100644 (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]);