Browse Source

Use paginated search for contacts

Signed-off-by: Julius Härtl <jus@bitgrid.net>
tags/v19.0.0beta6
Julius Härtl 4 years ago
parent
commit
6709833dc7
No account linked to committer's email address

+ 2
- 0
apps/dav/lib/CardDAV/AddressBookImpl.php View File

@@ -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:
* [

+ 6
- 0
apps/dav/lib/CardDAV/CardDavBackend.php View File

@@ -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())));

+ 1
- 2
lib/private/Collaboration/Collaborators/MailPlugin.php View File

@@ -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'])) {

+ 1
- 2
lib/private/Collaboration/Collaborators/RemotePlugin.php View File

@@ -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;

+ 2
- 0
lib/private/ContactsManager.php View File

@@ -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 = []) {

+ 2
- 0
lib/public/Contacts/IManager.php View File

@@ -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
*/

+ 2
- 0
lib/public/IAddressBook.php View File

@@ -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:
* [

Loading…
Cancel
Save