3 * FusionForge search engine
5 * Copyright 2004, Dominik Haas
6 * Copyright 2011, Franck Villaume - Capgemini
7 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
8 * Copyright 2013, French Minitry of National Education
10 * This file is part of FusionForge.
12 * FusionForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published
14 * by the Free Software Foundation; either version 2 of the License,
15 * or (at your option) any later version.
17 * FusionForge is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 require_once $gfcommon.'search/SearchQuery.class.php';
29 class DocsAllSearchQuery extends SearchQuery {
32 * array flags if non public items are returned
34 * @var $parametersValues
36 var $parametersValues;
41 * @param string $words words we are searching for
42 * @param int $offset offset
43 * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
44 * @param array $sections sections to search in
45 * @param boolean $showNonPublic flag if private sections are searched too
47 function __construct($words, $offset, $isExact = true, $sections=SEARCH__ALL_SECTIONS, $parametersValues, $showNonPublic = false) {
48 $this->parametersValues = $parametersValues;
49 $this->showNonPublic = $showNonPublic;
50 parent::__construct($words, $offset, $isExact);
54 * getQuery - get the sql query built to get the search results
56 * @return string sql query to execute
59 $qpa = db_construct_qpa();
60 $qpa = db_construct_qpa($qpa,
61 'SELECT doc_data.group_id, groups.group_name as project_name,doc_groups.groupname,
62 doc_data.docid, doc_data.title, doc_data.description, doc_data.filetype,
63 doc_data.filename, doc_groups.groupname
64 FROM doc_data, doc_groups, groups
65 WHERE doc_data.doc_group = doc_groups.doc_group
66 AND doc_data.group_id = groups.group_id',
68 if ($this->sections != SEARCH__ALL_SECTIONS) {
69 $qpa = db_construct_qpa($qpa,'AND doc_groups.doc_group = ANY ($1) ',
70 db_int_array_to_any_clause($this->sections));
72 if ($this->showNonPublic) {
73 $qpa = db_construct_qpa($qpa, ' AND doc_data.stateid IN (1, 4, 5)');
75 $qpa = db_construct_qpa($qpa, ' AND doc_data.stateid = 1');
78 $qpa = db_construct_qpa($qpa, ' AND ((');
79 $qpa = $this->addIlikeCondition($qpa, 'title', $this->words);
80 $qpa = db_construct_qpa($qpa, ') OR (');
81 $qpa = $this->addIlikeCondition($qpa, 'description', $this->words);
82 $qpa = db_construct_qpa($qpa, ') OR (');
83 $qpa = $this->addIlikeCondition($qpa, 'data_words', $this->words);
84 $qpa = db_construct_qpa ($qpa, ')) ORDER BY groups.group_name, doc_groups.groupname, doc_data.title') ;
93 // c-file-style: "bsd"