summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/api
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-12-02 16:01:01 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-12-02 16:01:01 +0100
commit372f54075fda0567d9df977b2e49ed1fdae0a60a (patch)
treef6105944a371af16ab568d5945909906143aa089 /apps/files_sharing/api
parent8d218bf3ef842d76c2b97a175b28e13054497952 (diff)
downloadnextcloud-server-372f54075fda0567d9df977b2e49ed1fdae0a60a.tar.gz
nextcloud-server-372f54075fda0567d9df977b2e49ed1fdae0a60a.zip
Only return the exact match, when it's allowed
Diffstat (limited to 'apps/files_sharing/api')
-rw-r--r--apps/files_sharing/api/sharees.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/apps/files_sharing/api/sharees.php b/apps/files_sharing/api/sharees.php
index 21f68d9b253..24b51d7afe4 100644
--- a/apps/files_sharing/api/sharees.php
+++ b/apps/files_sharing/api/sharees.php
@@ -120,6 +120,7 @@ class Sharees {
protected function getUsers($search) {
$this->result['users'] = $this->result['exact']['users'] = $users = [];
+ $userGroups = [];
if ($this->shareWithGroupOnly) {
// Search in all the groups this user is part of
$userGroups = $this->groupManager->getUserGroupIds($this->userSession->getUser());
@@ -171,13 +172,23 @@ class Sharees {
// user id and if so, we add that to the exact match list
$user = $this->userManager->get($search);
if ($user instanceof IUser) {
- array_push($this->result['exact']['users'], [
- 'label' => $user->getDisplayName(),
- 'value' => [
- 'shareType' => Share::SHARE_TYPE_USER,
- 'shareWith' => $user->getUID(),
- ],
- ]);
+ $addUser = true;
+
+ if ($this->shareWithGroupOnly) {
+ // Only add, if we have a common group
+ $commonGroups = array_intersect($userGroups, $this->groupManager->getUserGroupIds($user));
+ $addUser = !empty($commonGroups);
+ }
+
+ if ($addUser) {
+ array_push($this->result['exact']['users'], [
+ 'label' => $user->getDisplayName(),
+ 'value' => [
+ 'shareType' => Share::SHARE_TYPE_USER,
+ 'shareWith' => $user->getUID(),
+ ],
+ ]);
+ }
}
}