From 9afd160e66f2c060cb7d77d414d0c1d13ac0c3ad Mon Sep 17 00:00:00 2001
From: Bjoern Schiessle
Date: Fri, 7 Apr 2017 11:42:33 +0200
Subject: [PATCH] allow to disable upload to lookup server, by default it is
enabled
Signed-off-by: Bjoern Schiessle
---
.../lib/FederatedShareProvider.php | 11 +++++++
.../lib/Settings/Admin.php | 1 +
.../templates/settings-admin.php | 10 +++++-
.../tests/FederatedShareProviderTest.php | 32 +++++++++++++++++++
.../tests/Settings/AdminTest.php | 5 +++
settings/personal.php | 4 +++
settings/templates/personal.php | 9 +++++-
7 files changed, 70 insertions(+), 2 deletions(-)
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index fb49978b7af..b2f2558c80c 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -963,4 +963,15 @@ class FederatedShareProvider implements IShareProvider {
$result = $this->config->getAppValue('files_sharing', 'lookupServerEnabled', 'no');
return ($result === 'yes') ? true : false;
}
+
+
+ /**
+ * 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') ? true : false;
+ }
}
diff --git a/apps/federatedfilesharing/lib/Settings/Admin.php b/apps/federatedfilesharing/lib/Settings/Admin.php
index 20ff6ae6f4a..baac4b1086f 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 d71ce20d13c..b60ff1083b0 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 97d8ccd65c3..d9bc9a7e2ad 100644
--- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
+++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
@@ -705,6 +705,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 c0b35a6427b..9eae6317bf7 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 a4449754f64..2c46a9f8dd2 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -186,6 +186,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 d94fbb33770..10df437523b 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -67,7 +67,9 @@
+
+
@@ -86,7 +88,9 @@
t('No display name set')); } ?>
+
+
@@ -107,9 +111,12 @@
t('For password reset and notifications')); ?>
+
+
+
-
+
--
2.39.5