Make ContactsStore a public API
Signed-off-by: Tobia De Koninck <tobia@ledfan.be>
This commit is contained in:
parent
45971879f5
commit
f6ef779f97
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -1129,6 +1130,15 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
|
||||
});
|
||||
|
||||
$this->registerService(\OCP\Contacts\ContactsMenu\IContactsStore::class, function(Server $c) {
|
||||
return new ContactsStore(
|
||||
$c->getContactsManager(),
|
||||
$c->getConfig(),
|
||||
$c->getUserManager(),
|
||||
$c->getGroupManager()
|
||||
);
|
||||
});
|
||||
|
||||
$this->connectDispatcher();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace OCP\Contacts\ContactsMenu;
|
||||
|
||||
use OCP\IUser;
|
||||
|
||||
interface IContactsStore {
|
||||
|
||||
|
||||
/**
|
||||
* @param IUser $user
|
||||
* @param $filter
|
||||
* @return IEntry[]
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public function findOne(IUser $user, $shareType, $shareWith);
|
||||
|
||||
}
|
Loading…
Reference in New Issue