diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2017-04-10 16:49:26 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2017-04-25 20:47:17 +0200 |
commit | b8c2a8ae36235780675103286a04f8b6af50b4aa (patch) | |
tree | c75dd2baa0fdaabaf2a2c7aec40781ce3177509a /lib/private/Contacts/ContactsMenu | |
parent | 36cee1f3867bdaf9fd792fe9c03fe4e4ef95ffcc (diff) | |
download | nextcloud-server-b8c2a8ae36235780675103286a04f8b6af50b4aa.tar.gz nextcloud-server-b8c2a8ae36235780675103286a04f8b6af50b4aa.zip |
Don't show contacts an entry for themselves
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Contacts/ContactsMenu')
-rw-r--r-- | lib/private/Contacts/ContactsMenu/ContactsStore.php | 10 | ||||
-rw-r--r-- | lib/private/Contacts/ContactsMenu/Manager.php | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index fba970e93fa..1cdb5d6fc5f 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -26,6 +26,7 @@ namespace OC\Contacts\ContactsMenu; use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\IManager; +use OCP\IUser; class ContactsStore { @@ -40,17 +41,22 @@ class ContactsStore { } /** + * @param IUser $user * @param string|null $filter * @return IEntry[] */ - public function getContacts($filter) { + public function getContacts(IUser $user, $filter) { $allContacts = $this->contactsManager->search($filter ?: '', [ 'FN', ]); - return array_map(function(array $contact) { + $self = $user->getUID(); + $entries = array_map(function(array $contact) { return $this->contactArrayToEntry($contact); }, $allContacts); + return array_filter($entries, function(IEntry $entry) use ($self) { + return $entry->getProperty('UID') !== $self; + }); } /** diff --git a/lib/private/Contacts/ContactsMenu/Manager.php b/lib/private/Contacts/ContactsMenu/Manager.php index 40ceac7d783..16d77c2df08 100644 --- a/lib/private/Contacts/ContactsMenu/Manager.php +++ b/lib/private/Contacts/ContactsMenu/Manager.php @@ -26,7 +26,6 @@ namespace OC\Contacts\ContactsMenu; use OCP\App\IAppManager; use OCP\Contacts\ContactsMenu\IEntry; -use OCP\IURLGenerator; use OCP\IUser; class Manager { @@ -57,7 +56,7 @@ class Manager { * @return array */ public function getEntries(IUser $user, $filter) { - $entries = $this->store->getContacts($filter); + $entries = $this->store->getContacts($user, $filter); $sortedEntries = $this->sortEntries($entries); $topEntries = array_slice($sortedEntries, 0, 25); |