diff options
Diffstat (limited to 'apps/dav/lib/Settings')
-rw-r--r-- | apps/dav/lib/Settings/Admin/SystemAddressBookSettings.php | 43 | ||||
-rw-r--r-- | apps/dav/lib/Settings/AvailabilitySettings.php | 40 | ||||
-rw-r--r-- | apps/dav/lib/Settings/CalDAVSettings.php | 53 | ||||
-rw-r--r-- | apps/dav/lib/Settings/ExampleContentSettings.php | 71 |
4 files changed, 138 insertions, 69 deletions
diff --git a/apps/dav/lib/Settings/Admin/SystemAddressBookSettings.php b/apps/dav/lib/Settings/Admin/SystemAddressBookSettings.php new file mode 100644 index 00000000000..2f7b9f8fcc9 --- /dev/null +++ b/apps/dav/lib/Settings/Admin/SystemAddressBookSettings.php @@ -0,0 +1,43 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCA\DAV\Settings\Admin; + +use OCP\IL10N; +use OCP\Settings\DeclarativeSettingsTypes; +use OCP\Settings\IDeclarativeSettingsForm; + +class SystemAddressBookSettings implements IDeclarativeSettingsForm { + + public function __construct( + private IL10N $l, + ) { + } + + public function getSchema(): array { + return [ + 'id' => 'dav-admin-system-address-book', + 'priority' => 10, + 'section_type' => DeclarativeSettingsTypes::SECTION_TYPE_ADMIN, + 'section_id' => 'groupware', + 'storage_type' => DeclarativeSettingsTypes::STORAGE_TYPE_EXTERNAL, + 'title' => $this->l->t('System Address Book'), + 'description' => $this->l->t('The system address book contains contact information for all users in your instance.'), + + 'fields' => [ + [ + 'id' => 'system_addressbook_enabled', + 'title' => $this->l->t('Enable System Address Book'), + 'type' => DeclarativeSettingsTypes::CHECKBOX, + 'default' => false, + 'options' => [], + ], + ], + ]; + } + +} diff --git a/apps/dav/lib/Settings/AvailabilitySettings.php b/apps/dav/lib/Settings/AvailabilitySettings.php index f8986ffe5d1..a1ada96b255 100644 --- a/apps/dav/lib/Settings/AvailabilitySettings.php +++ b/apps/dav/lib/Settings/AvailabilitySettings.php @@ -2,26 +2,9 @@ declare(strict_types=1); -/* - * @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author 2021 Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Richard Steinmetz <richard@steinmetz.cloud> - * - * @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: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCA\DAV\Settings; @@ -37,19 +20,14 @@ use OCP\User\IAvailabilityCoordinator; use Psr\Log\LoggerInterface; class AvailabilitySettings implements ISettings { - protected IConfig $config; - protected IInitialState $initialState; - protected ?string $userId; - - public function __construct(IConfig $config, - IInitialState $initialState, - ?string $userId, + public function __construct( + protected IConfig $config, + protected IInitialState $initialState, + protected ?string $userId, private LoggerInterface $logger, private IAvailabilityCoordinator $coordinator, - private AbsenceMapper $absenceMapper) { - $this->config = $config; - $this->initialState = $initialState; - $this->userId = $userId; + private AbsenceMapper $absenceMapper, + ) { } public function getForm(): TemplateResponse { diff --git a/apps/dav/lib/Settings/CalDAVSettings.php b/apps/dav/lib/Settings/CalDAVSettings.php index 2985c9fc888..5e19539a899 100644 --- a/apps/dav/lib/Settings/CalDAVSettings.php +++ b/apps/dav/lib/Settings/CalDAVSettings.php @@ -1,31 +1,13 @@ <?php + /** - * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com> - * - * @author Georg Ehrke <oc.list@georgehrke.com> - * @author Julius Härtl <jus@bitgrid.net> - * @author Thomas Citharel <nextcloud@tcit.fr> - * @author François Freitag <mail@franek.fr> - * - * @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 OCA\DAV\Settings; use OCA\DAV\AppInfo\Application; +use OCP\App\IAppManager; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Services\IInitialState; use OCP\IConfig; @@ -34,14 +16,6 @@ use OCP\Settings\IDelegatedSettings; class CalDAVSettings implements IDelegatedSettings { - /** @var IConfig */ - private $config; - - /** @var IInitialState */ - private $initialState; - - private IURLGenerator $urlGenerator; - private const defaults = [ 'sendInvitations' => 'yes', 'generateBirthdayCalendar' => 'yes', @@ -56,10 +30,12 @@ class CalDAVSettings implements IDelegatedSettings { * @param IConfig $config * @param IInitialState $initialState */ - public function __construct(IConfig $config, IInitialState $initialState, IURLGenerator $urlGenerator) { - $this->config = $config; - $this->initialState = $initialState; - $this->urlGenerator = $urlGenerator; + public function __construct( + private IConfig $config, + private IInitialState $initialState, + private IURLGenerator $urlGenerator, + private IAppManager $appManager, + ) { } public function getForm(): TemplateResponse { @@ -71,10 +47,11 @@ class CalDAVSettings implements IDelegatedSettings { return new TemplateResponse(Application::APP_ID, 'settings-admin-caldav'); } - /** - * @return string - */ - public function getSection() { + public function getSection(): ?string { + if (!$this->appManager->isBackendRequired(IAppManager::BACKEND_CALDAV)) { + return null; + } + return 'groupware'; } diff --git a/apps/dav/lib/Settings/ExampleContentSettings.php b/apps/dav/lib/Settings/ExampleContentSettings.php new file mode 100644 index 00000000000..7b6f9b03a3a --- /dev/null +++ b/apps/dav/lib/Settings/ExampleContentSettings.php @@ -0,0 +1,71 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCA\DAV\Settings; + +use OCA\DAV\AppInfo\Application; +use OCA\DAV\Service\ExampleContactService; +use OCA\DAV\Service\ExampleEventService; +use OCP\App\IAppManager; +use OCP\AppFramework\Http\TemplateResponse; +use OCP\AppFramework\Services\IAppConfig; +use OCP\AppFramework\Services\IInitialState; +use OCP\Settings\ISettings; + +class ExampleContentSettings implements ISettings { + public function __construct( + private readonly IAppConfig $appConfig, + private readonly IInitialState $initialState, + private readonly IAppManager $appManager, + private readonly ExampleEventService $exampleEventService, + private readonly ExampleContactService $exampleContactService, + ) { + } + + public function getForm(): TemplateResponse { + $calendarEnabled = $this->appManager->isEnabledForUser('calendar'); + $contactsEnabled = $this->appManager->isEnabledForUser('contacts'); + $this->initialState->provideInitialState('calendarEnabled', $calendarEnabled); + $this->initialState->provideInitialState('contactsEnabled', $contactsEnabled); + + if ($calendarEnabled) { + $enableDefaultEvent = $this->exampleEventService->shouldCreateExampleEvent(); + $this->initialState->provideInitialState('create_example_event', $enableDefaultEvent); + $this->initialState->provideInitialState( + 'has_custom_example_event', + $this->exampleEventService->hasCustomExampleEvent(), + ); + } + + if ($contactsEnabled) { + $this->initialState->provideInitialState( + 'enableDefaultContact', + $this->exampleContactService->isDefaultContactEnabled(), + ); + $this->initialState->provideInitialState( + 'hasCustomDefaultContact', + $this->appConfig->getAppValueBool('hasCustomDefaultContact'), + ); + } + + return new TemplateResponse(Application::APP_ID, 'settings-example-content'); + } + + public function getSection(): ?string { + if (!$this->appManager->isEnabledForUser('contacts') + && !$this->appManager->isEnabledForUser('calendar')) { + return null; + } + + return 'groupware'; + } + + public function getPriority(): int { + return 10; + } +} |