Browse Source
Merge pull request #18816 from nextcloud/bugfix/noid/paginate-contacts-search
Use paginated search for contacts
pull/20629/head
blizzz
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with
16 additions and
4 deletions
-
apps/dav/lib/CardDAV/AddressBookImpl.php
-
apps/dav/lib/CardDAV/CardDavBackend.php
-
lib/private/Collaboration/Collaborators/MailPlugin.php
-
lib/private/Collaboration/Collaborators/RemotePlugin.php
-
lib/private/ContactsManager.php
-
lib/public/Contacts/IManager.php
-
lib/public/IAddressBook.php
|
|
|
@ -105,6 +105,8 @@ class AddressBookImpl implements IAddressBook { |
|
|
|
* - 'types' boolean (since 15.0.0) If set to true, fields that come with a TYPE property will be an array |
|
|
|
* example: ['id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => ['type => 'HOME', 'value' => 'g@h.i']] |
|
|
|
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped |
|
|
|
* - 'limit' - Set a numeric limit for the search results |
|
|
|
* - 'offset' - Set the offset for the limited search results |
|
|
|
* @return array an array of contacts which are arrays of key-value-pairs |
|
|
|
* example result: |
|
|
|
* [ |
|
|
|
|
|
|
|
@ -965,6 +965,12 @@ class CardDavBackend implements BackendInterface, SyncSupport { |
|
|
|
$query2->andWhere($query2->expr()->ilike('cp.value', $query->createNamedParameter('%' . $this->db->escapeLikeParameter($pattern) . '%'))); |
|
|
|
} |
|
|
|
} |
|
|
|
if (isset($options['limit'])) { |
|
|
|
$query2->setMaxResults($options['limit']); |
|
|
|
} |
|
|
|
if (isset($options['offset'])) { |
|
|
|
$query2->setFirstResult($options['offset']); |
|
|
|
} |
|
|
|
|
|
|
|
$query->select('c.carddata', 'c.uri')->from($this->dbCardsTable, 'c') |
|
|
|
->where($query->expr()->in('c.id', $query->createFunction($query2->getSQL()))); |
|
|
|
|
|
|
|
@ -81,8 +81,7 @@ class MailPlugin implements ISearchPlugin { |
|
|
|
$emailType = new SearchResultType('emails'); |
|
|
|
|
|
|
|
// Search in contacts
|
|
|
|
//@todo Pagination missing
|
|
|
|
$addressBookContacts = $this->contactsManager->search($search, ['EMAIL', 'FN']); |
|
|
|
$addressBookContacts = $this->contactsManager->search($search, ['EMAIL', 'FN'], ['limit' => $limit, 'offset' => $offset]); |
|
|
|
$lowerSearch = strtolower($search); |
|
|
|
foreach ($addressBookContacts as $contact) { |
|
|
|
if (isset($contact['EMAIL'])) { |
|
|
|
|
|
|
|
@ -67,8 +67,7 @@ class RemotePlugin implements ISearchPlugin { |
|
|
|
$resultType = new SearchResultType('remotes'); |
|
|
|
|
|
|
|
// Search in contacts
|
|
|
|
//@todo Pagination missing
|
|
|
|
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN']); |
|
|
|
$addressBookContacts = $this->contactsManager->search($search, ['CLOUD', 'FN'], ['limit' => $limit, 'offset' => $offset]); |
|
|
|
foreach ($addressBookContacts as $contact) { |
|
|
|
if (isset($contact['isLocalSystemBook'])) { |
|
|
|
continue; |
|
|
|
|
|
|
|
@ -40,6 +40,8 @@ namespace OC { |
|
|
|
* @param array $searchProperties defines the properties within the query pattern should match |
|
|
|
* @param array $options = array() to define the search behavior |
|
|
|
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped |
|
|
|
* - 'limit' - Set a numeric limit for the search results |
|
|
|
* - 'offset' - Set the offset for the limited search results |
|
|
|
* @return array an array of contacts which are arrays of key-value-pairs |
|
|
|
*/ |
|
|
|
public function search($pattern, $searchProperties = [], $options = []) { |
|
|
|
|
|
|
|
@ -96,6 +96,8 @@ interface IManager { |
|
|
|
* @param array $searchProperties defines the properties within the query pattern should match |
|
|
|
* @param array $options = array() to define the search behavior |
|
|
|
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped |
|
|
|
* - 'limit' - Set a numeric limit for the search results |
|
|
|
* - 'offset' - Set the offset for the limited search results |
|
|
|
* @return array an array of contacts which are arrays of key-value-pairs |
|
|
|
* @since 6.0.0 |
|
|
|
*/ |
|
|
|
|
|
|
|
@ -71,6 +71,8 @@ namespace OCP { |
|
|
|
* - 'types' boolean (since 15.0.0) If set to true, fields that come with a TYPE property will be an array |
|
|
|
* example: ['id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => ['type => 'HOME', 'value' => 'g@h.i']] |
|
|
|
* - 'escape_like_param' - If set to false wildcards _ and % are not escaped |
|
|
|
* - 'limit' - Set a numeric limit for the search results |
|
|
|
* - 'offset' - Set the offset for the limited search results |
|
|
|
* @return array an array of contacts which are arrays of key-value-pairs |
|
|
|
* example result: |
|
|
|
* [ |
|
|
|
|