зеркало из 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_ALLOWPERMITALL = 'allowPermitAll';
|
||||||
public const CONFIG_KEY_ALLOWPUBLICLINK = 'allowPublicLink';
|
public const CONFIG_KEY_ALLOWPUBLICLINK = 'allowPublicLink';
|
||||||
|
public const CONFIG_KEY_ALLOWSHOWTOALL = 'allowShowToAll';
|
||||||
public const CONFIG_KEY_CREATIONALLOWEDGROUPS = 'creationAllowedGroups';
|
public const CONFIG_KEY_CREATIONALLOWEDGROUPS = 'creationAllowedGroups';
|
||||||
public const CONFIG_KEY_RESTRICTCREATION = 'restrictCreation';
|
public const CONFIG_KEY_RESTRICTCREATION = 'restrictCreation';
|
||||||
public const CONFIG_KEYS = [
|
public const CONFIG_KEYS = [
|
||||||
self::CONFIG_KEY_ALLOWPERMITALL,
|
self::CONFIG_KEY_ALLOWPERMITALL,
|
||||||
self::CONFIG_KEY_ALLOWPUBLICLINK,
|
self::CONFIG_KEY_ALLOWPUBLICLINK,
|
||||||
|
self::CONFIG_KEY_ALLOWSHOWTOALL,
|
||||||
self::CONFIG_KEY_CREATIONALLOWEDGROUPS,
|
self::CONFIG_KEY_CREATIONALLOWEDGROUPS,
|
||||||
self::CONFIG_KEY_RESTRICTCREATION
|
self::CONFIG_KEY_RESTRICTCREATION
|
||||||
];
|
];
|
||||||
|
|
|
@ -57,6 +57,9 @@ class ConfigService {
|
||||||
public function getAllowPublicLink(): bool {
|
public function getAllowPublicLink(): bool {
|
||||||
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_ALLOWPUBLICLINK, 'true'));
|
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 {
|
private function getUnformattedCreationAllowedGroups(): array {
|
||||||
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_CREATIONALLOWEDGROUPS, '[]'));
|
return json_decode($this->config->getAppValue($this->appName, Constants::CONFIG_KEY_CREATIONALLOWEDGROUPS, '[]'));
|
||||||
}
|
}
|
||||||
|
@ -74,6 +77,7 @@ class ConfigService {
|
||||||
return [
|
return [
|
||||||
Constants::CONFIG_KEY_ALLOWPERMITALL => $this->getAllowPermitAll(),
|
Constants::CONFIG_KEY_ALLOWPERMITALL => $this->getAllowPermitAll(),
|
||||||
Constants::CONFIG_KEY_ALLOWPUBLICLINK => $this->getAllowPublicLink(),
|
Constants::CONFIG_KEY_ALLOWPUBLICLINK => $this->getAllowPublicLink(),
|
||||||
|
Constants::CONFIG_KEY_ALLOWSHOWTOALL => $this->getAllowShowToAll(),
|
||||||
Constants::CONFIG_KEY_CREATIONALLOWEDGROUPS => $this->getCreationAllowedGroups(),
|
Constants::CONFIG_KEY_CREATIONALLOWEDGROUPS => $this->getCreationAllowedGroups(),
|
||||||
Constants::CONFIG_KEY_RESTRICTCREATION => $this->getRestrictCreation(),
|
Constants::CONFIG_KEY_RESTRICTCREATION => $this->getRestrictCreation(),
|
||||||
|
|
||||||
|
|
|
@ -465,6 +465,14 @@ class FormsService {
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,18 @@
|
||||||
@update:checked="onAllowPermitAllChange">
|
@update:checked="onAllowPermitAllChange">
|
||||||
{{ t('forms', 'Allow sharing to all logged in accounts') }}
|
{{ t('forms', 'Allow sharing to all logged in accounts') }}
|
||||||
</NcCheckboxRadioSwitch>
|
</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>
|
</NcSettingsSection>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -124,6 +136,12 @@ export default {
|
||||||
await this.saveAppConfig('allowPermitAll', newVal)
|
await this.saveAppConfig('allowPermitAll', newVal)
|
||||||
el.loading = false
|
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.
|
* Save a key-value pair to the appConfig.
|
||||||
|
|
|
@ -190,7 +190,7 @@
|
||||||
@update:checked="onPermitAllUsersChange" />
|
@update:checked="onPermitAllUsersChange" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="form.access.permitAllUsers"
|
v-if="appConfig.allowShowToAll && form.access.permitAllUsers"
|
||||||
class="share-div share-div--indent">
|
class="share-div share-div--indent">
|
||||||
<div class="share-div__avatar">
|
<div class="share-div__avatar">
|
||||||
<FormsIcon :size="16" />
|
<FormsIcon :size="16" />
|
||||||
|
|
|
@ -91,6 +91,11 @@ class ConfigControllerTest extends TestCase {
|
||||||
'configValue' => true,
|
'configValue' => true,
|
||||||
'strConfig' => 'true'
|
'strConfig' => 'true'
|
||||||
],
|
],
|
||||||
|
'booleanConfig' => [
|
||||||
|
'configKey' => 'allowShowToAll',
|
||||||
|
'configValue' => true,
|
||||||
|
'strConfig' => 'true'
|
||||||
|
],
|
||||||
'arrayConfig' => [
|
'arrayConfig' => [
|
||||||
'configKey' => 'allowPermitAll',
|
'configKey' => 'allowPermitAll',
|
||||||
'configValue' => [
|
'configValue' => [
|
||||||
|
|
|
@ -85,6 +85,7 @@ class ConfigServiceTest extends TestCase {
|
||||||
'strConfig' => [
|
'strConfig' => [
|
||||||
'allowPermitAll' => 'false',
|
'allowPermitAll' => 'false',
|
||||||
'allowPublicLink' => 'false',
|
'allowPublicLink' => 'false',
|
||||||
|
'allowShowToAll' => 'false',
|
||||||
'creationAllowedGroups' => '["group1", "group2", "nonExisting"]',
|
'creationAllowedGroups' => '["group1", "group2", "nonExisting"]',
|
||||||
'restrictCreation' => 'true',
|
'restrictCreation' => 'true',
|
||||||
],
|
],
|
||||||
|
@ -95,6 +96,7 @@ class ConfigServiceTest extends TestCase {
|
||||||
'expected' => [
|
'expected' => [
|
||||||
'allowPermitAll' => false,
|
'allowPermitAll' => false,
|
||||||
'allowPublicLink' => false,
|
'allowPublicLink' => false,
|
||||||
|
'allowShowToAll' => false,
|
||||||
'creationAllowedGroups' => [
|
'creationAllowedGroups' => [
|
||||||
[
|
[
|
||||||
'groupId' => 'group1',
|
'groupId' => 'group1',
|
||||||
|
@ -157,9 +159,9 @@ class ConfigServiceTest extends TestCase {
|
||||||
'expected' => [
|
'expected' => [
|
||||||
'allowPermitAll' => true,
|
'allowPermitAll' => true,
|
||||||
'allowPublicLink' => true,
|
'allowPublicLink' => true,
|
||||||
|
'allowShowToAll' => true,
|
||||||
'creationAllowedGroups' => [],
|
'creationAllowedGroups' => [],
|
||||||
'restrictCreation' => false,
|
'restrictCreation' => false,
|
||||||
|
|
||||||
'canCreateForms' => true
|
'canCreateForms' => true
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
Загрузка…
Ссылка в новой задаче