diff --git a/apps/dav/appinfo/app.php b/apps/dav/appinfo/app.php index 0d417fd3fed2d..113a486543bfa 100644 --- a/apps/dav/appinfo/app.php +++ b/apps/dav/appinfo/app.php @@ -52,5 +52,7 @@ function(GenericEvent $event) use ($app) { $user = \OC::$server->getUserSession()->getUser(); if (!is_null($user)) { $app->setupContactsProvider($cm, $user->getUID()); + } else { + $app->setupSystemContactsProvider($cm); } }); diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php index 5d89324d4a9cf..90f1f5824e232 100644 --- a/apps/dav/lib/AppInfo/Application.php +++ b/apps/dav/lib/AppInfo/Application.php @@ -72,6 +72,16 @@ public function setupContactsProvider(IManager $contactsManager, $userID) { $cm->setupContactsProvider($contactsManager, $userID, $urlGenerator); } + /** + * @param IManager $contactsManager + */ + public function setupSystemContactsProvider(IManager $contactsManager) { + /** @var ContactsManager $cm */ + $cm = $this->getContainer()->query(ContactsManager::class); + $urlGenerator = $this->getContainer()->getServer()->getURLGenerator(); + $cm->setupSystemContactsProvider($contactsManager, $urlGenerator); + } + public function registerHooks() { /** @var HookManager $hm */ $hm = $this->getContainer()->query(HookManager::class); diff --git a/apps/dav/lib/CardDAV/ContactsManager.php b/apps/dav/lib/CardDAV/ContactsManager.php index b2e3544b287f3..4d6ca8c794c61 100644 --- a/apps/dav/lib/CardDAV/ContactsManager.php +++ b/apps/dav/lib/CardDAV/ContactsManager.php @@ -54,6 +54,14 @@ public function __construct(CardDavBackend $backend, IL10N $l10n) { public function setupContactsProvider(IManager $cm, $userId, IURLGenerator $urlGenerator) { $addressBooks = $this->backend->getAddressBooksForUser("principals/users/$userId"); $this->register($cm, $addressBooks, $urlGenerator); + $this->setupSystemContactsProvider($cm, $urlGenerator); + } + + /** + * @param IManager $cm + * @param IURLGenerator $urlGenerator + */ + public function setupSystemContactsProvider(IManager $cm, IURLGenerator $urlGenerator) { $addressBooks = $this->backend->getAddressBooksForUser("principals/system/system"); $this->register($cm, $addressBooks, $urlGenerator); } diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index 3eda58cacfb24..a31a9be5886ef 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -33,8 +33,9 @@ use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; +use OCP\Contacts\ContactsMenu\IContactsStore; -class ContactsStore { +class ContactsStore implements IContactsStore { /** @var IManager */ private $contactsManager; diff --git a/lib/private/Server.php b/lib/private/Server.php index a20d9ccfc0117..0b41267ad5a0f 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -54,6 +54,7 @@ use OC\Authentication\LoginCredentials\Store; use OC\Command\CronBus; use OC\Contacts\ContactsMenu\ActionFactory; +use OC\Contacts\ContactsMenu\ContactsStore; use OC\Diagnostics\EventLogger; use OC\Diagnostics\QueryLogger; use OC\Federation\CloudIdManager; @@ -1066,6 +1067,17 @@ public function __construct($webRoot, \OC\Config $config) { $c->query(\OCP\Share\IManager::class) ); }); + + $this->registerService(\OCP\Contacts\ContactsMenu\IContactsStore::class, function(Server $c) { + return new ContactsStore( + $this->getContactsManager(), + $this->getConfig(), + $this->getUserManager(), + $this->getGroupManager() + ); + }); + + } /** diff --git a/lib/public/Contacts/ContactsMenu/IContactsStore.php b/lib/public/Contacts/ContactsMenu/IContactsStore.php new file mode 100644 index 0000000000000..415c450072d01 --- /dev/null +++ b/lib/public/Contacts/ContactsMenu/IContactsStore.php @@ -0,0 +1,26 @@ +