From 9af96d9f9ac512d8082cd20303068f06646b4a93 Mon Sep 17 00:00:00 2001
From: Baptiste Fotia <fotia.baptiste@hotmail.com>
Date: Wed, 27 Dec 2023 12:56:23 +0100
Subject: feat(php,vue): Create a new parameter

Signed-off-by: Baptiste Fotia <fotia.baptiste@hotmail.com>
---
 apps/settings/lib/Settings/Admin/Sharing.php              | 2 ++
 apps/settings/src/components/AdminSettingsSharingForm.vue | 8 ++++++++
 apps/settings/tests/Settings/Admin/SharingTest.php        | 2 ++
 3 files changed, 12 insertions(+)

(limited to 'apps')

diff --git a/apps/settings/lib/Settings/Admin/Sharing.php b/apps/settings/lib/Settings/Admin/Sharing.php
index f4d3a5c107b..fc8b811eccd 100644
--- a/apps/settings/lib/Settings/Admin/Sharing.php
+++ b/apps/settings/lib/Settings/Admin/Sharing.php
@@ -63,6 +63,7 @@ class Sharing implements IDelegatedSettings {
 		$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
 		$linksExcludedGroups = $this->config->getAppValue('core', 'shareapi_allow_links_exclude_groups', '');
 		$excludedPasswordGroups = $this->config->getAppValue('core', 'shareapi_enforce_links_password_excluded_groups', '');
+		$onlyShareWithGroupMembersExcludeGroupList = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members_exclude_group_list', '');
 
 		$parameters = [
 			// Built-In Sharing
@@ -83,6 +84,7 @@ class Sharing implements IDelegatedSettings {
 			'passwordExcludedGroups' => json_decode($excludedPasswordGroups) ?? [],
 			'passwordExcludedGroupsFeatureEnabled' => $this->config->getSystemValueBool('sharing.allow_disabled_password_enforcement_groups', false),
 			'onlyShareWithGroupMembers' => $this->shareManager->shareWithGroupMembersOnly(),
+			'onlyShareWithGroupMembersExcludeGroupList' => json_decode($onlyShareWithGroupMembersExcludeGroupList) ?? [],
 			'defaultExpireDate' => $this->getHumanBooleanConfig('core', 'shareapi_default_expire_date'),
 			'expireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'),
 			'enforceExpireDate' => $this->getHumanBooleanConfig('core', 'shareapi_enforce_expire_date'),
diff --git a/apps/settings/src/components/AdminSettingsSharingForm.vue b/apps/settings/src/components/AdminSettingsSharingForm.vue
index 2165303349f..6850ab74243 100644
--- a/apps/settings/src/components/AdminSettingsSharingForm.vue
+++ b/apps/settings/src/components/AdminSettingsSharingForm.vue
@@ -37,6 +37,13 @@
 			<NcCheckboxRadioSwitch :checked.sync="settings.onlyShareWithGroupMembers">
 				{{ t('settings', 'Restrict users to only share with users in their groups') }}
 			</NcCheckboxRadioSwitch>
+			<div v-show="settings.onlyShareWithGroupMembers" id="settings-sharing-api-excluded-groups" class="sharing__labeled-entry sharing__input">
+				<label for="settings-sharing-only-group-members-excluded-groups">{{ t('settings', 'Ignore the following groups when checking group membership') }}</label>
+				<NcSettingsSelectGroup id="settings-sharing-only-group-members-excluded-groups"
+					v-model="settings.onlyShareWithGroupMembersExcludeGroupList"
+					:label="t('settings', 'Ignore the following groups when checking group membership')"
+					style="width: 100%" />
+			</div>
 		</div>
 
 		<div v-show="settings.enabled" id="settings-sharing-api" class="sharing__section">
@@ -216,6 +223,7 @@ interface IShareSettings {
 	passwordExcludedGroups: string[]
 	passwordExcludedGroupsFeatureEnabled: boolean
 	onlyShareWithGroupMembers: boolean
+	onlyShareWithGroupMembersExcludeGroupList: string[]
 	defaultExpireDate: boolean
 	expireAfterNDays: string
 	enforceExpireDate: boolean
diff --git a/apps/settings/tests/Settings/Admin/SharingTest.php b/apps/settings/tests/Settings/Admin/SharingTest.php
index b34c4945774..7dd4e56bcd2 100644
--- a/apps/settings/tests/Settings/Admin/SharingTest.php
+++ b/apps/settings/tests/Settings/Admin/SharingTest.php
@@ -163,6 +163,7 @@ class SharingTest extends TestCase {
 						'allowLinksExcludeGroups' => [],
 						'passwordExcludedGroups' => [],
 						'passwordExcludedGroupsFeatureEnabled' => false,
+						'onlyShareWithGroupMembersExcludeGroupList' => [],
 					]
 				],
 			);
@@ -254,6 +255,7 @@ class SharingTest extends TestCase {
 						'allowLinksExcludeGroups' => [],
 						'passwordExcludedGroups' => [],
 						'passwordExcludedGroupsFeatureEnabled' => false,
+						'onlyShareWithGroupMembersExcludeGroupList' => [],
 					]
 				],
 			);
-- 
cgit v1.2.3