]> source.dussan.org Git - nextcloud-server.git/commitdiff
allow to disable upload to lookup server, by default it is enabled
authorBjoern Schiessle <bjoern@schiessle.org>
Fri, 7 Apr 2017 09:42:33 +0000 (11:42 +0200)
committerBjoern Schiessle <bjoern@schiessle.org>
Fri, 7 Apr 2017 14:30:07 +0000 (16:30 +0200)
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
apps/federatedfilesharing/lib/FederatedShareProvider.php
apps/federatedfilesharing/lib/Settings/Admin.php
apps/federatedfilesharing/templates/settings-admin.php
apps/federatedfilesharing/tests/FederatedShareProviderTest.php
apps/federatedfilesharing/tests/Settings/AdminTest.php
settings/personal.php
settings/templates/personal.php

index fb49978b7af1679a9228da0429902abf9bf1a215..b2f2558c80c6f6a2283ece2e52d9a1ed496ff178 100644 (file)
@@ -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;
+       }
 }
index 20ff6ae6f4a6285c5d6da3b64e9f99365579c260..baac4b1086ff74836b0272897e62c9fb2aeb0cb0 100644 (file)
@@ -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, '');
index d71ce20d13cc40b2fa8855bdb27f0fe262d98b6a..b60ff1083b098d07f985a18af113a37237f467f2 100644 (file)
@@ -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>
index 97d8ccd65c3ec9f5ad87e89b3e0cceca59343924..d9bc9a7e2ad043ce1c0a5f94933a3ecac05d215f 100644 (file)
@@ -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],
index c0b35a6427bbb46d4f9426483585b2758e83383d..9eae6317bf71a07832222b7f05fc9856c5385a9f 100644 (file)
@@ -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());
index a4449754f644f3fb15d5ac5f6de749052e14ec27..2c46a9f8dd291375d16f8ca9a307cad87c8848ab 100644 (file)
@@ -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);
index d94fbb33770a2311dee08bda03b053dcda0adfc4..10df437523b4edaac7cc0ee46075e2845a0ed4ec 100644 (file)
@@ -67,7 +67,9 @@
                        </div>
                </div>
                <span class="icon-checkmark hidden"/>
+               <?php if($_['lookupServerUploadEnabled']) { ?>
                <input type="hidden" id="avatarscope" value="<?php p($_['avatarScope']) ?>">
+               <?php } ?>
        </form>
 </div>
 
@@ -86,7 +88,9 @@
                                <span><?php if(isset($_['displayName']) && !empty($_['displayName'])) { p($_['displayName']); } else { p($l->t('No display name set')); } ?></span>
                        <?php } ?>
                        <span class="icon-checkmark hidden"/>
+                       <?php if($_['lookupServerUploadEnabled']) { ?>
                        <input type="hidden" id="displaynamescope" value="<?php p($_['displayNameScope']) ?>">
+                       <?php } ?>
                </form>
        </div>
        <div class="personal-settings-setting-box">
                                <em><?php p($l->t('For password reset and notifications')); ?></em>
                        <?php } ?>
                        <span class="icon-checkmark hidden"/>
+                       <?php if($_['lookupServerUploadEnabled']) { ?>
                        <input type="hidden" id="emailscope" value="<?php p($_['emailScope']) ?>">
+                       <?php } ?>
                </form>
        </div>
+       <?php if($_['lookupServerUploadEnabled']) { ?>
        <div class="personal-settings-setting-box">
                <form id="phoneform" class="section">
                        <h2>
                        <input type="hidden" id="twitterscope" value="<?php p($_['twitterScope']) ?>">
                </form>
        </div>
-
+       <?php } ?>
        <span class="msg"></span>
 </div>
 </div>