summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/api/sharees.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-08-11 16:22:05 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-08-26 11:54:24 +0200
commitad450d4f0ed4ebbb5e9e6256750061b0adb950e1 (patch)
treea34b63c6502ff4d7b3e5a0eadac391427edd7b37 /apps/files_sharing/api/sharees.php
parentbe257bc9cc2330d0e67957525cb66646b346a850 (diff)
downloadnextcloud-server-ad450d4f0ed4ebbb5e9e6256750061b0adb950e1.tar.gz
nextcloud-server-ad450d4f0ed4ebbb5e9e6256750061b0adb950e1.zip
Add tests for "getGroups()"
Diffstat (limited to 'apps/files_sharing/api/sharees.php')
-rw-r--r--apps/files_sharing/api/sharees.php21
1 files changed, 12 insertions, 9 deletions
diff --git a/apps/files_sharing/api/sharees.php b/apps/files_sharing/api/sharees.php
index 6853bd8a269..7a3555e0a5b 100644
--- a/apps/files_sharing/api/sharees.php
+++ b/apps/files_sharing/api/sharees.php
@@ -20,6 +20,7 @@
*/
namespace OCA\Files_Sharing\API;
+use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IAppConfig;
@@ -100,8 +101,8 @@ class Sharees {
'label' => $displayName,
'value' => [
'shareType' => \OCP\Share::SHARE_TYPE_USER,
- 'shareWith' => $uid
- ]
+ 'shareWith' => $uid,
+ ],
];
}
@@ -117,20 +118,22 @@ class Sharees {
private function getGroups($search, $shareWithGroupOnly) {
$sharees = [];
$groups = $this->groupManager->search($search);
+ $groups = array_map(function (IGroup $group) { return $group->getGID(); }, $groups);
- if ($shareWithGroupOnly) {
+ if (!empty($groups) && $shareWithGroupOnly) {
// Intersect all the groups that match with the groups this user is a member of
$userGroups = $this->groupManager->getUserGroups($this->userSession->getUser());
+ $userGroups = array_map(function (IGroup $group) { return $group->getGID(); }, $userGroups);
$groups = array_intersect($groups, $userGroups);
}
- foreach ($groups as $group) {
+ foreach ($groups as $gid) {
$sharees[] = [
- 'label' => $group->getGID(),
+ 'label' => $gid,
'value' => [
'shareType' => \OCP\Share::SHARE_TYPE_GROUP,
- 'shareWith' => $group->getGID()
- ]
+ 'shareWith' => $gid,
+ ],
];
}
@@ -150,8 +153,8 @@ class Sharees {
'label' => $search,
'value' => [
'shareType' => \OCP\Share::SHARE_TYPE_REMOTE,
- 'shareWith' => $search
- ]
+ 'shareWith' => $search,
+ ],
];
}