diff --git a/apps/dav/l10n/is.json b/apps/dav/l10n/is.json index 4382e1581a960..78596f54977c2 100644 --- a/apps/dav/l10n/is.json +++ b/apps/dav/l10n/is.json @@ -80,4 +80,4 @@ "CalDAV server" : "CalDAV-þjónn", "Please make sure to properly set up the email settings above." : "Gakktu úr skugga um að tölvupóststillingarnar hér fyrir ofan séu réttar." },"pluralForm" :"nplurals=2; plural=(n % 10 != 1 || n % 100 == 11);" -} \ No newline at end of file +} diff --git a/apps/dav/l10n/it.js b/apps/dav/l10n/it.js index 364dcacf859c7..f90970f94f1ea 100644 --- a/apps/dav/l10n/it.js +++ b/apps/dav/l10n/it.js @@ -89,3 +89,4 @@ OC.L10N.register( "Please make sure to properly set up the email settings above." : "Assicurati di configurare correttamente le impostazioni di posta sopra." }, "nplurals=2; plural=(n != 1);"); + diff --git a/apps/dav/l10n/it.json b/apps/dav/l10n/it.json index ad1f6eb61111c..bc01a4a388c75 100644 --- a/apps/dav/l10n/it.json +++ b/apps/dav/l10n/it.json @@ -86,4 +86,4 @@ "CalDAV server" : "Server CalDAV", "Please make sure to properly set up the email settings above." : "Assicurati di configurare correttamente le impostazioni di posta sopra." },"pluralForm" :"nplurals=2; plural=(n != 1);" -} \ No newline at end of file +} diff --git a/apps/dav/l10n/pl.js b/apps/dav/l10n/pl.js index cbe0cdc40a908..0005a9cb417c5 100644 --- a/apps/dav/l10n/pl.js +++ b/apps/dav/l10n/pl.js @@ -88,4 +88,4 @@ OC.L10N.register( "CalDAV server" : "Serwer CalDAV", "Please make sure to properly set up the email settings above." : "Upewnij się, że dobrze skonfigurowano powyżej ustawienia poczty e-mail." }, -"nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);"); +"nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);"); \ No newline at end of file diff --git a/apps/dav/l10n/pl.json b/apps/dav/l10n/pl.json index 797c04f7bf87e..09038a665453a 100644 --- a/apps/dav/l10n/pl.json +++ b/apps/dav/l10n/pl.json @@ -86,4 +86,4 @@ "CalDAV server" : "Serwer CalDAV", "Please make sure to properly set up the email settings above." : "Upewnij się, że dobrze skonfigurowano powyżej ustawienia poczty e-mail." },"pluralForm" :"nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && (n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);" -} \ No newline at end of file +} diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index 05ef9cca53a9c..46608ebf9af65 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -27,16 +27,21 @@ namespace OC\Contacts\ContactsMenu; +use OC\DB\QueryBuilder\QueryBuilder; use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\IManager; use OCP\IConfig; use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; +use OCP\IDBConnection; use OCP\Contacts\ContactsMenu\IContactsStore; class ContactsStore implements IContactsStore { + /** @var \OCP\IDBConnection */ + private $conn; + /** @var IManager */ private $contactsManager; @@ -54,15 +59,18 @@ class ContactsStore implements IContactsStore { * @param IConfig $config * @param IUserManager $userManager * @param IGroupManager $groupManager + * @param IDBConnection $connection */ public function __construct(IManager $contactsManager, IConfig $config, IUserManager $userManager, - IGroupManager $groupManager) { + IGroupManager $groupManager, + IDBConnection $connection) { $this->contactsManager = $contactsManager; $this->config = $config; $this->userManager = $userManager; $this->groupManager = $groupManager; + $this->conn = $connection; } /** @@ -76,9 +84,47 @@ public function getContacts(IUser $user, $filter) { 'EMAIL' ]); - $entries = array_map(function(array $contact) { + // If search input text is not empty, search in database + if ($filter !== null) { + $entries = array_map(function (array $contact) { + return $this->contactArrayToEntry($contact); + }, $allContacts); + + + return $this->filterContacts( + $user, + $entries, + $filter + ); + + } + + // If search input text is empty, get shared users + $sharedContacts = []; + $queryBuilder = $this->conn->getQueryBuilder(); + + // Getting shared users and limit to 25 entries + $sharedContactsQuery = $queryBuilder->setMaxResults(25) + ->selectDistinct("share_with") + ->from("*PREFIX*share") + ->execute() + ->fetchAll(); + + + // Matching who shared with + for ($i = 0; $i < count($sharedContactsQuery); $i++) { + for ($j = 0; $j < count($allContacts); $j++) { + if ($sharedContactsQuery[$i]['share_with'] == $allContacts[$j]['UID']) { + $sharedContacts[] = $allContacts[$j]; + break; + } + } + } + + $entries = array_map(function (array $contact) { return $this->contactArrayToEntry($contact); - }, $allContacts); + }, $sharedContacts); + return $this->filterContacts( $user, $entries, @@ -259,5 +305,4 @@ private function contactArrayToEntry(array $contact) { return $entry; } - -} +} \ No newline at end of file