aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjörn Schießle <bjoern@schiessle.org>2017-04-10 11:04:19 +0200
committerGitHub <noreply@github.com>2017-04-10 11:04:19 +0200
commit235563f0a0481209f2e5d0303afe0b4db36bfcb6 (patch)
treee596b9e7aab8cd7cfe1641495a9c8edd54033243 /apps
parent09c66c93c54a81b4747abb3191f604cd67bfc601 (diff)
parent78f0b5c19fe3101e3f10b5da70411681cd9b3d3e (diff)
downloadnextcloud-server-235563f0a0481209f2e5d0303afe0b4db36bfcb6.tar.gz
nextcloud-server-235563f0a0481209f2e5d0303afe0b4db36bfcb6.zip
Merge pull request #4250 from nextcloud/disable-lookupserver-upload
allow admin to disable lookupserver upload
Diffstat (limited to 'apps')
-rw-r--r--apps/federatedfilesharing/lib/FederatedShareProvider.php17
-rw-r--r--apps/federatedfilesharing/lib/Settings/Admin.php1
-rw-r--r--apps/federatedfilesharing/templates/settings-admin.php10
-rw-r--r--apps/federatedfilesharing/tests/FederatedShareProviderTest.php32
-rw-r--r--apps/federatedfilesharing/tests/Settings/AdminTest.php5
5 files changed, 61 insertions, 4 deletions
diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php
index fb49978b7af..9063bbf7450 100644
--- a/apps/federatedfilesharing/lib/FederatedShareProvider.php
+++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php
@@ -941,7 +941,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');
}
/**
@@ -951,7 +951,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');
}
/**
@@ -961,6 +961,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 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');
<input type="checkbox" name="lookupServerEnabled" id="lookupServerEnabled" class="checkbox"
value="1" <?php if ($_['lookupServerEnabled']) print_unescaped('checked="checked"'); ?> />
<label for="lookupServerEnabled">
- <?php p($l->t('Search global and public address book for users'));?>
+ <?php p($l->t('Search global and public address book for users and let local users publish their data'));?>
</label><br/>
</p>
+ <p>
+ <input type="checkbox" name="lookupServerUploadEnabled" id="lookupServerUploadEnabled" class="checkbox"
+ value="1" <?php if ($_['lookupServerUploadEnabled']) print_unescaped('checked="checked"'); ?> />
+ <label for="lookupServerUploadEnabled">
+ <?php p($l->t('Allow users to publish their data to a global and public address book'));?>
+ </label><br/>
+ </p>
+
</div>
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());