Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2020-12-28 13:06:12 +0300
committerdartcafe <github@dartcafe.de>2020-12-28 13:06:12 +0300
commitce80a7711d7a0699047695ae874f3b1695f3e0a6 (patch)
tree68e4f4b99af724492bdb78ed40b3eddb24559ce7 /lib/Model/Contact.php
parent0352c2ec0b95c7636e22b6cc50a507505842d22e (diff)
some afterwork
Diffstat (limited to 'lib/Model/Contact.php')
-rw-r--r--lib/Model/Contact.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/Model/Contact.php b/lib/Model/Contact.php
index f121e00e..031cf541 100644
--- a/lib/Model/Contact.php
+++ b/lib/Model/Contact.php
@@ -23,6 +23,8 @@
namespace OCA\Polls\Model;
+use OCP\App\IAppManager;
+use OCP\Contacts\IManager as IContactsManager;
use OCA\Polls\Exceptions\MultipleContactsFound;
use OCA\Polls\Exceptions\ContactsNotEnabledExceptions;
@@ -51,10 +53,6 @@ class Contact extends UserGroupClass {
return $this->displayName;
}
- public static function isEnabled(): bool {
- return \OC::$server->getAppManager()->isEnabledForUser('contacts');
- }
-
/**
* We just need the contact's UID, so make sure, the any prefix is removed
*/
@@ -117,16 +115,21 @@ class Contact extends UserGroupClass {
}
}
+ public static function isEnabled(): bool {
+ return self::getContainer()->query(IAppManager::class)->isEnabledForUser('contacts');
+ }
+
/**
* * List all contacts with email adresses
* * excluding contacts from localSystemBook
*
* @param string[] $queryRange
*/
- public static function listRaw(string $query = '', array $queryRange = ['FN', 'EMAIL', 'ORG', 'CATEGORIES']): array {
+ private static function listRaw(string $query = '', array $queryRange = ['FN', 'EMAIL', 'ORG', 'CATEGORIES']): array {
$contacts = [];
- if (\OC::$server->getAppManager()->isEnabledForUser('contacts')) {
- foreach (\OC::$server->getContactsManager()->search($query, $queryRange) as $contact) {
+
+ if (self::isEnabled()) {
+ foreach (self::getContainer()->query(IContactsManager::class)->search($query, $queryRange) as $contact) {
if (!array_key_exists('isLocalSystemBook', $contact) && array_key_exists('EMAIL', $contact)) {
$contacts[] = $contact;
}