summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2023-11-14 20:47:00 +0100
committerGitHub <noreply@github.com>2023-11-14 20:47:00 +0100
commit138ce5303ad09205e20e1d9781779f23f8d0838a (patch)
tree83511ba7dafe96f3a52c392a463370291c5523c6 /apps/dav/lib
parent5c041122e847c02c60cb6bca480038a2a50f3331 (diff)
parent26ee5a531bad3516ea34e235b804ee223972a4e1 (diff)
downloadnextcloud-server-138ce5303ad09205e20e1d9781779f23f8d0838a.tar.gz
nextcloud-server-138ce5303ad09205e20e1d9781779f23f8d0838a.zip
Merge pull request #41457 from nextcloud/feat/contacts/advanced-search
feat(search): allow contacts person search
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php4
-rw-r--r--apps/dav/lib/Search/ContactsSearchProvider.php10
2 files changed, 13 insertions, 1 deletions
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index 613ec16921f..9a05abed049 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -1118,6 +1118,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
* wildcard?: bool,
* since?: DateTimeFilter|null,
* until?: DateTimeFilter|null,
+ * person?: string
* } $options
* @return array
*/
@@ -1182,6 +1183,9 @@ class CardDavBackend implements BackendInterface, SyncSupport {
$query2->setFirstResult($options['offset']);
}
+ if (isset($options['person'])) {
+ $query2->andWhere($query2->expr()->ilike('cp.value', $query2->createNamedParameter('%' . $this->db->escapeLikeParameter($options['person']) . '%')));
+ }
if (isset($options['since']) || isset($options['until'])) {
$query2->join('cp', $this->dbCardsPropertiesTable, 'cp_bday', 'cp.cardid = cp_bday.cardid');
$query2->andWhere($query2->expr()->eq('cp_bday.name', $query2->createNamedParameter('BDAY')));
diff --git a/apps/dav/lib/Search/ContactsSearchProvider.php b/apps/dav/lib/Search/ContactsSearchProvider.php
index 57e69c676e0..265f4958efb 100644
--- a/apps/dav/lib/Search/ContactsSearchProvider.php
+++ b/apps/dav/lib/Search/ContactsSearchProvider.php
@@ -33,6 +33,7 @@ use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Search\FilterDefinition;
+use OCP\Search\IFilter;
use OCP\Search\IFilteringProvider;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
@@ -110,7 +111,7 @@ class ContactsSearchProvider implements IFilteringProvider {
'offset' => $query->getCursor(),
'since' => $query->getFilter('since'),
'until' => $query->getFilter('until'),
- 'person' => $query->getFilter('person'),
+ 'person' => $this->getPersonDisplayName($query->getFilter('person')),
'company' => $query->getFilter('company'),
],
);
@@ -137,6 +138,13 @@ class ContactsSearchProvider implements IFilteringProvider {
$query->getCursor() + count($formattedResults)
);
}
+ private function getPersonDisplayName(?IFilter $person): ?string {
+ $user = $person?->get();
+ if ($user instanceof IUser) {
+ return $user->getDisplayName();
+ }
+ return null;
+ }
protected function getDavUrlForContact(
string $principalUri,