diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-11-28 10:37:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-28 10:37:19 +0300 |
commit | 62dc32019146bdc186e110bde23dd210633acbe7 (patch) | |
tree | a4947d148758d953fa5d3777333e8190ab84fb3b /apps/settings | |
parent | 669302e570024c83140ff5c4f4b1489c5a1c66ed (diff) | |
parent | 078f4efb20f269394e5f60fe327ba36c0279d77e (diff) |
Merge pull request #17725 from nextcloud/enh/share_exp_internal
Allow internal shares to have a default expiration date
Diffstat (limited to 'apps/settings')
-rw-r--r-- | apps/settings/js/admin.js | 4 | ||||
-rw-r--r-- | apps/settings/lib/Settings/Admin/Sharing.php | 3 | ||||
-rw-r--r-- | apps/settings/templates/settings/admin/sharing.php | 18 | ||||
-rw-r--r-- | apps/settings/tests/Settings/Admin/SharingTest.php | 40 |
4 files changed, 62 insertions, 3 deletions
diff --git a/apps/settings/js/admin.js b/apps/settings/js/admin.js index b2078862079..e798cd8d198 100644 --- a/apps/settings/js/admin.js +++ b/apps/settings/js/admin.js @@ -86,6 +86,10 @@ $(document).ready(function(){ $("#setDefaultExpireDate").toggleClass('hidden', !this.checked); }); + $('#shareapiDefaultInternalExpireDate').change(function() { + $("#setDefaultInternalExpireDate").toggleClass('hidden', !this.checked); + }); + $('#publicShareDisclaimer').change(function() { $("#publicShareDisclaimerText").toggleClass('hidden', !this.checked); if(!this.checked) { diff --git a/apps/settings/lib/Settings/Admin/Sharing.php b/apps/settings/lib/Settings/Admin/Sharing.php index 18b1f26d9a2..da267ee1b79 100644 --- a/apps/settings/lib/Settings/Admin/Sharing.php +++ b/apps/settings/lib/Settings/Admin/Sharing.php @@ -82,6 +82,9 @@ class Sharing implements ISettings { 'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'), 'shareApiDefaultPermissions' => $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL), 'shareApiDefaultPermissionsCheckboxes' => $this->getSharePermissionList(), + 'shareDefaultInternalExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_internal_expire_date', 'no'), + 'shareInternalExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_internal_expire_after_n_days', '7'), + 'shareInternalEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_internal_expire_date', 'no'), ]; return new TemplateResponse('settings', 'settings/admin/sharing', $parameters, ''); diff --git a/apps/settings/templates/settings/admin/sharing.php b/apps/settings/templates/settings/admin/sharing.php index 5913524be40..3ed9871add4 100644 --- a/apps/settings/templates/settings/admin/sharing.php +++ b/apps/settings/templates/settings/admin/sharing.php @@ -37,6 +37,22 @@ value="1" <?php if ($_['shareAPIEnabled'] === 'yes') print_unescaped('checked="checked"'); ?> /> <label for="shareAPIEnabled"><?php p($l->t('Allow apps to use the Share API'));?></label><br/> </p> + + <p id="internalShareSettings" class="indent <?php if ($_['shareAPIEnabled'] === 'no') p('hidden'); ?>"> + <input type="checkbox" name="shareapi_default_internal_expire_date" id="shareapiDefaultInternalExpireDate" class="checkbox" + value="1" <?php if ($_['shareDefaultInternalExpireDateSet'] === 'yes') print_unescaped('checked="checked"'); ?> /> + <label for="shareapiDefaultInternalExpireDate"><?php p($l->t('Set default expiration date for non-link shares'));?></label><br/> + </p> + <p id="setDefaultInternalExpireDate" class="double-indent <?php if ($_['shareDefaultInternalExpireDateSet'] === 'no' || $_['shareAPIEnabled'] === 'no') p('hidden');?>"> + <?php p($l->t( 'Expire after ' )); ?> + <input type="text" name='shareapi_internal_expire_after_n_days' id="shareapiInternalExpireAfterNDays" placeholder="<?php p('7')?>" + value='<?php p($_['shareInternalExpireAfterNDays']) ?>' /> + <?php p($l->t( 'days' )); ?> + <input type="checkbox" name="shareapi_internal_enforce_expire_date" id="shareapiInternalEnforceExpireDate" class="checkbox" + value="1" <?php if ($_['shareInternalEnforceExpireDate'] === 'yes') print_unescaped('checked="checked"'); ?> /> + <label for="shareapiInternalEnforceExpireDate"><?php p($l->t('Enforce expiration date'));?></label><br/> + </p> + <p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>"> <input type="checkbox" name="shareapi_allow_links" id="allowLinks" class="checkbox" value="1" <?php if ($_['allowLinks'] === 'yes') print_unescaped('checked="checked"'); ?> /> @@ -56,7 +72,7 @@ <input type="checkbox" name="shareapi_default_expire_date" id="shareapiDefaultExpireDate" class="checkbox" value="1" <?php if ($_['shareDefaultExpireDateSet'] === 'yes') print_unescaped('checked="checked"'); ?> /> - <label for="shareapiDefaultExpireDate"><?php p($l->t('Set default expiration date'));?></label><br/> + <label for="shareapiDefaultExpireDate"><?php p($l->t('Set default expiration date for link shares'));?></label><br/> </p> <p id="setDefaultExpireDate" class="double-indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareDefaultExpireDateSet'] === 'no' || $_['shareAPIEnabled'] === 'no') p('hidden');?>"> diff --git a/apps/settings/tests/Settings/Admin/SharingTest.php b/apps/settings/tests/Settings/Admin/SharingTest.php index 38f687b87ae..ff67ebc28b6 100644 --- a/apps/settings/tests/Settings/Admin/SharingTest.php +++ b/apps/settings/tests/Settings/Admin/SharingTest.php @@ -131,6 +131,21 @@ class SharingTest extends TestCase { ->method('getAppValue') ->with('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL) ->willReturn(Constants::PERMISSION_ALL); + $this->config + ->expects($this->at(14)) + ->method('getAppValue') + ->with('core', 'shareapi_default_internal_expire_date', 'no') + ->willReturn('no'); + $this->config + ->expects($this->at(15)) + ->method('getAppValue') + ->with('core', 'shareapi_internal_expire_after_n_days', '7') + ->willReturn('7'); + $this->config + ->expects($this->at(16)) + ->method('getAppValue') + ->with('core', 'shareapi_enforce_internal_expire_date', 'no') + ->willReturn('no'); $expected = new TemplateResponse( 'settings', @@ -152,7 +167,10 @@ class SharingTest extends TestCase { 'publicShareDisclaimerText' => 'Lorem ipsum', 'enableLinkPasswordByDefault' => 'yes', 'shareApiDefaultPermissions' => Constants::PERMISSION_ALL, - 'shareApiDefaultPermissionsCheckboxes' => $this->invokePrivate($this->admin, 'getSharePermissionList', []) + 'shareApiDefaultPermissionsCheckboxes' => $this->invokePrivate($this->admin, 'getSharePermissionList', []), + 'shareDefaultInternalExpireDateSet' => 'no', + 'shareInternalExpireAfterNDays' => '7', + 'shareInternalEnforceExpireDate' => 'no', ], '' ); @@ -231,6 +249,21 @@ class SharingTest extends TestCase { ->method('getAppValue') ->with('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL) ->willReturn(Constants::PERMISSION_ALL); + $this->config + ->expects($this->at(14)) + ->method('getAppValue') + ->with('core', 'shareapi_default_internal_expire_date', 'no') + ->willReturn('no'); + $this->config + ->expects($this->at(15)) + ->method('getAppValue') + ->with('core', 'shareapi_internal_expire_after_n_days', '7') + ->willReturn('7'); + $this->config + ->expects($this->at(16)) + ->method('getAppValue') + ->with('core', 'shareapi_enforce_internal_expire_date', 'no') + ->willReturn('no'); $expected = new TemplateResponse( @@ -253,7 +286,10 @@ class SharingTest extends TestCase { 'publicShareDisclaimerText' => 'Lorem ipsum', 'enableLinkPasswordByDefault' => 'yes', 'shareApiDefaultPermissions' => Constants::PERMISSION_ALL, - 'shareApiDefaultPermissionsCheckboxes' => $this->invokePrivate($this->admin, 'getSharePermissionList', []) + 'shareApiDefaultPermissionsCheckboxes' => $this->invokePrivate($this->admin, 'getSharePermissionList', []), + 'shareDefaultInternalExpireDateSet' => 'no', + 'shareInternalExpireAfterNDays' => '7', + 'shareInternalEnforceExpireDate' => 'no', ], '' ); |