summaryrefslogtreecommitdiffstats
path: root/lib/private/ContactsManager.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-12-08 18:53:54 +0100
committerJoas Schilling <coding@schilljs.com>2021-12-08 19:24:16 +0100
commitd5cb5a33dc5d09e7cef3b88e3f55240ef3384df2 (patch)
tree11070b1768827b120bd1365b4f917a8bf5c8acf2 /lib/private/ContactsManager.php
parentd49ad7ea47e35a463e4953c9922a5af77ff7acf2 (diff)
downloadnextcloud-server-d5cb5a33dc5d09e7cef3b88e3f55240ef3384df2.tar.gz
nextcloud-server-d5cb5a33dc5d09e7cef3b88e3f55240ef3384df2.zip
Convert strict_search to wildcard property and add psalm docs
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/ContactsManager.php')
-rw-r--r--lib/private/ContactsManager.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/private/ContactsManager.php b/lib/private/ContactsManager.php
index 557cf98c66b..937fb94a09a 100644
--- a/lib/private/ContactsManager.php
+++ b/lib/private/ContactsManager.php
@@ -42,8 +42,10 @@ 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
- * - 'enumeration' - Whether user enumeration on system address book is allowed
- * - 'fullmatch' - Whether matching on full detail in system address book is allowed
+ * - 'enumeration' - (since 23.0.0) Whether user enumeration on system address book is allowed
+ * - 'fullmatch' - (since 23.0.0) Whether matching on full detail in system address book is allowed
+ * - 'strict_search' - (since 23.0.0) Whether the search pattern is full string or partial search
+ * @psalm-param array{escape_like_param?: bool, limit?: int, offset?: int, enumeration?: bool, fullmatch?: bool, strict_search?: bool} $options
* @return array an array of contacts which are arrays of key-value-pairs
*/
public function search($pattern, $searchProperties = [], $options = []) {
@@ -51,6 +53,7 @@ class ContactsManager implements IManager {
$result = [];
foreach ($this->addressBooks as $addressBook) {
$searchOptions = $options;
+ $strictSearch = array_key_exists('strict_search', $options) && $options['strict_search'] === true;
if ($addressBook->isSystemAddressBook()) {
$fullMatch = !\array_key_exists('fullmatch', $options) || $options['fullmatch'] !== false;
@@ -58,7 +61,13 @@ class ContactsManager implements IManager {
// Neither full match is allowed, so skip the system address book
continue;
}
- $searchOptions['wildcard'] = !\array_key_exists('enumeration', $options) || $options['enumeration'] !== false;
+ if ($strictSearch) {
+ $searchOptions['wildcard'] = false;
+ } else {
+ $searchOptions['wildcard'] = !\array_key_exists('enumeration', $options) || $options['enumeration'] !== false;
+ }
+ } else {
+ $searchOptions['wildcard'] = !$strictSearch;
}
$r = $addressBook->search($pattern, $searchProperties, $searchOptions);