summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2015-03-25 09:13:51 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2015-03-25 09:13:51 +0100
commit9c19a5dbcc422b361618ca979271bc6218ff33b7 (patch)
treeb115ed7c8664549a56c78edfae6bab62a7ab5436
parentfb618894902331fdd537e9319ed28959b14175c7 (diff)
downloadnextcloud-server-9c19a5dbcc422b361618ca979271bc6218ff33b7.tar.gz
nextcloud-server-9c19a5dbcc422b361618ca979271bc6218ff33b7.zip
Make sure we do not return people that we already shared with
We should use the provided list of users and groups that we already shared with to filter suggestions.
-rw-r--r--core/ajax/share.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php
index d8aec9c6542..1a2b9c4e70c 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -241,6 +241,14 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
$usergroups = OC_Group::getUserGroups(OC_User::getUser());
$groups = array_intersect($groups, $usergroups);
}
+
+ $sharedUsers = [];
+ $sharedGroups = [];
+ if (isset($_GET['itemShares'])) {
+ $sharedUsers = isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) ? $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER] : [];
+ $sharedGroups = isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) ? $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP] : [];
+ }
+
$count = 0;
$users = array();
$limit = 0;
@@ -252,8 +260,13 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
} else {
$users = OC_User::getDisplayNames((string)$_GET['search'], $limit, $offset);
}
+
$offset += $limit;
foreach ($users as $uid => $displayName) {
+ if (in_array($uid, $sharedUsers)) {
+ continue;
+ }
+
if ((!isset($_GET['itemShares'])
|| !is_array((string)$_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])
|| !in_array($uid, (string)$_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]))
@@ -274,6 +287,10 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
$l = \OC::$server->getL10N('core');
foreach ($groups as $group) {
+ if (in_array($group, $sharedGroups)) {
+ continue;
+ }
+
if ($count < 15) {
if (!isset($_GET['itemShares'])
|| !isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])