3 * FusionForge search engine
5 * Copyright 1999-2001, VA Linux Systems, Inc
6 * Copyright 2004, Guillaume Smet/Open Wide
8 * This file is part of FusionForge.
10 * FusionForge is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published
12 * by the Free Software Foundation; either version 2 of the License,
13 * or (at your option) any later version.
15 * FusionForge is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with FusionForge; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 require_once $gfcommon.'search/SearchQuery.class.php';
28 class PeopleSearchQuery extends SearchQuery {
33 * @param string $words words we are searching for
34 * @param int $offset offset
35 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
37 function PeopleSearchQuery($words, $offset, $isExact) {
38 $this->SearchQuery($words, $offset, $isExact);
42 * getQuery - get the query built to get the search results
44 * @return array query+params array
49 $qpa = db_construct_qpa () ;
51 if (forge_get_config('use_fti')) {
52 if (count ($this->words)) {
53 $words = $this->getFormattedWords();
54 $qpa = db_construct_qpa ($qpa,
55 'SELECT users.user_id, user_name, headline(realname, q) as realname FROM users, to_tsquery($1) AS q, users_idx WHERE status=$2 AND users_idx.user_id = users.user_id AND (vectors @@ q ',
59 $qpa = db_construct_qpa ($qpa,
60 'SELECT users.user_id, user_name, realname FROM users WHERE status=$1 AND users_idx.user_id = users.user_id AND (',
63 if (count ($this->phrases)) {
64 if (count ($this->words)) {
65 $qpa = db_construct_qpa ($qpa,
66 $this->getOperator()) ;
68 $qpa = db_construct_qpa ($qpa,
70 $qpa = $this->addMatchCondition($qpa, 'user_name');
71 $qpa = db_construct_qpa ($qpa,
73 $qpa = $this->addMatchCondition($qpa, 'realname');
74 $qpa = db_construct_qpa ($qpa,
77 if (count ($this->words)) {
78 $qpa = db_construct_qpa ($qpa,
79 ') ORDER BY rank(vectors, q) DESC, user_name') ;
81 $qpa = db_construct_qpa ($qpa,
82 ') ORDER BY user_name') ;
85 $qpa = db_construct_qpa ($qpa,
86 'SELECT user_name,user_id,realname FROM users WHERE ((') ;
87 $qpa = $this->addIlikeCondition ($qpa, 'user_name') ;
88 $qpa = db_construct_qpa ($qpa,
90 $qpa = $this->addIlikeCondition ($qpa, 'realname') ;
91 $qpa = db_construct_qpa ($qpa,
92 ')) AND status=$1 ORDER BY user_name',
101 // c-file-style: "bsd"