mirror of
https://github.com/nextcloud/server.git
synced 2026-05-19 16:39:59 -04:00
feat(search): allow contacts person search
Signed-off-by: hamza221 <hamzamahjoubi221@gmail.com> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
8b5d85a953
commit
26ee5a531b
2 changed files with 13 additions and 1 deletions
|
|
@ -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')));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue