|
|
|
|
@ -42,14 +42,26 @@ class ContactsManager implements IManager { |
|
|
|
|
* - '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 |
|
|
|
|
* - 'wildcard' - Whether the search should use wildcards |
|
|
|
|
* - 'enumeration' - Whether user enumeration on system address book is allowed |
|
|
|
|
* - 'fullmatch' - Whether matching on full detail in system address book is allowed |
|
|
|
|
* @return array an array of contacts which are arrays of key-value-pairs |
|
|
|
|
*/ |
|
|
|
|
public function search($pattern, $searchProperties = [], $options = []) { |
|
|
|
|
$this->loadAddressBooks(); |
|
|
|
|
$result = []; |
|
|
|
|
foreach ($this->addressBooks as $addressBook) { |
|
|
|
|
$r = $addressBook->search($pattern, $searchProperties, $options); |
|
|
|
|
$searchOptions = $options; |
|
|
|
|
|
|
|
|
|
if ($addressBook->isSystemAddressBook()) { |
|
|
|
|
$fullMatch = !\array_key_exists('fullmatch', $options) || $options['fullmatch'] !== false; |
|
|
|
|
if (!$fullMatch) { |
|
|
|
|
// Neither full match is allowed, so skip the system address book |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
$searchOptions['wildcard'] = !\array_key_exists('enumeration', $options) || $options['enumeration'] !== false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$r = $addressBook->search($pattern, $searchProperties, $searchOptions); |
|
|
|
|
$contacts = []; |
|
|
|
|
foreach ($r as $c) { |
|
|
|
|
$c['addressbook-key'] = $addressBook->getKey(); |
|
|
|
|
|