diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 61f1b1c8f1..75d4de39a6 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -931,7 +931,7 @@ class FederatedShareProvider implements IShareProvider { */ public function isOutgoingServer2serverShareEnabled() { $result = $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes'); - return ($result === 'yes') ? true : false; + return ($result === 'yes'); } /** @@ -941,7 +941,7 @@ class FederatedShareProvider implements IShareProvider { */ public function isIncomingServer2serverShareEnabled() { $result = $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes'); - return ($result === 'yes') ? true : false; + return ($result === 'yes'); } /** @@ -951,6 +951,17 @@ class FederatedShareProvider implements IShareProvider { */ public function isLookupServerQueriesEnabled() { $result = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no'); - return ($result === 'yes') ? true : false; + return ($result === 'yes'); + } + + + /** + * Check if it is allowed to publish user specific data to the lookup server + * + * @return bool + */ + public function isLookupServerUploadEnabled() { + $result = $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes'); + return ($result === 'yes'); } } diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php index 20ff6ae6f4..baac4b1086 100644 --- a/apps/federatedfilesharing/lib/Settings/Admin.php +++ b/apps/federatedfilesharing/lib/Settings/Admin.php @@ -44,6 +44,7 @@ class Admin implements ISettings { 'outgoingServer2serverShareEnabled' => $this->fedShareProvider->isOutgoingServer2serverShareEnabled(), 'incomingServer2serverShareEnabled' => $this->fedShareProvider->isIncomingServer2serverShareEnabled(), 'lookupServerEnabled' => $this->fedShareProvider->isLookupServerQueriesEnabled(), + 'lookupServerUploadEnabled' => $this->fedShareProvider->isLookupServerUploadEnabled(), ]; return new TemplateResponse('federatedfilesharing', 'settings-admin', $parameters, ''); diff --git a/apps/federatedfilesharing/templates/settings-admin.php b/apps/federatedfilesharing/templates/settings-admin.php index d71ce20d13..b60ff1083b 100644 --- a/apps/federatedfilesharing/templates/settings-admin.php +++ b/apps/federatedfilesharing/templates/settings-admin.php @@ -29,7 +29,15 @@ script('federatedfilesharing', 'settings-admin'); />

+

+ /> +
+

+ diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php index 874d4b48a5..2f48cb49c8 100644 --- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php +++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php @@ -696,6 +696,38 @@ class FederatedShareProviderTest extends \Test\TestCase { ); } + /** + * @dataProvider dataTestFederatedSharingSettings + * + * @param string $isEnabled + * @param bool $expected + */ + public function testIsLookupServerQueriesEnabled($isEnabled, $expected) { + $this->config->expects($this->once())->method('getAppValue') + ->with('files_sharing', 'lookupServerEnabled', 'no') + ->willReturn($isEnabled); + + $this->assertSame($expected, + $this->provider->isLookupServerQueriesEnabled() + ); + } + + /** + * @dataProvider dataTestFederatedSharingSettings + * + * @param string $isEnabled + * @param bool $expected + */ + public function testIsLookupServerUploadEnabled($isEnabled, $expected) { + $this->config->expects($this->once())->method('getAppValue') + ->with('files_sharing', 'lookupServerUploadEnabled', 'yes') + ->willReturn($isEnabled); + + $this->assertSame($expected, + $this->provider->isLookupServerUploadEnabled() + ); + } + public function dataTestFederatedSharingSettings() { return [ ['yes', true], diff --git a/apps/federatedfilesharing/tests/Settings/AdminTest.php b/apps/federatedfilesharing/tests/Settings/AdminTest.php index c0b35a6427..9eae6317bf 100644 --- a/apps/federatedfilesharing/tests/Settings/AdminTest.php +++ b/apps/federatedfilesharing/tests/Settings/AdminTest.php @@ -69,11 +69,16 @@ class AdminTest extends TestCase { ->expects($this->once()) ->method('isLookupServerQueriesEnabled') ->willReturn($state); + $this->federatedShareProvider + ->expects($this->once()) + ->method('isLookupServerUploadEnabled') + ->willReturn($state); $params = [ 'outgoingServer2serverShareEnabled' => $state, 'incomingServer2serverShareEnabled' => $state, 'lookupServerEnabled' => $state, + 'lookupServerUploadEnabled' => $state ]; $expected = new TemplateResponse('federatedfilesharing', 'settings-admin', $params, ''); $this->assertEquals($expected, $this->admin->getForm()); diff --git a/settings/personal.php b/settings/personal.php index a5cf88a781..03ee831efb 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -188,6 +188,10 @@ $tmpl->assign('certs', $certificateManager->listCertificates()); $tmpl->assign('showCertificates', $enableCertImport); $tmpl->assign('urlGenerator', $urlGenerator); +$lookupServerUploadEnabled = $config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes'); +$lookupServerUploadEnabled = $lookupServerUploadEnabled === 'yes'; +$tmpl->assign('lookupServerUploadEnabled', $lookupServerUploadEnabled); + // Get array of group ids for this user $groups = \OC::$server->getGroupManager()->getUserIdGroups(OC_User::getUser()); $groups2 = array_map(function($group) { return $group->getGID(); }, $groups); diff --git a/settings/templates/personal.php b/settings/templates/personal.php index a14982b9b7..1a7b6d41e6 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -61,7 +61,9 @@