diff --git a/include/ajax.users.php b/include/ajax.users.php index dba3cb1da2fd19213b9a7dc7b453af8a0f5ea541..6d1f5936b9ae8146474ddda8688b355845075480 100644 --- a/include/ajax.users.php +++ b/include/ajax.users.php @@ -22,8 +22,8 @@ require_once INCLUDE_DIR.'class.note.php'; class UsersAjaxAPI extends AjaxController { - /* Assumes search by emal for now */ - function search($type = null) { + /* Assumes search by basic info for now */ + function search($type = null, $fulltext=false) { if(!isset($_REQUEST['q'])) { Http::response(400, __('Query argument is required')); @@ -53,15 +53,23 @@ class UsersAjaxAPI extends AjaxController { ->values_flat('id', 'emails__address', 'name') ->limit($limit); - global $ost; - $users = $ost->searcher->find($q, $users); - $users->order_by(new SqlCode('__relevance__'), QuerySet::DESC) - ->distinct('id'); + if ($fulltext) { + global $ost; + $users = $ost->searcher->find($q, $users); + $users->order_by(new SqlCode('__relevance__'), QuerySet::DESC) + ->distinct('id'); - if (!count($emails) && !count($users) && preg_match('`\w$`u', $q)) { - // Do wildcard full-text search - $_REQUEST['q'] = $q."*"; - return $this->search($type); + if (!count($emails) && !count($users) && preg_match('`\w$`u', $q)) { + // Do wildcard full-text search + $_REQUEST['q'] = $q."*"; + return $this->search($type, $fulltext); + } + } else { + $users->filter(Q::any(array( + 'emails__address__contains' => $q, + 'name__contains' => $q, + 'org__name__contains' => $q, + ))); } if ($emails = array_filter($emails)) { diff --git a/include/class.search.php b/include/class.search.php index 474fa3132d6c6763149c49c74893602c829fe26c..fb4c4e8007079313614698f618bd68fc109f3dfc 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -266,7 +266,7 @@ class MysqlSearchBackend extends SearchBackend { if ($model instanceof Ticket) $attrs['title'] = $attrs['number'].' '.$attrs['title']; elseif ($model instanceof User) - $content .= implode("\n", $attrs['emails']); + $content .=' '.implode("\n", $attrs['emails']); $title = $attrs['title'] ?: '';