mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
feat: add system address book settings in ui
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
This commit is contained in:
parent
4efd119df7
commit
9b0302f7ac
5 changed files with 122 additions and 0 deletions
|
|
@ -295,6 +295,7 @@ return array(
|
|||
'OCA\\DAV\\Listener\\CalendarShareUpdateListener' => $baseDir . '/../lib/Listener/CalendarShareUpdateListener.php',
|
||||
'OCA\\DAV\\Listener\\CardListener' => $baseDir . '/../lib/Listener/CardListener.php',
|
||||
'OCA\\DAV\\Listener\\ClearPhotoCacheListener' => $baseDir . '/../lib/Listener/ClearPhotoCacheListener.php',
|
||||
'OCA\\DAV\\Listener\\DavAdminSettingsListener' => $baseDir . '/../lib/Listener/DavAdminSettingsListener.php',
|
||||
'OCA\\DAV\\Listener\\OutOfOfficeListener' => $baseDir . '/../lib/Listener/OutOfOfficeListener.php',
|
||||
'OCA\\DAV\\Listener\\SubscriptionListener' => $baseDir . '/../lib/Listener/SubscriptionListener.php',
|
||||
'OCA\\DAV\\Listener\\TrustedServerRemovedListener' => $baseDir . '/../lib/Listener/TrustedServerRemovedListener.php',
|
||||
|
|
@ -358,6 +359,7 @@ return array(
|
|||
'OCA\\DAV\\Server' => $baseDir . '/../lib/Server.php',
|
||||
'OCA\\DAV\\ServerFactory' => $baseDir . '/../lib/ServerFactory.php',
|
||||
'OCA\\DAV\\Service\\AbsenceService' => $baseDir . '/../lib/Service/AbsenceService.php',
|
||||
'OCA\\DAV\\Settings\\Admin\\SystemAddressBookSettings' => $baseDir . '/../lib/Settings/Admin/SystemAddressBookSettings.php',
|
||||
'OCA\\DAV\\Settings\\AvailabilitySettings' => $baseDir . '/../lib/Settings/AvailabilitySettings.php',
|
||||
'OCA\\DAV\\Settings\\CalDAVSettings' => $baseDir . '/../lib/Settings/CalDAVSettings.php',
|
||||
'OCA\\DAV\\SetupChecks\\NeedsSystemAddressBookSync' => $baseDir . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php',
|
||||
|
|
|
|||
|
|
@ -310,6 +310,7 @@ class ComposerStaticInitDAV
|
|||
'OCA\\DAV\\Listener\\CalendarShareUpdateListener' => __DIR__ . '/..' . '/../lib/Listener/CalendarShareUpdateListener.php',
|
||||
'OCA\\DAV\\Listener\\CardListener' => __DIR__ . '/..' . '/../lib/Listener/CardListener.php',
|
||||
'OCA\\DAV\\Listener\\ClearPhotoCacheListener' => __DIR__ . '/..' . '/../lib/Listener/ClearPhotoCacheListener.php',
|
||||
'OCA\\DAV\\Listener\\DavAdminSettingsListener' => __DIR__ . '/..' . '/../lib/Listener/DavAdminSettingsListener.php',
|
||||
'OCA\\DAV\\Listener\\OutOfOfficeListener' => __DIR__ . '/..' . '/../lib/Listener/OutOfOfficeListener.php',
|
||||
'OCA\\DAV\\Listener\\SubscriptionListener' => __DIR__ . '/..' . '/../lib/Listener/SubscriptionListener.php',
|
||||
'OCA\\DAV\\Listener\\TrustedServerRemovedListener' => __DIR__ . '/..' . '/../lib/Listener/TrustedServerRemovedListener.php',
|
||||
|
|
@ -373,6 +374,7 @@ class ComposerStaticInitDAV
|
|||
'OCA\\DAV\\Server' => __DIR__ . '/..' . '/../lib/Server.php',
|
||||
'OCA\\DAV\\ServerFactory' => __DIR__ . '/..' . '/../lib/ServerFactory.php',
|
||||
'OCA\\DAV\\Service\\AbsenceService' => __DIR__ . '/..' . '/../lib/Service/AbsenceService.php',
|
||||
'OCA\\DAV\\Settings\\Admin\\SystemAddressBookSettings' => __DIR__ . '/..' . '/../lib/Settings/Admin/SystemAddressBookSettings.php',
|
||||
'OCA\\DAV\\Settings\\AvailabilitySettings' => __DIR__ . '/..' . '/../lib/Settings/AvailabilitySettings.php',
|
||||
'OCA\\DAV\\Settings\\CalDAVSettings' => __DIR__ . '/..' . '/../lib/Settings/CalDAVSettings.php',
|
||||
'OCA\\DAV\\SetupChecks\\NeedsSystemAddressBookSync' => __DIR__ . '/..' . '/../lib/SetupChecks/NeedsSystemAddressBookSync.php',
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ use OCA\DAV\Listener\CalendarPublicationListener;
|
|||
use OCA\DAV\Listener\CalendarShareUpdateListener;
|
||||
use OCA\DAV\Listener\CardListener;
|
||||
use OCA\DAV\Listener\ClearPhotoCacheListener;
|
||||
use OCA\DAV\Listener\DavAdminSettingsListener;
|
||||
use OCA\DAV\Listener\OutOfOfficeListener;
|
||||
use OCA\DAV\Listener\SubscriptionListener;
|
||||
use OCA\DAV\Listener\TrustedServerRemovedListener;
|
||||
|
|
@ -65,6 +66,7 @@ use OCA\DAV\Listener\UserPreferenceListener;
|
|||
use OCA\DAV\Search\ContactsSearchProvider;
|
||||
use OCA\DAV\Search\EventsSearchProvider;
|
||||
use OCA\DAV\Search\TasksSearchProvider;
|
||||
use OCA\DAV\Settings\Admin\SystemAddressBookSettings;
|
||||
use OCA\DAV\SetupChecks\NeedsSystemAddressBookSync;
|
||||
use OCA\DAV\SetupChecks\WebdavEndpoint;
|
||||
use OCA\DAV\UserMigration\CalendarMigrator;
|
||||
|
|
@ -85,6 +87,8 @@ use OCP\Federation\Events\TrustedServerRemovedEvent;
|
|||
use OCP\Files\AppData\IAppDataFactory;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Server;
|
||||
use OCP\Settings\Events\DeclarativeSettingsGetValueEvent;
|
||||
use OCP\Settings\Events\DeclarativeSettingsSetValueEvent;
|
||||
use OCP\User\Events\BeforeUserDeletedEvent;
|
||||
use OCP\User\Events\BeforeUserIdUnassignedEvent;
|
||||
use OCP\User\Events\OutOfOfficeChangedEvent;
|
||||
|
|
@ -212,6 +216,12 @@ class Application extends App implements IBootstrap {
|
|||
|
||||
$context->registerSetupCheck(NeedsSystemAddressBookSync::class);
|
||||
$context->registerSetupCheck(WebdavEndpoint::class);
|
||||
|
||||
// register admin settings form and listener(s)
|
||||
$context->registerDeclarativeSettings(SystemAddressBookSettings::class);
|
||||
$context->registerEventListener(DeclarativeSettingsGetValueEvent::class, DavAdminSettingsListener::class);
|
||||
$context->registerEventListener(DeclarativeSettingsSetValueEvent::class, DavAdminSettingsListener::class);
|
||||
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
|
|
|
|||
65
apps/dav/lib/Listener/DavAdminSettingsListener.php
Normal file
65
apps/dav/lib/Listener/DavAdminSettingsListener.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
namespace OCA\DAV\Listener;
|
||||
|
||||
use OCA\DAV\AppInfo\Application;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\Settings\Events\DeclarativeSettingsGetValueEvent;
|
||||
use OCP\Settings\Events\DeclarativeSettingsSetValueEvent;
|
||||
|
||||
/** @template-implements IEventListener<DeclarativeSettingsGetValueEvent|DeclarativeSettingsSetValueEvent> */
|
||||
class DavAdminSettingsListener implements IEventListener {
|
||||
|
||||
public function __construct(
|
||||
private IAppConfig $config,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
|
||||
/** @var DeclarativeSettingsGetValueEvent|DeclarativeSettingsSetValueEvent $event */
|
||||
if ($event->getApp() !== Application::APP_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($event->getFormId() !== 'dav-admin-system-address-book') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($event instanceof DeclarativeSettingsGetValueEvent) {
|
||||
$this->handleGetValue($event);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($event instanceof DeclarativeSettingsSetValueEvent) {
|
||||
$this->handleSetValue($event);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function handleGetValue(DeclarativeSettingsGetValueEvent $event): void {
|
||||
|
||||
if ($event->getFieldId() === 'system_addressbook_enabled') {
|
||||
$event->setValue((int)$this->config->getValueBool('dav', 'system_addressbook_exposed', true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function handleSetValue(DeclarativeSettingsSetValueEvent $event): void {
|
||||
|
||||
if ($event->getFieldId() === 'system_addressbook_enabled') {
|
||||
$this->config->setValueBool('dav', 'system_addressbook_exposed', (bool)$event->getValue());
|
||||
$event->stopPropagation();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
43
apps/dav/lib/Settings/Admin/SystemAddressBookSettings.php
Normal file
43
apps/dav/lib/Settings/Admin/SystemAddressBookSettings.php
Normal file
|
|
@ -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' => [],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue