From 0fa9f3049f20ee4d573a6c615ebf9e7ecf7abdd1 Mon Sep 17 00:00:00 2001 From: Corentin Damman Date: Fri, 16 Sep 2022 17:43:01 +0200 Subject: feat(files_sharing): allow to specify allowed groups to share instead of excluded groups Relates to #3387 Signed-off-by: Corentin Damman --- lib/private/Contacts/ContactsMenu/ContactsStore.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/private/Contacts') diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index 2f141cbc0ab..3b39cc869a7 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -193,7 +193,7 @@ class ContactsStore implements IContactsStore { $restrictEnumerationGroup = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes'; $restrictEnumerationPhone = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_phone', 'no') === 'yes'; $allowEnumerationFullMatch = $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_full_match', 'yes') === 'yes'; - $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes'; + $excludeGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no'); // whether to filter out local users $skipLocal = false; @@ -202,14 +202,22 @@ class ContactsStore implements IContactsStore { $selfGroups = $this->groupManager->getUserGroupIds($self); - if ($excludedGroups) { + if ($excludeGroups && $excludeGroups !== 'no') { $excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', ''); $decodedExcludeGroups = json_decode($excludedGroups, true); $excludeGroupsList = $decodedExcludeGroups ?? []; - if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) { - // a group of the current user is excluded -> filter all local users + if ($excludeGroups != 'allow') { + if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) { + // a group of the current user is excluded -> filter all local users + $skipLocal = true; + } + } else { $skipLocal = true; + if (count(array_intersect($excludeGroupsList, $selfGroups)) !== 0) { + // a group of the current user is allowed -> do not filter all local users + $skipLocal = false; + } } } -- cgit v1.2.3