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 SkillSearchQuery extends SearchQuery {
31 * getQuery - get the query built to get the search results
33 * @return array query+params array
38 $qpa = db_construct_qpa () ;
40 if (forge_get_config('use_fti')) {
41 $words = $this->getFTIwords();
42 $qpa = db_construct_qpa ($qpa,
43 'SELECT skills_data.skills_data_id, skills_data.type, skills_data.start, skills_data.finish, ts_headline(skills_data.title, q) as title, ts_headline(skills_data.keywords, q) as keywords FROM skills_data, users, skills_data_types, to_tsquery($1) AS q, skills_data_idx WHERE (vectors @@ q ',
45 if (count ($this->phrases)) {
46 $qpa = db_construct_qpa ($qpa,
47 $this->getOperator()) ;
48 $qpa = db_construct_qpa ($qpa,
50 $qpa = $this->addMatchCondition ($qpa, 'skills_data.title') ;
51 $qpa = db_construct_qpa ($qpa,
53 $qpa = $this->addMatchCondition ($qpa, 'skills_data.keywords') ;
54 $qpa = db_construct_qpa ($qpa,
57 $qpa = db_construct_qpa ($qpa,
59 $qpa = db_construct_qpa ($qpa,
60 'AND skills_data.skills_data_id = skills_data_idx.skills_data_id ') ;
61 $qpa = db_construct_qpa ($qpa,
62 'AND (skills_data.user_id=users.user_id) AND (skills_data.type=skills_data_types.type_id) ') ;
63 $qpa = db_construct_qpa ($qpa,
64 'ORDER BY ts_rank(vectors, q) DESC, finish DESC') ;
66 $qpa = db_construct_qpa ($qpa,
67 'SELECT * FROM skills_data, users, skills_data_types WHERE ((') ;
68 $qpa = $this->addIlikeCondition ($qpa, 'skills_data.title') ;
69 $qpa = db_construct_qpa ($qpa,
71 $qpa = $this->addIlikeCondition ($qpa, 'skills_data.keywords') ;
72 $qpa = db_construct_qpa ($qpa,
73 ')) AND (skills_data.user_id=users.user_id) AND (skills_data.type=skills_data_types.type_id) ORDER BY finish DESC') ;
81 // c-file-style: "bsd"