mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Merge pull request #6637 from nextcloud/contactsstore_public_api
Make ContactsStore a public API
This commit is contained in:
commit
179be8d95c
8 changed files with 67 additions and 1 deletions
|
|
@ -53,6 +53,8 @@ $cm->register(function() use ($cm, $app) {
|
|||
$user = \OC::$server->getUserSession()->getUser();
|
||||
if (!is_null($user)) {
|
||||
$app->setupContactsProvider($cm, $user->getUID());
|
||||
} else {
|
||||
$app->setupSystemContactsProvider($cm);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,16 @@ class Application extends App {
|
|||
$cm->setupContactsProvider($contactsManager, $userID, $urlGenerator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IManager $contactsManager
|
||||
*/
|
||||
public function setupSystemContactsProvider(IContactsManager $contactsManager) {
|
||||
/** @var ContactsManager $cm */
|
||||
$cm = $this->getContainer()->query(ContactsManager::class);
|
||||
$urlGenerator = $this->getContainer()->getServer()->getURLGenerator();
|
||||
$cm->setupSystemContactsProvider($contactsManager, $urlGenerator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ICalendarManager $calendarManager
|
||||
* @param string $userId
|
||||
|
|
|
|||
|
|
@ -55,6 +55,14 @@ class ContactsManager {
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ return array(
|
|||
'OCP\\Contacts' => $baseDir . '/lib/public/Contacts.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IAction' => $baseDir . '/lib/public/Contacts/ContactsMenu/IAction.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IActionFactory' => $baseDir . '/lib/public/Contacts/ContactsMenu/IActionFactory.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IContactsStore' => $baseDir . '/lib/public/Contacts/ContactsMenu/IContactsStore.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IEntry' => $baseDir . '/lib/public/Contacts/ContactsMenu/IEntry.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\ILinkAction' => $baseDir . '/lib/public/Contacts/ContactsMenu/ILinkAction.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IProvider' => $baseDir . '/lib/public/Contacts/ContactsMenu/IProvider.php',
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OCP\\Contacts' => __DIR__ . '/../../..' . '/lib/public/Contacts.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IAction' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IAction.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IActionFactory' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IActionFactory.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IContactsStore' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IContactsStore.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IEntry' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IEntry.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\ILinkAction' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/ILinkAction.php',
|
||||
'OCP\\Contacts\\ContactsMenu\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IProvider.php',
|
||||
|
|
|
|||
|
|
@ -35,8 +35,9 @@ use OCP\IGroupManager;
|
|||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Contacts\ContactsMenu\IContactsStore;
|
||||
|
||||
class ContactsStore {
|
||||
class ContactsStore implements IContactsStore {
|
||||
|
||||
/** @var IManager */
|
||||
private $contactsManager;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ use OC\Collaboration\Collaborators\RemotePlugin;
|
|||
use OC\Collaboration\Collaborators\UserPlugin;
|
||||
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;
|
||||
|
|
@ -114,6 +115,7 @@ use OCA\Theming\ThemingDefaults;
|
|||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Collaboration\AutoComplete\IManager;
|
||||
use OCP\Contacts\ContactsMenu\IContactsStore;
|
||||
use OCP\Defaults;
|
||||
use OCA\Theming\Util;
|
||||
use OCP\Federation\ICloudIdManager;
|
||||
|
|
@ -1129,6 +1131,16 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
|
||||
});
|
||||
|
||||
$this->registerService(IContactsStore::class, function(Server $c) {
|
||||
return new ContactsStore(
|
||||
$c->getContactsManager(),
|
||||
$c->getConfig(),
|
||||
$c->getUserManager(),
|
||||
$c->getGroupManager()
|
||||
);
|
||||
});
|
||||
$this->registerAlias(IContactsStore::class, ContactsStore::class);
|
||||
|
||||
$this->connectDispatcher();
|
||||
}
|
||||
|
||||
|
|
|
|||
31
lib/public/Contacts/ContactsMenu/IContactsStore.php
Normal file
31
lib/public/Contacts/ContactsMenu/IContactsStore.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace OCP\Contacts\ContactsMenu;
|
||||
|
||||
use OCP\IUser;
|
||||
|
||||
/**
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface IContactsStore {
|
||||
|
||||
|
||||
/**
|
||||
* @param IUser $user
|
||||
* @param $filter
|
||||
* @return IEntry[]
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getContacts(IUser $user, $filter);
|
||||
|
||||
/**
|
||||
* @brief finds a contact by specifying the property to search on ($shareType) and the value ($shareWith)
|
||||
* @param IUser $user
|
||||
* @param integer $shareType
|
||||
* @param string $shareWith
|
||||
* @return IEntry|null
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function findOne(IUser $user, $shareType, $shareWith);
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue