3 * FusionForge search engine
5 * Copyright 1999-2001, VA Linux Systems, Inc
6 * Copyright 2004, Guillaume Smet/Open Wide
7 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
8 * http://fusionforge.org
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once $gfcommon.'search/SearchQuery.class.php';
28 class PeopleSearchQuery extends SearchQuery {
31 * getQuery - get the query built to get the search results
33 * @return array query+params array
36 $qpa = db_construct_qpa () ;
38 if (forge_get_config('use_fti')) {
39 $words = $this->getFTIwords();
40 $qpa = db_construct_qpa ($qpa,
41 '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 ',
44 if (count ($this->phrases)) {
45 $qpa = db_construct_qpa ($qpa,
46 $this->getOperator()) ;
47 $qpa = db_construct_qpa ($qpa,
49 $qpa = $this->addMatchCondition($qpa, 'user_name');
50 $qpa = db_construct_qpa ($qpa,
52 $qpa = $this->addMatchCondition($qpa, 'realname');
53 $qpa = db_construct_qpa ($qpa,
56 $qpa = db_construct_qpa ($qpa,
57 ') ORDER BY ts_rank(vectors, q) DESC, user_name') ;
59 $qpa = db_construct_qpa ($qpa,
60 'SELECT user_name,user_id,realname FROM users WHERE ((') ;
61 $qpa = $this->addIlikeCondition ($qpa, 'user_name') ;
62 $qpa = db_construct_qpa ($qpa,
64 $qpa = $this->addIlikeCondition ($qpa, 'realname') ;
65 $qpa = db_construct_qpa ($qpa,
66 ')) AND status=$1 ORDER BY user_name',
75 // c-file-style: "bsd"