2015-10-21 09:06:48 -04:00
|
|
|
<?php
|
2024-05-27 11:39:07 -04:00
|
|
|
|
2016-01-12 09:02:16 -05:00
|
|
|
/**
|
2024-05-27 11:39:07 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2016-01-12 09:02:16 -05:00
|
|
|
*/
|
2015-10-21 09:06:48 -04:00
|
|
|
namespace OCA\DAV;
|
|
|
|
|
|
2021-03-09 15:48:48 -05:00
|
|
|
use OC\KnownUser\KnownUserService;
|
2020-02-27 10:54:07 -05:00
|
|
|
use OCA\DAV\AppInfo\PluginManager;
|
2015-10-30 20:28:21 -04:00
|
|
|
use OCA\DAV\CalDAV\CalDavBackend;
|
2016-01-26 06:06:02 -05:00
|
|
|
use OCA\DAV\CalDAV\CalendarRoot;
|
2025-05-14 05:21:28 -04:00
|
|
|
use OCA\DAV\CalDAV\Federation\FederatedCalendarFactory;
|
|
|
|
|
use OCA\DAV\CalDAV\Federation\FederatedCalendarMapper;
|
2019-11-22 14:52:10 -05:00
|
|
|
use OCA\DAV\CalDAV\Principal\Collection;
|
2019-08-06 07:40:52 -04:00
|
|
|
use OCA\DAV\CalDAV\Proxy\ProxyMapper;
|
2016-07-08 10:13:34 -04:00
|
|
|
use OCA\DAV\CalDAV\PublicCalendarRoot;
|
2018-05-28 14:12:13 -04:00
|
|
|
use OCA\DAV\CalDAV\ResourceBooking\ResourcePrincipalBackend;
|
|
|
|
|
use OCA\DAV\CalDAV\ResourceBooking\RoomPrincipalBackend;
|
2024-01-30 12:35:44 -05:00
|
|
|
use OCA\DAV\CalDAV\Sharing\Backend;
|
2015-11-05 10:46:37 -05:00
|
|
|
use OCA\DAV\CardDAV\AddressBookRoot;
|
2015-10-30 11:05:25 -04:00
|
|
|
use OCA\DAV\CardDAV\CardDavBackend;
|
2015-10-21 09:06:48 -04:00
|
|
|
use OCA\DAV\Connector\Sabre\Principal;
|
2016-01-08 06:11:02 -05:00
|
|
|
use OCA\DAV\DAV\GroupPrincipalBackend;
|
2025-05-14 05:21:28 -04:00
|
|
|
use OCA\DAV\DAV\RemoteUserPrincipalBackend;
|
2015-11-26 14:46:50 -05:00
|
|
|
use OCA\DAV\DAV\SystemPrincipalBackend;
|
2017-10-19 06:57:20 -04:00
|
|
|
use OCA\DAV\Provisioning\Apple\AppleProvisioningNode;
|
2024-10-10 06:40:31 -04:00
|
|
|
use OCA\DAV\SystemTag\SystemTagsByIdCollection;
|
|
|
|
|
use OCA\DAV\SystemTag\SystemTagsInUseCollection;
|
|
|
|
|
use OCA\DAV\SystemTag\SystemTagsRelationsCollection;
|
2018-11-02 16:19:27 -04:00
|
|
|
use OCA\DAV\Upload\CleanupService;
|
2022-02-05 13:55:23 -05:00
|
|
|
use OCP\Accounts\IAccountManager;
|
2020-02-27 10:54:07 -05:00
|
|
|
use OCP\App\IAppManager;
|
2017-10-19 06:57:20 -04:00
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
2025-02-03 09:34:01 -05:00
|
|
|
use OCP\Comments\ICommentsManager;
|
2020-07-28 03:35:51 -04:00
|
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
2023-04-27 16:24:16 -04:00
|
|
|
use OCP\Files\IRootFolder;
|
2025-08-15 07:54:56 -04:00
|
|
|
use OCP\ICacheFactory;
|
2021-03-12 05:20:04 -05:00
|
|
|
use OCP\IConfig;
|
2025-02-03 09:34:01 -05:00
|
|
|
use OCP\IDBConnection;
|
|
|
|
|
use OCP\IGroupManager;
|
|
|
|
|
use OCP\IUserManager;
|
|
|
|
|
use OCP\IUserSession;
|
|
|
|
|
use OCP\Security\ISecureRandom;
|
2024-10-10 06:40:31 -04:00
|
|
|
use OCP\Server;
|
2025-02-03 09:34:01 -05:00
|
|
|
use OCP\SystemTag\ISystemTagManager;
|
|
|
|
|
use OCP\SystemTag\ISystemTagObjectMapper;
|
2021-12-06 14:01:22 -05:00
|
|
|
use Psr\Log\LoggerInterface;
|
2015-10-21 09:06:48 -04:00
|
|
|
use Sabre\DAV\SimpleCollection;
|
|
|
|
|
|
|
|
|
|
class RootCollection extends SimpleCollection {
|
|
|
|
|
public function __construct() {
|
2017-10-20 09:09:52 -04:00
|
|
|
$l10n = \OC::$server->getL10N('dav');
|
2025-02-03 09:34:01 -05:00
|
|
|
$random = Server::get(ISecureRandom::class);
|
|
|
|
|
$logger = Server::get(LoggerInterface::class);
|
|
|
|
|
$userManager = Server::get(IUserManager::class);
|
|
|
|
|
$userSession = Server::get(IUserSession::class);
|
|
|
|
|
$groupManager = Server::get(IGroupManager::class);
|
|
|
|
|
$shareManager = Server::get(\OCP\Share\IManager::class);
|
|
|
|
|
$db = Server::get(IDBConnection::class);
|
|
|
|
|
$dispatcher = Server::get(IEventDispatcher::class);
|
|
|
|
|
$config = Server::get(IConfig::class);
|
|
|
|
|
$proxyMapper = Server::get(ProxyMapper::class);
|
2024-10-10 06:40:31 -04:00
|
|
|
$rootFolder = Server::get(IRootFolder::class);
|
2025-05-14 05:21:28 -04:00
|
|
|
$federatedCalendarFactory = Server::get(FederatedCalendarFactory::class);
|
2019-08-14 07:38:11 -04:00
|
|
|
|
2016-01-08 06:11:02 -05:00
|
|
|
$userPrincipalBackend = new Principal(
|
2016-09-03 04:52:05 -04:00
|
|
|
$userManager,
|
2017-12-04 09:02:55 -05:00
|
|
|
$groupManager,
|
2025-02-03 09:34:01 -05:00
|
|
|
Server::get(IAccountManager::class),
|
2017-12-04 09:02:55 -05:00
|
|
|
$shareManager,
|
2025-02-03 09:34:01 -05:00
|
|
|
Server::get(IUserSession::class),
|
|
|
|
|
Server::get(IAppManager::class),
|
2019-11-26 10:37:57 -05:00
|
|
|
$proxyMapper,
|
2025-02-03 09:34:01 -05:00
|
|
|
Server::get(KnownUserService::class),
|
|
|
|
|
Server::get(IConfig::class),
|
2021-08-16 11:55:27 -04:00
|
|
|
\OC::$server->getL10NFactory()
|
2015-10-21 09:06:48 -04:00
|
|
|
);
|
2024-01-30 12:35:44 -05:00
|
|
|
|
2020-12-11 08:04:40 -05:00
|
|
|
$groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager, $config);
|
2019-08-14 07:38:11 -04:00
|
|
|
$calendarResourcePrincipalBackend = new ResourcePrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper);
|
|
|
|
|
$calendarRoomPrincipalBackend = new RoomPrincipalBackend($db, $userSession, $groupManager, $logger, $proxyMapper);
|
2025-05-14 05:21:28 -04:00
|
|
|
$remoteUserPrincipalBackend = Server::get(RemoteUserPrincipalBackend::class);
|
2015-10-26 12:56:33 -04:00
|
|
|
// as soon as debug mode is enabled we allow listing of principals
|
|
|
|
|
$disableListing = !$config->getSystemValue('debug', false);
|
|
|
|
|
|
|
|
|
|
// setup the first level of the dav tree
|
2016-01-08 06:11:02 -05:00
|
|
|
$userPrincipals = new Collection($userPrincipalBackend, 'principals/users');
|
2015-11-26 14:46:50 -05:00
|
|
|
$userPrincipals->disableListing = $disableListing;
|
2016-01-08 06:11:02 -05:00
|
|
|
$groupPrincipals = new Collection($groupPrincipalBackend, 'principals/groups');
|
|
|
|
|
$groupPrincipals->disableListing = $disableListing;
|
2015-11-26 14:46:50 -05:00
|
|
|
$systemPrincipals = new Collection(new SystemPrincipalBackend(), 'principals/system');
|
|
|
|
|
$systemPrincipals->disableListing = $disableListing;
|
2018-05-28 14:12:13 -04:00
|
|
|
$calendarResourcePrincipals = new Collection($calendarResourcePrincipalBackend, 'principals/calendar-resources');
|
|
|
|
|
$calendarRoomPrincipals = new Collection($calendarRoomPrincipalBackend, 'principals/calendar-rooms');
|
2025-05-14 05:21:28 -04:00
|
|
|
$remoteUserPrincipals = new Collection($remoteUserPrincipalBackend, RemoteUserPrincipalBackend::PRINCIPAL_PREFIX);
|
2025-02-03 09:34:01 -05:00
|
|
|
$calendarSharingBackend = Server::get(Backend::class);
|
2018-05-28 14:12:13 -04:00
|
|
|
|
2016-01-08 06:11:02 -05:00
|
|
|
$filesCollection = new Files\RootCollection($userPrincipalBackend, 'principals/users');
|
2015-10-26 12:56:33 -04:00
|
|
|
$filesCollection->disableListing = $disableListing;
|
2021-03-12 05:20:04 -05:00
|
|
|
$caldavBackend = new CalDavBackend(
|
|
|
|
|
$db,
|
|
|
|
|
$userPrincipalBackend,
|
|
|
|
|
$userManager,
|
|
|
|
|
$random,
|
|
|
|
|
$logger,
|
|
|
|
|
$dispatcher,
|
2024-01-30 12:35:44 -05:00
|
|
|
$config,
|
|
|
|
|
$calendarSharingBackend,
|
2025-05-14 05:21:28 -04:00
|
|
|
Server::get(FederatedCalendarMapper::class),
|
2025-08-15 07:54:56 -04:00
|
|
|
Server::get(ICacheFactory::class),
|
2024-01-30 12:35:44 -05:00
|
|
|
false,
|
2021-03-12 05:20:04 -05:00
|
|
|
);
|
2025-05-14 05:21:28 -04:00
|
|
|
$userCalendarRoot = new CalendarRoot($userPrincipalBackend, $caldavBackend, 'principals/users', $logger, $l10n, $config, $federatedCalendarFactory);
|
2018-05-28 14:12:13 -04:00
|
|
|
$userCalendarRoot->disableListing = $disableListing;
|
|
|
|
|
|
2025-05-14 05:21:28 -04:00
|
|
|
$remoteUserCalendarRoot = new CalendarRoot($remoteUserPrincipalBackend, $caldavBackend, RemoteUserPrincipalBackend::PRINCIPAL_PREFIX, $logger, $l10n, $config, $federatedCalendarFactory);
|
|
|
|
|
$remoteUserCalendarRoot->disableListing = $disableListing;
|
|
|
|
|
|
|
|
|
|
$resourceCalendarRoot = new CalendarRoot($calendarResourcePrincipalBackend, $caldavBackend, 'principals/calendar-resources', $logger, $l10n, $config, $federatedCalendarFactory);
|
2018-05-28 14:12:13 -04:00
|
|
|
$resourceCalendarRoot->disableListing = $disableListing;
|
2025-05-14 05:21:28 -04:00
|
|
|
$roomCalendarRoot = new CalendarRoot($calendarRoomPrincipalBackend, $caldavBackend, 'principals/calendar-rooms', $logger, $l10n, $config, $federatedCalendarFactory);
|
2018-05-28 14:12:13 -04:00
|
|
|
$roomCalendarRoot->disableListing = $disableListing;
|
|
|
|
|
|
2022-03-31 09:34:57 -04:00
|
|
|
$publicCalendarRoot = new PublicCalendarRoot($caldavBackend, $l10n, $config, $logger);
|
2016-01-21 08:09:15 -05:00
|
|
|
|
2024-10-18 02:40:59 -04:00
|
|
|
$systemTagCollection = Server::get(SystemTagsByIdCollection::class);
|
2024-10-10 06:40:31 -04:00
|
|
|
$systemTagRelationsCollection = new SystemTagsRelationsCollection(
|
2025-02-03 09:34:01 -05:00
|
|
|
Server::get(ISystemTagManager::class),
|
|
|
|
|
Server::get(ISystemTagObjectMapper::class),
|
|
|
|
|
Server::get(IUserSession::class),
|
2017-10-05 06:32:46 -04:00
|
|
|
$groupManager,
|
2024-02-09 03:54:52 -05:00
|
|
|
$dispatcher,
|
|
|
|
|
$rootFolder,
|
2015-11-27 06:54:31 -05:00
|
|
|
);
|
2024-10-10 06:40:31 -04:00
|
|
|
$systemTagInUseCollection = Server::get(SystemTagsInUseCollection::class);
|
2016-01-11 12:09:00 -05:00
|
|
|
$commentsCollection = new Comments\RootCollection(
|
2025-02-03 09:34:01 -05:00
|
|
|
Server::get(ICommentsManager::class),
|
2017-10-05 06:32:46 -04:00
|
|
|
$userManager,
|
2025-02-03 09:34:01 -05:00
|
|
|
Server::get(IUserSession::class),
|
2023-07-11 05:06:29 -04:00
|
|
|
$dispatcher,
|
2022-03-31 09:34:57 -04:00
|
|
|
$logger
|
2016-01-11 12:09:00 -05:00
|
|
|
);
|
2015-11-05 10:46:37 -05:00
|
|
|
|
2025-02-03 09:34:01 -05:00
|
|
|
$contactsSharingBackend = Server::get(\OCA\DAV\CardDAV\Sharing\Backend::class);
|
2025-01-08 08:39:18 -05:00
|
|
|
$config = Server::get(IConfig::class);
|
2024-01-30 12:35:44 -05:00
|
|
|
|
2025-02-03 09:34:01 -05:00
|
|
|
$pluginManager = new PluginManager(\OC::$server, Server::get(IAppManager::class));
|
2024-01-30 12:35:44 -05:00
|
|
|
$usersCardDavBackend = new CardDavBackend(
|
|
|
|
|
$db,
|
|
|
|
|
$userPrincipalBackend,
|
|
|
|
|
$userManager,
|
|
|
|
|
$dispatcher,
|
|
|
|
|
$contactsSharingBackend,
|
2025-01-08 08:39:18 -05:00
|
|
|
$config
|
2024-01-30 12:35:44 -05:00
|
|
|
);
|
2023-05-11 12:59:30 -04:00
|
|
|
$usersAddressBookRoot = new AddressBookRoot($userPrincipalBackend, $usersCardDavBackend, $pluginManager, $userSession->getUser(), $groupManager, 'principals/users');
|
2015-11-27 07:14:55 -05:00
|
|
|
$usersAddressBookRoot->disableListing = $disableListing;
|
2015-11-05 10:46:37 -05:00
|
|
|
|
2024-01-30 12:35:44 -05:00
|
|
|
$systemCardDavBackend = new CardDavBackend(
|
|
|
|
|
$db,
|
|
|
|
|
$userPrincipalBackend,
|
|
|
|
|
$userManager,
|
|
|
|
|
$dispatcher,
|
|
|
|
|
$contactsSharingBackend,
|
2025-01-08 08:39:18 -05:00
|
|
|
$config
|
2024-01-30 12:35:44 -05:00
|
|
|
);
|
2023-05-11 12:59:30 -04:00
|
|
|
$systemAddressBookRoot = new AddressBookRoot(new SystemPrincipalBackend(), $systemCardDavBackend, $pluginManager, $userSession->getUser(), $groupManager, 'principals/system');
|
2015-11-27 07:14:55 -05:00
|
|
|
$systemAddressBookRoot->disableListing = $disableListing;
|
2015-10-21 09:06:48 -04:00
|
|
|
|
2018-11-02 16:19:27 -04:00
|
|
|
$uploadCollection = new Upload\RootCollection(
|
|
|
|
|
$userPrincipalBackend,
|
|
|
|
|
'principals/users',
|
2025-02-24 13:22:52 -05:00
|
|
|
Server::get(CleanupService::class),
|
|
|
|
|
$rootFolder,
|
|
|
|
|
$userSession,
|
2025-04-14 09:45:50 -04:00
|
|
|
$shareManager,
|
2025-02-24 13:22:52 -05:00
|
|
|
);
|
2015-10-28 09:52:45 -04:00
|
|
|
$uploadCollection->disableListing = $disableListing;
|
|
|
|
|
|
2016-12-23 06:12:38 -05:00
|
|
|
$avatarCollection = new Avatars\RootCollection($userPrincipalBackend, 'principals/users');
|
|
|
|
|
$avatarCollection->disableListing = $disableListing;
|
|
|
|
|
|
2017-10-19 06:57:20 -04:00
|
|
|
$appleProvisioning = new AppleProvisioningNode(
|
2025-02-03 09:34:01 -05:00
|
|
|
Server::get(ITimeFactory::class));
|
2017-10-19 06:57:20 -04:00
|
|
|
|
2015-10-21 09:06:48 -04:00
|
|
|
$children = [
|
2020-04-09 03:22:29 -04:00
|
|
|
new SimpleCollection('principals', [
|
|
|
|
|
$userPrincipals,
|
|
|
|
|
$groupPrincipals,
|
|
|
|
|
$systemPrincipals,
|
|
|
|
|
$calendarResourcePrincipals,
|
2025-05-14 05:21:28 -04:00
|
|
|
$calendarRoomPrincipals,
|
|
|
|
|
$remoteUserPrincipals]),
|
2020-04-09 03:22:29 -04:00
|
|
|
$filesCollection,
|
|
|
|
|
$userCalendarRoot,
|
2025-05-14 05:21:28 -04:00
|
|
|
$remoteUserCalendarRoot,
|
2020-04-09 03:22:29 -04:00
|
|
|
new SimpleCollection('system-calendars', [
|
|
|
|
|
$resourceCalendarRoot,
|
|
|
|
|
$roomCalendarRoot,
|
|
|
|
|
]),
|
|
|
|
|
$publicCalendarRoot,
|
|
|
|
|
new SimpleCollection('addressbooks', [
|
|
|
|
|
$usersAddressBookRoot,
|
|
|
|
|
$systemAddressBookRoot]),
|
|
|
|
|
$systemTagCollection,
|
|
|
|
|
$systemTagRelationsCollection,
|
2023-04-27 16:24:16 -04:00
|
|
|
$systemTagInUseCollection,
|
2020-04-09 03:22:29 -04:00
|
|
|
$commentsCollection,
|
|
|
|
|
$uploadCollection,
|
|
|
|
|
$avatarCollection,
|
|
|
|
|
new SimpleCollection('provisioning', [
|
|
|
|
|
$appleProvisioning
|
|
|
|
|
])
|
2015-10-21 09:06:48 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
parent::__construct('root', $children);
|
|
|
|
|
}
|
|
|
|
|
}
|