зеркало из https://github.com/nextcloud/forms.git
enh: make show to all users an admin setting
Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
Родитель
b528a54d07
Коммит
ee697ff50f
|
@ -31,11 +31,13 @@ class Constants {
|
|||
*/
|
||||
public const CONFIG_KEY_ALLOWPERMITALL = 'allowPermitAll';
|
||||
public const CONFIG_KEY_ALLOWPUBLICLINK = 'allowPublicLink';
|
||||
public const CONFIG_KEY_ALLOWSHOWTOALL = 'allowShowToAll';
|
||||
public const CONFIG_KEY_CREATIONALLOWEDGROUPS = 'creationAllowedGroups';
|
||||
public const CONFIG_KEY_RESTRICTCREATION = 'restrictCreation';
|
||||
public const CONFIG_KEYS = [
|
||||
self::CONFIG_KEY_ALLOWPERMITALL,
|
||||
self::CONFIG_KEY_ALLOWPUBLICLINK,
|
||||
self::CONFIG_KEY_ALLOWSHOWTOALL,
|
||||
self::CONFIG_KEY_CREATIONALLOWEDGROUPS,
|
||||
self::CONFIG_KEY_RESTRICTCREATION
|
||||
];
|
||||
|
|
|
@ -57,6 +57,9 @@ class ConfigService {
|
|||
public function getAllowPublicLink(): bool {
|
||||
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_ALLOWPUBLICLINK, 'true'));
|
||||
}
|
||||
public function getAllowShowToAll() : bool {
|
||||
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_ALLOWSHOWTOALL, 'true'));
|
||||
}
|
||||
private function getUnformattedCreationAllowedGroups(): array {
|
||||
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_CREATIONALLOWEDGROUPS, '[]'));
|
||||
}
|
||||
|
@ -74,6 +77,7 @@ class ConfigService {
|
|||
return [
|
||||
Constants::CONFIG_KEY_ALLOWPERMITALL => $this->getAllowPermitAll(),
|
||||
Constants::CONFIG_KEY_ALLOWPUBLICLINK => $this->getAllowPublicLink(),
|
||||
Constants::CONFIG_KEY_ALLOWSHOWTOALL => $this->getAllowShowToAll(),
|
||||
Constants::CONFIG_KEY_CREATIONALLOWEDGROUPS => $this->getCreationAllowedGroups(),
|
||||
Constants::CONFIG_KEY_RESTRICTCREATION => $this->getRestrictCreation(),
|
||||
|
||||
|
|
|
@ -465,6 +465,14 @@ class FormsService {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Shown if permitall and showntoall are both set.
|
||||
if ($form->getAccess()['permitAllUsers'] &&
|
||||
$form->getAccess()['showToAllUsers'] &&
|
||||
$this->configService->getAllowPermitAll() &&
|
||||
$this->configService->getAllowShowToAll()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,18 @@
|
|||
@update:checked="onAllowPermitAllChange">
|
||||
{{ t('forms', 'Allow sharing to all logged in accounts') }}
|
||||
</NcCheckboxRadioSwitch>
|
||||
<NcCheckboxRadioSwitch
|
||||
ref="switchAllowShowToAll"
|
||||
:checked.sync="appConfig.allowShowToAll"
|
||||
type="switch"
|
||||
@update:checked="onAllowShowToAllChange">
|
||||
{{
|
||||
t(
|
||||
'forms',
|
||||
'Allow showing form to all logged in accounts on sidebar',
|
||||
)
|
||||
}}
|
||||
</NcCheckboxRadioSwitch>
|
||||
</NcSettingsSection>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -124,6 +136,12 @@ export default {
|
|||
await this.saveAppConfig('allowPermitAll', newVal)
|
||||
el.loading = false
|
||||
},
|
||||
async onAllowShowToAllChange(newVal) {
|
||||
const el = this.$refs.switchAllowShowToAll
|
||||
el.loading = true
|
||||
await this.saveAppConfig('allowShowToAll', newVal)
|
||||
el.loading = false
|
||||
},
|
||||
|
||||
/**
|
||||
* Save a key-value pair to the appConfig.
|
||||
|
|
|
@ -190,7 +190,7 @@
|
|||
@update:checked="onPermitAllUsersChange" />
|
||||
</div>
|
||||
<div
|
||||
v-if="form.access.permitAllUsers"
|
||||
v-if="appConfig.allowShowToAll && form.access.permitAllUsers"
|
||||
class="share-div share-div--indent">
|
||||
<div class="share-div__avatar">
|
||||
<FormsIcon :size="16" />
|
||||
|
|
|
@ -91,6 +91,11 @@ class ConfigControllerTest extends TestCase {
|
|||
'configValue' => true,
|
||||
'strConfig' => 'true'
|
||||
],
|
||||
'booleanConfig' => [
|
||||
'configKey' => 'allowShowToAll',
|
||||
'configValue' => true,
|
||||
'strConfig' => 'true'
|
||||
],
|
||||
'arrayConfig' => [
|
||||
'configKey' => 'allowPermitAll',
|
||||
'configValue' => [
|
||||
|
|
|
@ -85,6 +85,7 @@ class ConfigServiceTest extends TestCase {
|
|||
'strConfig' => [
|
||||
'allowPermitAll' => 'false',
|
||||
'allowPublicLink' => 'false',
|
||||
'allowShowToAll' => 'false',
|
||||
'creationAllowedGroups' => '["group1", "group2", "nonExisting"]',
|
||||
'restrictCreation' => 'true',
|
||||
],
|
||||
|
@ -95,6 +96,7 @@ class ConfigServiceTest extends TestCase {
|
|||
'expected' => [
|
||||
'allowPermitAll' => false,
|
||||
'allowPublicLink' => false,
|
||||
'allowShowToAll' => false,
|
||||
'creationAllowedGroups' => [
|
||||
[
|
||||
'groupId' => 'group1',
|
||||
|
@ -157,9 +159,9 @@ class ConfigServiceTest extends TestCase {
|
|||
'expected' => [
|
||||
'allowPermitAll' => true,
|
||||
'allowPublicLink' => true,
|
||||
'allowShowToAll' => true,
|
||||
'creationAllowedGroups' => [],
|
||||
'restrictCreation' => false,
|
||||
|
||||
'canCreateForms' => true
|
||||
]
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче