aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Settings
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Settings')
-rw-r--r--lib/public/Settings/DeclarativeSettingsTypes.php128
-rw-r--r--lib/public/Settings/Events/DeclarativeSettingsGetValueEvent.php88
-rw-r--r--lib/public/Settings/Events/DeclarativeSettingsRegisterFormEvent.php38
-rw-r--r--lib/public/Settings/Events/DeclarativeSettingsSetValueEvent.php70
-rw-r--r--lib/public/Settings/IDeclarativeManager.php75
-rw-r--r--lib/public/Settings/IDeclarativeSettingsForm.php65
-rw-r--r--lib/public/Settings/IDeclarativeSettingsFormWithHandlers.php31
-rw-r--r--lib/public/Settings/IDelegatedSettings.php38
-rw-r--r--lib/public/Settings/IIconSection.php32
-rw-r--r--lib/public/Settings/IManager.php84
-rw-r--r--lib/public/Settings/ISettings.php29
-rw-r--r--lib/public/Settings/ISubAdminSettings.php22
12 files changed, 599 insertions, 101 deletions
diff --git a/lib/public/Settings/DeclarativeSettingsTypes.php b/lib/public/Settings/DeclarativeSettingsTypes.php
new file mode 100644
index 00000000000..7edf0cbdd6e
--- /dev/null
+++ b/lib/public/Settings/DeclarativeSettingsTypes.php
@@ -0,0 +1,128 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Settings;
+
+/**
+ * Declarative settings types supported in the IDeclarativeSettingsForm forms
+ *
+ * @since 29.0.0
+ */
+final class DeclarativeSettingsTypes {
+ /**
+ * IDeclarativeSettingsForm section_type which is determines where the form is displayed
+ *
+ * @since 29.0.0
+ */
+ public const SECTION_TYPE_ADMIN = 'admin';
+
+ /**
+ * IDeclarativeSettingsForm section_type which is determines where the form is displayed
+ *
+ * @since 29.0.0
+ */
+ public const SECTION_TYPE_PERSONAL = 'personal';
+
+ /**
+ * IDeclarativeSettingsForm storage_type which is determines where and how the config value is stored
+ *
+ * For `external` storage_type the app needs to either implement event listeners for \OCP\Settings\SetDeclarativeSettingsValueEvent
+ * and \OCP\Settings\GetDeclarativeSettingsValueEvent or the IDeclarativeSettingsForm also needs to implement
+ * IDeclarativeSettingsFormWithHandlers for storing and retrieving the config value.
+ *
+ * @since 29.0.0
+ */
+ public const STORAGE_TYPE_EXTERNAL = 'external';
+
+ /**
+ * IDeclarativeSettingsForm storage_type which is determines where and how the config value is stored
+ *
+ * For `internal` storage_type the config value is stored in default `appconfig` and `preferences` tables.
+ *
+ * @since 29.0.0
+ */
+ public const STORAGE_TYPE_INTERNAL = 'internal';
+
+ /**
+ * NcInputField type text
+ *
+ * @since 29.0.0
+ */
+ public const TEXT = 'text';
+
+ /**
+ * NcInputField type password
+ *
+ * @since 29.0.0
+ */
+ public const PASSWORD = 'password';
+
+ /**
+ * NcInputField type email
+ *
+ * @since 29.0.0
+ */
+ public const EMAIL = 'email';
+
+ /**
+ * NcInputField type tel
+ *
+ * @since 29.0.0
+ */
+ public const TEL = 'tel';
+
+ /**
+ * NcInputField type url
+ *
+ * @since 29.0.0
+ */
+ public const URL = 'url';
+
+ /**
+ * NcInputField type number
+ *
+ * @since 29.0.0
+ */
+ public const NUMBER = 'number';
+
+ /**
+ * NcCheckboxRadioSwitch type checkbox
+ *
+ * @since 29.0.0
+ */
+ public const CHECKBOX = 'checkbox';
+
+ /**
+ * Multiple NcCheckboxRadioSwitch type checkbox representing a one config value (saved as JSON object)
+ *
+ * @since 29.0.0
+ */
+ public const MULTI_CHECKBOX = 'multi-checkbox';
+
+ /**
+ * NcCheckboxRadioSwitch type radio
+ *
+ * @since 29.0.0
+ */
+ public const RADIO = 'radio';
+
+ /**
+ * NcSelect
+ *
+ * @since 29.0.0
+ */
+ public const SELECT = 'select';
+
+ /**
+ * Multiple NcSelect representing a one config value (saved as JSON array)
+ *
+ * @since 29.0.0
+ */
+ public const MULTI_SELECT = 'multi-select';
+}
diff --git a/lib/public/Settings/Events/DeclarativeSettingsGetValueEvent.php b/lib/public/Settings/Events/DeclarativeSettingsGetValueEvent.php
new file mode 100644
index 00000000000..73f3f8b8561
--- /dev/null
+++ b/lib/public/Settings/Events/DeclarativeSettingsGetValueEvent.php
@@ -0,0 +1,88 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Settings\Events;
+
+use Exception;
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+use OCP\Settings\IDeclarativeSettingsForm;
+
+/**
+ * @psalm-import-type DeclarativeSettingsValueTypes from IDeclarativeSettingsForm
+ *
+ * @since 29.0.0
+ */
+class DeclarativeSettingsGetValueEvent extends Event {
+ /**
+ * @var ?DeclarativeSettingsValueTypes
+ */
+ private mixed $value = null;
+
+ /**
+ * @since 29.0.0
+ */
+ public function __construct(
+ private IUser $user,
+ private string $app,
+ private string $formId,
+ private string $fieldId,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function getApp(): string {
+ return $this->app;
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function getFormId(): string {
+ return $this->formId;
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function getFieldId(): string {
+ return $this->fieldId;
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function setValue(mixed $value): void {
+ $this->value = $value;
+ }
+
+ /**
+ * @return DeclarativeSettingsValueTypes
+ * @throws Exception
+ *
+ * @since 29.0.0
+ */
+ public function getValue(): mixed {
+ if ($this->value === null) {
+ throw new Exception('Value not set');
+ }
+
+ return $this->value;
+ }
+}
diff --git a/lib/public/Settings/Events/DeclarativeSettingsRegisterFormEvent.php b/lib/public/Settings/Events/DeclarativeSettingsRegisterFormEvent.php
new file mode 100644
index 00000000000..e861afdd580
--- /dev/null
+++ b/lib/public/Settings/Events/DeclarativeSettingsRegisterFormEvent.php
@@ -0,0 +1,38 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Settings\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\Settings\IDeclarativeManager;
+use OCP\Settings\IDeclarativeSettingsForm;
+
+/**
+ * @psalm-import-type DeclarativeSettingsFormSchemaWithoutValues from IDeclarativeSettingsForm
+ *
+ * @since 29.0.0
+ */
+class DeclarativeSettingsRegisterFormEvent extends Event {
+ /**
+ * @since 29.0.0
+ */
+ public function __construct(
+ private IDeclarativeManager $manager,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @param DeclarativeSettingsFormSchemaWithoutValues $schema
+ * @since 29.0.0
+ */
+ public function registerSchema(string $app, array $schema): void {
+ $this->manager->registerSchema($app, $schema);
+ }
+}
diff --git a/lib/public/Settings/Events/DeclarativeSettingsSetValueEvent.php b/lib/public/Settings/Events/DeclarativeSettingsSetValueEvent.php
new file mode 100644
index 00000000000..429b0c1ff36
--- /dev/null
+++ b/lib/public/Settings/Events/DeclarativeSettingsSetValueEvent.php
@@ -0,0 +1,70 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Settings\Events;
+
+use OCP\EventDispatcher\Event;
+use OCP\IUser;
+use OCP\Settings\IDeclarativeSettingsForm;
+
+/**
+ * @psalm-import-type DeclarativeSettingsValueTypes from IDeclarativeSettingsForm
+ *
+ * @since 29.0.0
+ */
+class DeclarativeSettingsSetValueEvent extends Event {
+ /**
+ * @param DeclarativeSettingsValueTypes $value
+ * @since 29.0.0
+ */
+ public function __construct(
+ private IUser $user,
+ private string $app,
+ private string $formId,
+ private string $fieldId,
+ private mixed $value,
+ ) {
+ parent::__construct();
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function getUser(): IUser {
+ return $this->user;
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function getApp(): string {
+ return $this->app;
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function getFormId(): string {
+ return $this->formId;
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function getFieldId(): string {
+ return $this->fieldId;
+ }
+
+ /**
+ * @since 29.0.0
+ */
+ public function getValue(): mixed {
+ return $this->value;
+ }
+}
diff --git a/lib/public/Settings/IDeclarativeManager.php b/lib/public/Settings/IDeclarativeManager.php
new file mode 100644
index 00000000000..5c21ee6750b
--- /dev/null
+++ b/lib/public/Settings/IDeclarativeManager.php
@@ -0,0 +1,75 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Settings;
+
+use Exception;
+use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException;
+use OCP\IUser;
+
+/**
+ * @since 29.0.0
+ *
+ * @psalm-import-type DeclarativeSettingsValueTypes from IDeclarativeSettingsForm
+ * @psalm-import-type DeclarativeSettingsSectionType from IDeclarativeSettingsForm
+ * @psalm-import-type DeclarativeSettingsFormSchemaWithValues from IDeclarativeSettingsForm
+ * @psalm-import-type DeclarativeSettingsFormSchemaWithoutValues from IDeclarativeSettingsForm
+ */
+interface IDeclarativeManager {
+ /**
+ * Registers a new declarative settings schema.
+ *
+ * @param DeclarativeSettingsFormSchemaWithoutValues $schema
+ * @since 29.0.0
+ */
+ public function registerSchema(string $app, array $schema): void;
+
+ /**
+ * Load all schemas from the registration context and events.
+ *
+ * @since 29.0.0
+ */
+ public function loadSchemas(): void;
+
+ /**
+ * Gets the IDs of the forms for the given type and section.
+ *
+ * @param DeclarativeSettingsSectionType $type
+ * @param string $section
+ * @return array<string, list<string>>
+ *
+ * @since 29.0.0
+ */
+ public function getFormIDs(IUser $user, string $type, string $section): array;
+
+ /**
+ * Gets the forms including the field values for the given type and section.
+ *
+ * @param IUser $user Used for reading values from the personal section or for authorization for the admin section.
+ * @param ?DeclarativeSettingsSectionType $type If it is null the forms will not be filtered by type.
+ * @param ?string $section If it is null the forms will not be filtered by section.
+ * @return list<DeclarativeSettingsFormSchemaWithValues>
+ *
+ * @since 29.0.0
+ */
+ public function getFormsWithValues(IUser $user, ?string $type, ?string $section): array;
+
+ /**
+ * Sets a value for the given field ID.
+ *
+ * @param IUser $user Used for storing values in the personal section or for authorization for the admin section.
+ * @param DeclarativeSettingsValueTypes $value
+ *
+ * @throws Exception
+ * @throws NotAdminException
+ *
+ * @since 29.0.0
+ */
+ public function setValue(IUser $user, string $app, string $formId, string $fieldId, mixed $value): void;
+}
diff --git a/lib/public/Settings/IDeclarativeSettingsForm.php b/lib/public/Settings/IDeclarativeSettingsForm.php
new file mode 100644
index 00000000000..419905b7b23
--- /dev/null
+++ b/lib/public/Settings/IDeclarativeSettingsForm.php
@@ -0,0 +1,65 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Settings;
+
+/**
+ * @since 29.0.0
+ *
+ * @psalm-type DeclarativeSettingsSectionType = 'admin'|'personal'
+ *
+ * @psalm-type DeclarativeSettingsStorageType = 'internal'|'external'
+ *
+ * @psalm-type DeclarativeSettingsValueTypes = string|int|float|bool|list<string>
+ *
+ * @psalm-type DeclarativeSettingsFormField = array{
+ * id: string,
+ * title: string,
+ * description?: string,
+ * type: 'text'|'password'|'email'|'tel'|'url'|'number'|'checkbox'|'multi-checkbox'|'radio'|'select'|'multi-select',
+ * placeholder?: string,
+ * label?: string,
+ * default: mixed,
+ * options?: list<string|array{name: string, value: mixed}>,
+ * sensitive?: boolean,
+ * }
+ *
+ * @psalm-type DeclarativeSettingsFormFieldWithValue = DeclarativeSettingsFormField&array{
+ * value: DeclarativeSettingsValueTypes,
+ * }
+ *
+ * @psalm-type DeclarativeSettingsFormSchema = array{
+ * id: string,
+ * priority: int,
+ * section_type: DeclarativeSettingsSectionType,
+ * section_id: string,
+ * storage_type: DeclarativeSettingsStorageType,
+ * title: string,
+ * description?: string,
+ * doc_url?: string,
+ * }
+ *
+ * @psalm-type DeclarativeSettingsFormSchemaWithValues = DeclarativeSettingsFormSchema&array{
+ * app: string,
+ * fields: list<DeclarativeSettingsFormFieldWithValue>,
+ * }
+ *
+ * @psalm-type DeclarativeSettingsFormSchemaWithoutValues = DeclarativeSettingsFormSchema&array{
+ * fields: list<DeclarativeSettingsFormField>,
+ * }
+ */
+interface IDeclarativeSettingsForm {
+ /**
+ * Gets the schema that defines the declarative settings form
+ *
+ * @return DeclarativeSettingsFormSchemaWithoutValues
+ * @since 29.0.0
+ */
+ public function getSchema(): array;
+}
diff --git a/lib/public/Settings/IDeclarativeSettingsFormWithHandlers.php b/lib/public/Settings/IDeclarativeSettingsFormWithHandlers.php
new file mode 100644
index 00000000000..180df73d995
--- /dev/null
+++ b/lib/public/Settings/IDeclarativeSettingsFormWithHandlers.php
@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Settings;
+
+use OCP\IUser;
+
+/**
+ * @since 31.0.0
+ */
+interface IDeclarativeSettingsFormWithHandlers extends IDeclarativeSettingsForm {
+
+ /**
+ * This function is called to get the current value of a specific forms field.
+ * @since 31.0.0
+ */
+ public function getValue(string $fieldId, IUser $user): mixed;
+
+ /**
+ * This function is called when a user updated a form field to persist the setting.
+ * @since 31.0.0
+ */
+ public function setValue(string $fieldId, mixed $value, IUser $user): void;
+
+}
diff --git a/lib/public/Settings/IDelegatedSettings.php b/lib/public/Settings/IDelegatedSettings.php
new file mode 100644
index 00000000000..ae885dee705
--- /dev/null
+++ b/lib/public/Settings/IDelegatedSettings.php
@@ -0,0 +1,38 @@
+<?php
+
+/**
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Settings;
+
+/**
+ * Special cases of settings that can be allowed to use by member of special
+ * groups.
+ * @since 23.0.0
+ */
+interface IDelegatedSettings extends ISettings {
+ /**
+ * Get the name of the settings to differentiate settings inside a section or
+ * null if only the section name should be displayed.
+ * @since 23.0.0
+ */
+ public function getName(): ?string;
+
+ /**
+ * Get a list of authorized app config that this setting is allowed to modify.
+ * The format of the array is the following:
+ * ```php
+ * <?php
+ * [
+ * 'app_name' => [
+ * '/simple_key/', # value
+ * '/s[a-z]*ldap/', # regex
+ * ],
+ * 'another_app_name => [ ... ],
+ * ]
+ * ```
+ * @since 23.0.0
+ */
+ public function getAuthorizedAppConfig(): array;
+}
diff --git a/lib/public/Settings/IIconSection.php b/lib/public/Settings/IIconSection.php
index 3a7ef9ed126..4d0fe40aa29 100644
--- a/lib/public/Settings/IIconSection.php
+++ b/lib/public/Settings/IIconSection.php
@@ -1,27 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2017, Joas Schilling <coding@schilljs.com>
- *
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace OCP\Settings;
/**
@@ -32,7 +14,7 @@ interface IIconSection {
* returns the ID of the section. It is supposed to be a lower case string,
* e.g. 'ldap'
*
- * @returns string
+ * @return string
* @since 9.1
*/
public function getID();
@@ -48,8 +30,8 @@ interface IIconSection {
/**
* @return int whether the form should be rather on the top or bottom of
- * the settings navigation. The sections are arranged in ascending order of
- * the priority values. It is required to return a value between 0 and 99.
+ * the settings navigation. The sections are arranged in ascending order of
+ * the priority values. It is required to return a value between 0 and 99.
*
* E.g.: 70
* @since 9.1
@@ -60,7 +42,7 @@ interface IIconSection {
* returns the relative path to an 16*16 icon describing the section.
* e.g. '/core/img/places/files.svg'
*
- * @returns string
+ * @return string
* @since 12
*/
public function getIcon();
diff --git a/lib/public/Settings/IManager.php b/lib/public/Settings/IManager.php
index 88a8a297c54..954fd3fdb56 100644
--- a/lib/public/Settings/IManager.php
+++ b/lib/public/Settings/IManager.php
@@ -1,65 +1,62 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Settings;
+use OCP\IUser;
+
/**
* @since 9.1
*/
interface IManager {
/**
* @since 9.1.0
+ * @deprecated 29.0.0 Use {@see self::SETTINGS_ADMIN} instead
*/
public const KEY_ADMIN_SETTINGS = 'admin';
/**
* @since 9.1.0
+ * @deprecated 29.0.0 Use {@see self::SETTINGS_ADMIN} instead
*/
public const KEY_ADMIN_SECTION = 'admin-section';
/**
* @since 13.0.0
+ * @deprecated 29.0.0 Use {@see self::SETTINGS_PERSONAL} instead
*/
public const KEY_PERSONAL_SETTINGS = 'personal';
/**
* @since 13.0.0
+ * @deprecated 29.0.0 Use {@see self::SETTINGS_PERSONAL} instead
*/
public const KEY_PERSONAL_SECTION = 'personal-section';
/**
- * @param string $type 'admin' or 'personal'
- * @param string $section Class must implement OCP\Settings\ISection
+ * @since 29.0.0
+ */
+ public const SETTINGS_ADMIN = 'admin';
+
+ /**
+ * @since 29.0.0
+ */
+ public const SETTINGS_PERSONAL = 'personal';
+
+ /**
+ * @psalm-param self::SETTINGS_* $type
+ * @param class-string<IIconSection> $section
* @since 14.0.0
*/
public function registerSection(string $type, string $section);
/**
- * @param string $type 'admin' or 'personal'
- * @param string $setting Class must implement OCP\Settings\ISetting
+ * @psalm-param self::SETTINGS_* $type
+ * @param class-string<ISettings> $setting
* @since 14.0.0
*/
public function registerSetting(string $type, string $setting);
@@ -67,7 +64,7 @@ interface IManager {
/**
* returns a list of the admin sections
*
- * @return array array of ISection[] where key is the priority
+ * @return array<int, list<IIconSection>> list of sections with priority as key
* @since 9.1.0
*/
public function getAdminSections(): array;
@@ -75,7 +72,7 @@ interface IManager {
/**
* returns a list of the personal sections
*
- * @return array array of ISection[] where key is the priority
+ * @return array<int, list<IIconSection>> list of sections with priority as key
* @since 13.0.0
*/
public function getPersonalSections(): array;
@@ -85,17 +82,40 @@ interface IManager {
*
* @param string $section the section id for which to load the settings
* @param bool $subAdminOnly only return settings sub admins are supposed to see (since 17.0.0)
- * @return array array of IAdmin[] where key is the priority
+ * @return array<int, list<ISettings>> list of settings with priority as key
* @since 9.1.0
*/
- public function getAdminSettings($section, bool $subAdminOnly = false): array;
+ public function getAdminSettings(string $section, bool $subAdminOnly = false): array;
+
+ /**
+ * Returns a list of admin settings that the given user can use for the give section
+ *
+ * @return array<int, list<ISettings>> List of admin-settings the user has access to, with priority as key.
+ * @since 23.0.0
+ */
+ public function getAllowedAdminSettings(string $section, IUser $user): array;
+
+ /**
+ * Returns a list of admin settings that the given user can use.
+ *
+ * @return list<ISettings> The array of admin settings there admin delegation is allowed.
+ * @since 23.0.0
+ */
+ public function getAllAllowedAdminSettings(IUser $user): array;
/**
* returns a list of the personal settings
*
* @param string $section the section id for which to load the settings
- * @return array array of IPersonal[] where key is the priority
+ * @return array<int, list<ISettings>> list of settings with priority as key
* @since 13.0.0
*/
- public function getPersonalSettings($section): array;
+ public function getPersonalSettings(string $section): array;
+
+ /**
+ * Get a specific section by type and id
+ * @psalm-param self::SETTINGS_* $type
+ * @since 25.0.0
+ */
+ public function getSection(string $type, string $sectionId): ?IIconSection;
}
diff --git a/lib/public/Settings/ISettings.php b/lib/public/Settings/ISettings.php
index a7bae53e3bf..e33556f0b4a 100644
--- a/lib/public/Settings/ISettings.php
+++ b/lib/public/Settings/ISettings.php
@@ -1,27 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Lukas Reschke <lukas@statuscode.ch>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace OCP\Settings;
use OCP\AppFramework\Http\TemplateResponse;
@@ -30,7 +12,6 @@ use OCP\AppFramework\Http\TemplateResponse;
* @since 9.1
*/
interface ISettings {
-
/**
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
* @since 9.1
@@ -45,8 +26,8 @@ interface ISettings {
/**
* @return int whether the form should be rather on the top or bottom of
- * the admin section. The forms are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
+ * the admin section. The forms are arranged in ascending order of the
+ * priority values. It is required to return a value between 0 and 100.
*
* E.g.: 70
* @since 9.1
diff --git a/lib/public/Settings/ISubAdminSettings.php b/lib/public/Settings/ISubAdminSettings.php
index d7f55eddfb0..dfe3b1b9e73 100644
--- a/lib/public/Settings/ISubAdminSettings.php
+++ b/lib/public/Settings/ISubAdminSettings.php
@@ -3,27 +3,9 @@
declare(strict_types=1);
/**
- * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-
namespace OCP\Settings;
/**