From 7343fee4b240f71726de592ab216f1a221762bf7 Mon Sep 17 00:00:00 2001 From: Jonas Rittershofer Date: Wed, 3 Feb 2021 15:29:31 +0100 Subject: [PATCH] Create proper Settings Section Signed-off-by: Jonas Rittershofer --- appinfo/info.xml | 1 + lib/Settings/RegistrationSettings.php | 3 +- lib/Settings/RegistrationSettingsSection.php | 73 ++++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 lib/Settings/RegistrationSettingsSection.php diff --git a/appinfo/info.xml b/appinfo/info.xml index 55d3b0a..4dc2713 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -42,5 +42,6 @@ This app allows users to register a new account. OCA\Registration\Settings\RegistrationSettings + OCA\Registration\Settings\RegistrationSettingsSection diff --git a/lib/Settings/RegistrationSettings.php b/lib/Settings/RegistrationSettings.php index 5414213..ecf3139 100644 --- a/lib/Settings/RegistrationSettings.php +++ b/lib/Settings/RegistrationSettings.php @@ -44,7 +44,6 @@ class RegistrationSettings implements ISettings { $this->appName = $appName; $this->config = $config; $this->groupManager = $groupManager; - $this->appName = $appName; } public function getForm(): TemplateResponse { @@ -86,7 +85,7 @@ class RegistrationSettings implements ISettings { } public function getSection(): string { - return 'additional'; + return 'registration'; } public function getPriority(): int { diff --git a/lib/Settings/RegistrationSettingsSection.php b/lib/Settings/RegistrationSettingsSection.php new file mode 100644 index 0000000..df11e3d --- /dev/null +++ b/lib/Settings/RegistrationSettingsSection.php @@ -0,0 +1,73 @@ + + * + * @author Jonas Rittershofer + * + * @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 . + * + */ + +namespace OCA\Registration\Settings; + +use OCP\IL10N; +use OCP\IURLGenerator; +use OCP\Settings\IIconSection; + +class RegistrationSettingsSection implements IIconSection { + /** @var IL10N */ + private $l10n; + + /** @var IURLGenerator */ + private $urlGenerator; + + public function __construct(IL10N $l10n, IURLGenerator $urlGenerator) { + $this->l10n = $l10n; + $this->urlGenerator = $urlGenerator; + } + + /** + * Section ID to be set in Settings + * @return string + */ + public function getID(): string { + return 'registration'; + } + + /** + * Section Name to be displayed + * @return string + */ + public function getName(): string { + return $this->l10n->t('Registration'); + } + + /** + * Return Priority of section 0-100 + * @return int + */ + public function getPriority(): int { + return 80; + } + + /** + * Pass the relative path to the icon + * @return string + */ + public function getIcon(): string { + return $this->urlGenerator->imagePath('registration', 'app.svg'); + } +}