]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make auto accepting the default and provide setting to enforce the share acceptance...
authorJulius Härtl <jus@bitgrid.net>
Thu, 16 Jan 2020 17:42:58 +0000 (18:42 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 16 Jan 2020 21:07:51 +0000 (22:07 +0100)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/files_sharing/lib/Listener/UserShareAcceptanceListener.php
apps/files_sharing/lib/Settings/Personal.php
apps/files_sharing/src/components/PersonalSettings.vue
config/config.sample.php

index f8ce4353c130f2803924946abfe4c5986ac3e1a7..382f0b61793abbfc41f3deb85aed322ea9b99141 100644 (file)
@@ -26,6 +26,7 @@ declare(strict_types=1);
 
 namespace OCA\Files_Sharing\Listener;
 
+use OCA\Files_Sharing\AppInfo\Application;
 use OCP\EventDispatcher\Event;
 use OCP\EventDispatcher\IEventListener;
 use OCP\IConfig;
@@ -74,7 +75,9 @@ class UserShareAcceptanceListener implements IEventListener {
        }
 
        private function handleAutoAccept(IShare $share, string $userId) {
-               if ($this->config->getUserValue($userId, 'files_sharing','default_accept','no') === 'yes') {
+               $defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes';
+               $acceptDefault = $this->config->getUserValue($userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes';
+               if (!$this->config->getSystemValueBool('sharing.force_share_accept', false) && $acceptDefault) {
                        $this->shareManager->acceptShare($share, $userId);
                }
        }
index 25740d8b4f02bdb3081160d27de1a0e45e27dc4c..d6fd7f5f9ca794095470d32963ac3a0d2845879c 100644 (file)
@@ -48,8 +48,11 @@ class Personal implements ISettings {
        }
 
        public function getForm(): TemplateResponse {
-               $value = $this->config->getUserValue($this->userId, Application::APP_ID, 'default_accept', 'no') === 'yes';
-               $this->initialState->provideInitialState(Application::APP_ID, 'accept_default', $value);
+               $defaultAcceptSystemConfig = $this->config->getSystemValueBool('sharing.enable_share_accept', false) ? 'no' : 'yes';
+               $acceptDefault = $this->config->getUserValue($this->userId, Application::APP_ID, 'default_accept', $defaultAcceptSystemConfig) === 'yes';
+               $enforceAccept = $this->config->getSystemValueBool('sharing.force_share_accept', false);
+               $this->initialState->provideInitialState(Application::APP_ID, 'accept_default', $acceptDefault);
+               $this->initialState->provideInitialState(Application::APP_ID, 'enforce_accept', $enforceAccept);
                return new TemplateResponse('files_sharing', 'Settings/personal');
        }
 
index b6cbbc180b6536d0bcee9235e4378d10b29bd959..ec7255480eb4251bb246076cf3e221043a97ce93 100644 (file)
@@ -20,7 +20,7 @@
   -->
 
 <template>
-       <div id="files-sharing-personal-settings" class="section">
+       <div id="files-sharing-personal-settings" class="section" v-if="!enforceAcceptShares">
                <h2>{{ t('files', 'Sharing') }}</h2>
                <p>
                        <input id="files-sharing-personal-settings-accept"
@@ -42,12 +42,10 @@ export default {
        name: 'PersonalSettings',
        data() {
                return {
-                       accepting: true,
+                       accepting: loadState('files_sharing', 'accept_default'),
+                       enforceAcceptShares: loadState('files_sharing', 'enforce_accept'),
                }
        },
-       mounted() {
-               this.accepting = loadState('files_sharing', 'accept_default')
-       },
        methods: {
                toggleEnabled() {
                        axios.put(
index ba47fe9e843a76de5f5f035c37de9c2fd79c7318..0122199db30450735e8ee55f8be7d36981e9b8d4 100644 (file)
@@ -1339,11 +1339,16 @@ $CONFIG = array(
 'sharing.minSearchStringLength' => 0,
 
 /**
- * Starting with Nextcloud 18 also internal shares have to be accepted. Setting
- * this setting to true forces all internal shares to be accepted directly.
- * (resulting in pre 18 behavior).
+ * Set to true to enable that internal shares need to be accepted by the users by default.
+ * Users can change this for their account in their personal sharing settings
  */
-'sharing.interal_shares_accepted' => false,
+'sharing.enable_share_accept' => false,
+
+/**
+ * Set to true to enforce that internal shares need to be accepted
+ */
+'sharing.force_share_accept' => false,
+
 
 /**
  * All other configuration options