3 * FusionForge search engine
5 * Copyright 1999-2001, VA Linux Systems, Inc
6 * Copyright 2004, Guillaume Smet/Open Wide
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfcommon.'search/SearchQuery.class.php';
27 class PeopleSearchQuery extends SearchQuery {
32 * @param string $words words we are searching for
33 * @param int $offset offset
34 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
36 function PeopleSearchQuery($words, $offset, $isExact) {
37 $this->SearchQuery($words, $offset, $isExact);
41 * getQuery - get the query built to get the search results
43 * @return array query+params array
46 $qpa = db_construct_qpa () ;
48 if (forge_get_config('use_fti')) {
49 $words = $this->getFTIwords();
50 $qpa = db_construct_qpa ($qpa,
51 'SELECT users.user_id, user_name, ts_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 ',
54 if (count ($this->phrases)) {
55 $qpa = db_construct_qpa ($qpa,
56 $this->getOperator()) ;
57 $qpa = db_construct_qpa ($qpa,
59 $qpa = $this->addMatchCondition($qpa, 'user_name');
60 $qpa = db_construct_qpa ($qpa,
62 $qpa = $this->addMatchCondition($qpa, 'realname');
63 $qpa = db_construct_qpa ($qpa,
66 $qpa = db_construct_qpa ($qpa,
67 ') ORDER BY ts_rank(vectors, q) DESC, user_name') ;
69 $qpa = db_construct_qpa ($qpa,
70 'SELECT user_name,user_id,realname FROM users WHERE ((') ;
71 $qpa = $this->addIlikeCondition ($qpa, 'user_name') ;
72 $qpa = db_construct_qpa ($qpa,
74 $qpa = $this->addIlikeCondition ($qpa, 'realname') ;
75 $qpa = db_construct_qpa ($qpa,
76 ')) AND status=$1 ORDER BY user_name',
85 // c-file-style: "bsd"