summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-04-26 18:31:17 +0200
committerGitHub <noreply@github.com>2017-04-26 18:31:17 +0200
commitd89c76049fbc7061bfa45e87c46f08802242d5f2 (patch)
tree0aa8bdbad51349e6e6081fd3fe24945950433e03 /lib
parentedd9444209ec8f0737821870fa9a25b7fe5dc0e6 (diff)
parent6bbc682c4b24212d36ef595d3692653dca1c67b1 (diff)
downloadnextcloud-server-d89c76049fbc7061bfa45e87c46f08802242d5f2.tar.gz
nextcloud-server-d89c76049fbc7061bfa45e87c46f08802242d5f2.zip
Merge pull request #4374 from nextcloud/contactsmenu_popover
add contacts popover
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Contacts/ContactsMenu/ContactsStore.php44
-rw-r--r--lib/private/Contacts/ContactsMenu/Manager.php17
2 files changed, 60 insertions, 1 deletions
diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php
index 1cdb5d6fc5f..40a0bf87031 100644
--- a/lib/private/Contacts/ContactsMenu/ContactsStore.php
+++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php
@@ -60,6 +60,50 @@ class ContactsStore {
}
/**
+ * @param IUser $user
+ * @param integer $shareType
+ * @param string $shareWith
+ * @return IEntry|null
+ */
+ public function findOne(IUser $user, $shareType, $shareWith) {
+ switch($shareType) {
+ case 0:
+ case 6:
+ $filter = ['UID'];
+ break;
+ case 4:
+ $filter = ['EMAIL'];
+ break;
+ default:
+ return null;
+ }
+
+ $userId = $user->getUID();
+ $allContacts = $this->contactsManager->search($shareWith, $filter);
+ $contacts = array_filter($allContacts, function($contact) use ($userId) {
+ return $contact['UID'] !== $userId;
+ });
+ $match = null;
+
+ foreach ($contacts as $contact) {
+ if ($shareType === 4 && isset($contact['EMAIL'])) {
+ if (in_array($shareWith, $contact['EMAIL'])) {
+ $match = $contact;
+ break;
+ }
+ }
+ if ($shareType === 0 || $shareType === 6) {
+ if ($contact['UID'] === $shareWith && $contact['isLocalSystemBook'] === true) {
+ $match = $contact;
+ break;
+ }
+ }
+ }
+
+ return $match ? $this->contactArrayToEntry($match) : null;
+ }
+
+ /**
* @param array $contact
* @return Entry
*/
diff --git a/lib/private/Contacts/ContactsMenu/Manager.php b/lib/private/Contacts/ContactsMenu/Manager.php
index 16d77c2df08..766b4623253 100644
--- a/lib/private/Contacts/ContactsMenu/Manager.php
+++ b/lib/private/Contacts/ContactsMenu/Manager.php
@@ -51,7 +51,7 @@ class Manager {
}
/**
- * @param string $user
+ * @param IUser $user
* @param string $filter
* @return array
*/
@@ -70,6 +70,21 @@ class Manager {
}
/**
+ * @param IUser $user
+ * @param integer $shareType
+ * @param string $shareWith
+ * @return IEntry
+ */
+ public function findOne(IUser $user, $shareType, $shareWith) {
+ $entry = $this->store->findOne($user, $shareType, $shareWith);
+ if ($entry) {
+ $this->processEntries([$entry], $user);
+ }
+
+ return $entry;
+ }
+
+ /**
* @param IEntry[] $entries
* @return IEntry[]
*/