aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/Settings
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/lib/Settings')
-rw-r--r--apps/dav/lib/Settings/Admin/SystemAddressBookSettings.php43
-rw-r--r--apps/dav/lib/Settings/AvailabilitySettings.php65
-rw-r--r--apps/dav/lib/Settings/CalDAVSettings.php59
-rw-r--r--apps/dav/lib/Settings/ExampleContentSettings.php71
4 files changed, 177 insertions, 61 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 9a163e21edb..a1ada96b255 100644
--- a/apps/dav/lib/Settings/AvailabilitySettings.php
+++ b/apps/dav/lib/Settings/AvailabilitySettings.php
@@ -2,40 +2,65 @@
declare(strict_types=1);
-/*
- * @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2021 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: 2021 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\Db\AbsenceMapper;
+use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http\TemplateResponse;
+use OCP\AppFramework\Services\IInitialState;
+use OCP\IConfig;
use OCP\Settings\ISettings;
+use OCP\User\IAvailabilityCoordinator;
+use Psr\Log\LoggerInterface;
class AvailabilitySettings implements ISettings {
+ public function __construct(
+ protected IConfig $config,
+ protected IInitialState $initialState,
+ protected ?string $userId,
+ private LoggerInterface $logger,
+ private IAvailabilityCoordinator $coordinator,
+ private AbsenceMapper $absenceMapper,
+ ) {
+ }
+
public function getForm(): TemplateResponse {
+ $this->initialState->provideInitialState(
+ 'user_status_automation',
+ $this->config->getUserValue(
+ $this->userId,
+ 'dav',
+ 'user_status_automation',
+ 'no'
+ )
+ );
+ $hideAbsenceSettings = !$this->coordinator->isEnabled();
+ $this->initialState->provideInitialState('hide_absence_settings', $hideAbsenceSettings);
+ if (!$hideAbsenceSettings) {
+ try {
+ $absence = $this->absenceMapper->findByUserId($this->userId);
+ $this->initialState->provideInitialState('absence', $absence);
+ } catch (DoesNotExistException) {
+ // The user has not yet set up an absence period.
+ // Logging this error is not necessary.
+ } catch (\OCP\DB\Exception $e) {
+ $this->logger->error("Could not find absence data for user $this->userId: " . $e->getMessage(), [
+ 'exception' => $e,
+ ]);
+ }
+ }
+
return new TemplateResponse(Application::APP_ID, 'settings-personal-availability');
}
public function getSection(): string {
- return 'groupware';
+ return 'availability';
}
public function getPriority(): int {
diff --git a/apps/dav/lib/Settings/CalDAVSettings.php b/apps/dav/lib/Settings/CalDAVSettings.php
index 6d60b2611e0..5e19539a899 100644
--- a/apps/dav/lib/Settings/CalDAVSettings.php
+++ b/apps/dav/lib/Settings/CalDAVSettings.php
@@ -1,53 +1,27 @@
<?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\IConfig;
use OCP\AppFramework\Services\IInitialState;
+use OCP\IConfig;
use OCP\IURLGenerator;
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',
'sendEventReminders' => 'yes',
- 'sendEventRemindersToSharedGroupMembers' => 'yes',
- 'sendEventRemindersPush' => 'no',
+ 'sendEventRemindersToSharedUsers' => 'yes',
+ 'sendEventRemindersPush' => '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;
+ }
+}