This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  bf1a6b1e2b17b80731497a2b760ee7cf5b9f0765 (commit)
      from  45889f80c1dd29049332bba23569c63f79113dc9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=bf1a6b1e2b17b80731497a2b760ee7cf5b9f0765

commit bf1a6b1e2b17b80731497a2b760ee7cf5b9f0765
Author: Franck Villaume <[email protected]>
Date:   Sat Jan 16 12:27:49 2016 +0100

    SearchEngine: drop use_fti flag. FTI queries are default. Remove other 
unsupported queries

diff --git a/src/CHANGES b/src/CHANGES
index 8ff0391..6625c12 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -3,6 +3,7 @@ FusionForge 6.X:
 * Spellcheck (Anders Jonsson)
 * Site Admin: add paging system in userlist page [#799] (TrivialDev)
 * Projects Page: add paging system in full_list and tag_cloud subpages 
(TrivialDev)
+* SearchEngine: support only FTI queries (TrivialDev)
 * Docman: limit number of returned documents on search query. Use paging 
system [#794] (TrivialDev)
 * Docman: limit search using from & to dates [#798] (TrivialDev)
 * Docman: use standard search engine: unify results between 'search in 
project' & search in the docs tab (TrivialDev)
diff --git a/src/bin/migrate-to-ini-files.sh b/src/bin/migrate-to-ini-files.sh
index 756cb71..dd28c07 100755
--- a/src/bin/migrate-to-ini-files.sh
+++ b/src/bin/migrate-to-ini-files.sh
@@ -90,7 +90,6 @@ add_config core url_root >> $tmp
 add_config core use_docman >> $tmp
 add_config core use_forum >> $tmp
 add_config core use_frs >> $tmp
-add_config core use_fti >> $tmp
 add_config core use_ftp >> $tmp
 add_config core use_ftp_uploads >> $tmp
 add_config core use_gateways >> $tmp
diff --git a/src/common/search/ArtifactSearchQuery.class.php 
b/src/common/search/ArtifactSearchQuery.class.php
index d919094..6a3d17d 100644
--- a/src/common/search/ArtifactSearchQuery.class.php
+++ b/src/common/search/ArtifactSearchQuery.class.php
@@ -43,11 +43,11 @@ class ArtifactSearchQuery extends SearchQuery {
        /**
         * Constructor
         *
-        * @param string $words words we are searching for
-        * @param int $offset offset
-        * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
-        * @param int $groupId group id
-        * @param int $artifactId artifact id
+        * @param       string  $words          words we are searching for
+        * @param       int     $offset         offset
+        * @param       boolean $isExact        if we want to search for all 
the words or if only one matching the query is sufficient
+        * @param       int     $groupId        group id
+        * @param       int     $artifactId     artifact id
         */
        function __construct($words, $offset, $isExact, $groupId, $artifactId) {
                //TODO: Why is groupId an arg and var since it isn't used 
anywhere?
@@ -60,38 +60,23 @@ class ArtifactSearchQuery extends SearchQuery {
        /**
         * getQuery - get the query built to get the search results
         *
-        * @return array query+params array
+        * @return      array   query+params array
         */
        function getQuery() {
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $words = $this->getFTIwords();
-
-                       if (count($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'SELECT x.* FROM 
(SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, 
artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body),
 $1) as full_string_agg, artifact_idx.vectors FROM artifact LEFT OUTER JOIN 
artifact_message USING (artifact_id), users, artifact_idx WHERE users.user_id = 
artifact.submitted_by AND artifact.group_artifact_id = $2 AND 
artifact.artifact_id = artifact_idx.artifact_id AND vectors @@ to_tsquery($3) 
GROUP BY artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, artifact.details, vectors) AS x WHERE ',
-                                                        array 
($this->field_separator, $this->artifactId, $words)) ;
-                               $qpa = $this->addMatchCondition ($qpa, 
'full_string_agg') ;
-                               $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY ts_rank(vectors, 
to_tsquery($1)) DESC',
-                                                array($words)) ;
-                       } else {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'SELECT 
artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, artifact_idx.vectors FROM artifact, users, 
artifact_idx WHERE users.user_id = artifact.submitted_by AND 
artifact.group_artifact_id = $1 AND artifact.artifact_id = 
artifact_idx.artifact_id AND vectors @@ to_tsquery($2) ORDER BY 
ts_rank(vectors, to_tsquery($2)) DESC',
-                                                        array 
($this->artifactId, $words)) ;
-                       }
+               $words = $this->getFTIwords();
 
+               if (count($this->phrases)) {
+                       $qpa = db_construct_qpa(false, 'SELECT x.* FROM (SELECT 
artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, 
artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body),
 $1) as full_string_agg, artifact_idx.vectors FROM artifact LEFT OUTER JOIN 
artifact_message USING (artifact_id), users, artifact_idx WHERE users.user_id = 
artifact.submitted_by AND artifact.group_artifact_id = $2 AND 
artifact.artifact_id = artifact_idx.artifact_id AND vectors @@ to_tsquery($3) 
GROUP BY artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, artifact.details, vectors) AS x WHERE ',
+                                                       array 
($this->field_separator, $this->artifactId, $words));
+                       $qpa = $this->addMatchCondition($qpa, 
'full_string_agg');
+                       $qpa = db_construct_qpa($qpa, ' ORDER BY 
ts_rank(vectors, to_tsquery($1)) DESC',
+                                                       array($words));
                } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT x.* FROM (SELECT 
artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, 
artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body),
 $1) as full_string_agg FROM artifact LEFT OUTER JOIN artifact_message USING 
(artifact_id), users WHERE users.user_id = artifact.submitted_by AND 
artifact.group_artifact_id = $2 GROUP BY artifact.artifact_id, 
artifact.group_artifact_id, artifact.summary, artifact.open_date, 
users.realname, artifact.details) AS x WHERE ',
-                                                array ($this->field_separator, 
$this->artifactId)) ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'full_string_agg') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY artifact_id') ;
+                       $qpa = db_construct_qpa(false, 'SELECT 
artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, artifact_idx.vectors FROM artifact, users, 
artifact_idx WHERE users.user_id = artifact.submitted_by AND 
artifact.group_artifact_id = $1 AND artifact.artifact_id = 
artifact_idx.artifact_id AND vectors @@ to_tsquery($2) ORDER BY 
ts_rank(vectors, to_tsquery($2)) DESC',
+                                                       array 
($this->artifactId, $words));
                }
 
-               return $qpa ;
+               return $qpa;
        }
 }
 
diff --git a/src/common/search/DocsSearchQuery.class.php 
b/src/common/search/DocsSearchQuery.class.php
index 854a617..5e8cfde 100644
--- a/src/common/search/DocsSearchQuery.class.php
+++ b/src/common/search/DocsSearchQuery.class.php
@@ -46,12 +46,12 @@ class DocsSearchQuery extends SearchQuery {
        /**
         * Constructor
         *
-        * @param       string  $words words we are searching for
-        * @param       int     $offset offset
-        * @param       bool    $isExact if we want to search for all the words 
or if only one matching the query is sufficient
-        * @param       array   $groupIdArr array containing group ids
-        * @param       string  $sections sections to search in
-        * @param       bool    $showNonPublic flag if private sections are 
searched too
+        * @param       string  $words          words we are searching for
+        * @param       int     $offset         offset
+        * @param       bool    $isExact        if we want to search for all 
the words or if only one matching the query is sufficient
+        * @param       array   $groupIdArr     array containing group ids
+        * @param       string  $sections       sections to search in
+        * @param       bool    $showNonPublic  flag if private sections are 
searched too
         */
        function __construct($words, $offset, $isExact, $groupIdArr, $sections 
= SEARCH__ALL_SECTIONS, $showNonPublic = false, $rowsPerPage = 
SEARCH__DEFAULT_ROWS_PER_PAGE, $options = array()) {
 
@@ -101,37 +101,13 @@ class DocsSearchQuery extends SearchQuery {
         * @return      array   query+params array
         */
        function getQuery() {
-               if (forge_get_config('use_fti')) {
-                       return $this->getFTIQuery();
-               } else {
-                       $options = $this->options;
-                       if (!isset($options['insideDocuments']) || 
!$options['insideDocuments']) {
-                               $qpa = db_construct_qpa(false,
-                                                'SELECT x.* FROM (SELECT 
doc_data.docid, doc_data.group_id AS group_id, doc_data.title, 
doc_data.filename, doc_data.description, doc_groups.groupname, 
title||$1||description AS full_string_agg, groups.group_name as project_name 
FROM doc_data, doc_groups, groups WHERE doc_data.doc_group = 
doc_groups.doc_group AND doc_data.group_id = groups.group_id ',
-                                                array 
($this->field_separator));
-                       } else {
-                               $qpa = db_construct_qpa(false,
-                                                'SELECT x.* FROM (SELECT 
doc_data.docid, doc_data.group_id AS group_id, doc_data.title, 
doc_data.filename, doc_data.description, doc_groups.groupname, 
title||$1||description||$1||data_words AS full_string_agg, groups.group_name as 
project_name FROM doc_data, doc_groups, groups WHERE doc_data.doc_group = 
doc_groups.doc_group AND doc_data.group_id = groups.group_id ',
-                                                array 
($this->field_separator));
-                       }
-                       $qpa = $this->addCommonQPA($qpa);
-                       $qpa = db_construct_qpa($qpa, ') AS x WHERE ');
-                       $qpa = $this->addIlikeCondition($qpa, 
'full_string_agg');
-                       $qpa = db_construct_qpa($qpa, ' ORDER BY x.groupname, 
x.title');
-               }
-               return $qpa;
-       }
-
-       function getFTIQuery() {
                $words = $this->getFTIwords();
                $options = $this->options;
                if (!isset($options['insideDocuments']) || 
!$options['insideDocuments']) {
-                       $qpa = db_construct_qpa(false,
-                                       'SELECT x.* FROM (SELECT 
doc_data.docid, doc_data.group_id AS group_id, doc_data.filename, 
ts_headline(doc_data.title, q) AS title, ts_headline(doc_data.description, q) 
AS description, doc_groups.groupname, doc_data.title||$1||description AS 
full_string_agg, doc_data_idx.vectors, groups.group_name as project_name FROM 
groups, doc_data, doc_groups, doc_data_idx, to_tsquery($2) AS q WHERE 
doc_data.doc_group = doc_groups.doc_group AND doc_data.group_id = 
groups.group_id AND doc_data.docid = doc_data_idx.docid AND (vectors @@ 
to_tsquery($2))',
+                       $qpa = db_construct_qpa(false, 'SELECT x.* FROM (SELECT 
doc_data.docid, doc_data.group_id AS group_id, doc_data.filename, 
ts_headline(doc_data.title, q) AS title, ts_headline(doc_data.description, q) 
AS description, doc_groups.groupname, doc_data.title||$1||description AS 
full_string_agg, doc_data_idx.vectors, groups.group_name as project_name FROM 
groups, doc_data, doc_groups, doc_data_idx, to_tsquery($2) AS q WHERE 
doc_data.doc_group = doc_groups.doc_group AND doc_data.group_id = 
groups.group_id AND doc_data.docid = doc_data_idx.docid AND (vectors @@ 
to_tsquery($2))',
                                        array ($this->field_separator, $words));
                } else {
-                       $qpa = db_construct_qpa(false,
-                                       'SELECT x.* FROM (SELECT 
doc_data.docid, doc_data.group_id AS group_id, ts_headline(doc_data.filename, 
q) AS filename, ts_headline(doc_data.title, q) AS title, 
ts_headline(doc_data.description, q) AS description, doc_groups.groupname, 
doc_data.title||$1||description||$1||filename AS full_string_agg, 
doc_data_words_idx.vectors, groups.group_name as project_name FROM groups, 
doc_data, doc_groups, doc_data_words_idx, to_tsquery($2) AS q WHERE 
doc_data.doc_group = doc_groups.doc_group AND doc_data.group_id = 
groups.group_id AND doc_data.docid = doc_data_words_idx.docid AND (vectors @@ 
to_tsquery($2))',
+                       $qpa = db_construct_qpa(false, 'SELECT x.* FROM (SELECT 
doc_data.docid, doc_data.group_id AS group_id, ts_headline(doc_data.filename, 
q) AS filename, ts_headline(doc_data.title, q) AS title, 
ts_headline(doc_data.description, q) AS description, doc_groups.groupname, 
doc_data.title||$1||description||$1||filename AS full_string_agg, 
doc_data_words_idx.vectors, groups.group_name as project_name FROM groups, 
doc_data, doc_groups, doc_data_words_idx, to_tsquery($2) AS q WHERE 
doc_data.doc_group = doc_groups.doc_group AND doc_data.group_id = 
groups.group_id AND doc_data.docid = doc_data_words_idx.docid AND (vectors @@ 
to_tsquery($2))',
                                        array ($this->field_separator, $words));
                }
                $qpa = $this->addCommonQPA($qpa);
@@ -140,8 +116,7 @@ class DocsSearchQuery extends SearchQuery {
                        $qpa = db_construct_qpa($qpa, 'WHERE ') ;
                        $qpa = $this->addMatchCondition($qpa, 
'full_string_agg');
                }
-               $qpa = db_construct_qpa($qpa,
-                                        ' ORDER BY ts_rank(vectors, 
to_tsquery($1)) DESC, group_id ASC, groupname ASC, title ASC',
+               $qpa = db_construct_qpa($qpa, ' ORDER BY ts_rank(vectors, 
to_tsquery($1)) DESC, group_id ASC, groupname ASC, title ASC',
                                         array($words));
 
                return $qpa;
@@ -152,7 +127,7 @@ class DocsSearchQuery extends SearchQuery {
         *
         * @param       $groupId        int group id
         * @param       $showNonPublic  boolean if we should consider non 
public sections
-        * @return array
+        * @return      array
         */
        static function getSections($groupId, $showNonPublic = false) {
                if (!forge_check_perm('docman',$groupId,'read')) {
diff --git a/src/common/search/ExportProjectSearchQuery.class.php 
b/src/common/search/ExportProjectSearchQuery.class.php
index 69dca88..6c14ab3 100644
--- a/src/common/search/ExportProjectSearchQuery.class.php
+++ b/src/common/search/ExportProjectSearchQuery.class.php
@@ -29,9 +29,9 @@ class ExportProjectSearchQuery extends SearchQuery {
        /**
         * Constructor
         *
-        * @param string $words words we are searching for
-        * @param int $offset offset
-        * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
+        * @param       string  $words          words we are searching for
+        * @param       int     $offset         offset
+        * @param       boolean $isExact        if we want to search for all 
the words or if only one matching the query is sufficient
         */
        function __construct($words, $offset, $isExact) {
                parent::__construct($words, $offset, $isExact, 200);
@@ -40,60 +40,27 @@ class ExportProjectSearchQuery extends SearchQuery {
        /**
         * getQuery - get the query built to get the search results
         *
-        * @return array query+params array
+        * @return      array   query+params array
         */
        function getQuery() {
-
-               $qpa = db_construct_qpa() ;
-               if (forge_get_config('use_fti')) {
-                       $words = $this->getFTIwords();
-
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT 
ts_headline(unix_group_name, q) as unix_group_name, 
ts_headline(short_description, q) as short_description, type_id, 
groups.group_id, license, register_time FROM groups, groups_idx, to_tsquery($1) 
q ',
-                                                array (implode (' ', $words))) 
;
-                       $qpa = db_construct_qpa($qpa,
-                                                'WHERE status IN ($1, $2) AND 
short_description <> $3 AND groups.group_id = groups_idx.group_id',
-                                                array ('A',
-                                                       'H',
-                                                       '')) ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ' AND (vectors @@ q' ) ;
-                       if (count($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        $this->getOperator()) ;
-                               $qpa = db_construct_qpa($qpa,
-                                                        '(') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'group_name');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') OR (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'unix_group_name');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') OR (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'short_description');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ')') ;
-                       }
-                       $qpa = db_construct_qpa($qpa,
-                                                ') ORDER BY ts_rank(vectors, 
q) DESC, group_name ASC') ;
-               } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT 
group_name,unix_group_name,type_id,groups.group_id, 
short_description,license,register_time FROM groups WHERE status IN ($1, $2) 
AND short_description <> $3 AND groups.group_id = groups_idx.group_id',
-                                                        array ('A',
-                                                               'H',
-                                                               '')) ;
-                        $qpa = db_construct_qpa($qpa,
-                                                 ' AND ((') ;
-                        $qpa = $this->addIlikeCondition ($qpa, 'group_name') ;
-                        $qpa = db_construct_qpa($qpa,
-                                                 ') OR (') ;
-                        $qpa = $this->addIlikeCondition ($qpa, 
'unix_group_name') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                 ') OR (') ;
-                        $qpa = $this->addIlikeCondition ($qpa, 
'short_description') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                 '))') ;
+               $words = $this->getFTIwords();
+               $qpa = db_construct_qpa(false, 'SELECT 
ts_headline(unix_group_name, q) as unix_group_name, 
ts_headline(short_description, q) as short_description, type_id, 
groups.group_id, license, register_time FROM groups, groups_idx, to_tsquery($1) 
q ',
+                                               array(implode(' ', $words)));
+               $qpa = db_construct_qpa($qpa, 'WHERE status IN ($1, $2) AND 
short_description <> $3 AND groups.group_id = groups_idx.group_id',
+                                               array('A', 'H', ''));
+               $qpa = db_construct_qpa($qpa, ' AND (vectors @@ q');
+               if (count($this->phrases)) {
+                       $qpa = db_construct_qpa($qpa, $this->getOperator());
+                       $qpa = db_construct_qpa($qpa, '(');
+                       $qpa = $this->addMatchCondition($qpa, 'group_name');
+                       $qpa = db_construct_qpa($qpa, ') OR (');
+                       $qpa = $this->addMatchCondition($qpa, 
'unix_group_name');
+                       $qpa = db_construct_qpa($qpa, ') OR (');
+                       $qpa = $this->addMatchCondition($qpa, 
'short_description');
+                       $qpa = db_construct_qpa($qpa, ')');
                }
-               return $qpa ;
+               $qpa = db_construct_qpa($qpa, ') ORDER BY ts_rank(vectors, q) 
DESC, group_name ASC');
+               return $qpa;
        }
 }
 
diff --git a/src/common/search/ForumSearchQuery.class.php 
b/src/common/search/ForumSearchQuery.class.php
index 8d1c105..365f558 100644
--- a/src/common/search/ForumSearchQuery.class.php
+++ b/src/common/search/ForumSearchQuery.class.php
@@ -43,11 +43,11 @@ class ForumSearchQuery extends SearchQuery {
        /**
         * Constructor
         *
-        * @param string $words words we are searching for
-        * @param int $offset offset
-        * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
-        * @param int $groupId group id
-        * @param int $forumId forum id
+        * @param       string  $words          words we are searching for
+        * @param       int     $offset         offset
+        * @param       boolean $isExact        if we want to search for all 
the words or if only one matching the query is sufficient
+        * @param       int     $groupId        group id
+        * @param       int     $forumId        forum id
         */
        function __construct($words, $offset, $isExact, $groupId, $forumId) {
                $this->groupId = $groupId;
@@ -59,41 +59,21 @@ class ForumSearchQuery extends SearchQuery {
        /**
         * getQuery - get the query built to get the search results
         *
-        * @return array query+params array
+        * @return      array   query+params array
         */
        function getQuery() {
+               $words = $this->getFTIwords();
+               $qpa = db_construct_qpa(false, 'SELECT x.* FROM (SELECT 
forum.group_forum_id, forum.msg_id, ts_headline(forum.subject, $1::tsquery) AS 
subject, forum.post_date, users.realname, forum.subject||$2||forum.body as 
full_string_agg, forum_idx.vectors FROM forum, users, to_tsquery($1) AS q, 
forum_idx WHERE forum.group_forum_id = $3 AND forum.posted_by = users.user_id 
AND forum_idx.msg_id = forum.msg_id GROUP BY forum.group_forum_id, 
forum.msg_id, subject, body, post_date, realname, forum_idx.vectors) AS x WHERE 
vectors @@ $1::tsquery ',
+                                               array($words, 
$this->field_separator, $this->forumId));
+               $phraseOp = $this->getOperator();
 
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $words = $this->getFTIwords();
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT x.* FROM (SELECT 
forum.group_forum_id, forum.msg_id, ts_headline(forum.subject, $1::tsquery) AS 
subject, forum.post_date, users.realname, forum.subject||$2||forum.body as 
full_string_agg, forum_idx.vectors FROM forum, users, to_tsquery($1) AS q, 
forum_idx WHERE forum.group_forum_id = $3 AND forum.posted_by = users.user_id 
AND forum_idx.msg_id = forum.msg_id GROUP BY forum.group_forum_id, 
forum.msg_id, subject, body, post_date, realname, forum_idx.vectors) AS x WHERE 
vectors @@ $1::tsquery ',
-                                                array ($words,
-                                                       $this->field_separator,
-                                                       $this->forumId)) ;
-                       $phraseOp = $this->getOperator();
-
-                       if(count($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'full_string_agg');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') ') ;
-                       }
-                       $qpa = db_construct_qpa($qpa,
-                                                'ORDER BY ts_rank(vectors, $1) 
DESC',
-                                                array($words)) ;
-               } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT x.* FROM (SELECT 
forum.group_forum_id, forum.msg_id, forum.subject, forum.post_date, 
users.realname, forum.subject||$1||forum.body as full_string_agg FROM 
forum,users WHERE users.user_id=forum.posted_by AND forum.group_forum_id=$2 
GROUP BY forum.group_forum_id, msg_id, subject, post_date, realname, body) AS x 
WHERE ',
-                                                array ($this->field_separator,
-                                                       $this->forumId)) ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'full_string_agg') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ' ');
+               if(count($this->phrases)) {
+                       $qpa = db_construct_qpa($qpa, 'AND (');
+                       $qpa = $this->addMatchCondition($qpa, 
'full_string_agg');
+                       $qpa = db_construct_qpa($qpa, ') ');
                }
-               return $qpa ;
+               $qpa = db_construct_qpa($qpa, 'ORDER BY ts_rank(vectors, $1) 
DESC', array($words));
+               return $qpa;
        }
 }
 
diff --git a/src/common/search/ForumsSearchQuery.class.php 
b/src/common/search/ForumsSearchQuery.class.php
index de52e95..89db4ee 100644
--- a/src/common/search/ForumsSearchQuery.class.php
+++ b/src/common/search/ForumsSearchQuery.class.php
@@ -45,12 +45,12 @@ class ForumsSearchQuery extends SearchQuery {
        /**
         * Constructor
         *
-        * @param string        $words words we are searching for
-        * @param int           $offset offset
-        * @param bool          $isExact if we want to search for all the words 
or if only one matching the query is sufficient
-        * @param int           $groupId group id
-        * @param string        $sections sections to search in
-        * @param bool          $showNonPublic flag if private sections are 
searched too
+        * @param       string  $words          words we are searching for
+        * @param       int     $offset         offset
+        * @param       bool    $isExact        if we want to search for all 
the words or if only one matching the query is sufficient
+        * @param       int     $groupId        group id
+        * @param       string  $sections       sections to search in
+        * @param       bool    $showNonPublic  flag if private sections are 
searched too
         */
        function __construct($words, $offset, $isExact, $groupId, 
$sections=SEARCH__ALL_SECTIONS, $showNonPublic=false) {
                $this->groupId = $groupId;
@@ -64,70 +64,44 @@ class ForumsSearchQuery extends SearchQuery {
        /**
         * getQuery - get the query built to get the search results
         *
-        * @return array query+params array
+        * @return      array   query+params array
         */
        function getQuery() {
+               $nonPublic = 'false';
+               $sections = '';
+               if ($this->showNonPublic) {
+                       $nonPublic = 'true';
+               }
+               if ($this->sections != SEARCH__ALL_SECTIONS) {
+                       $sections = $this->sections;
+               }
 
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $nonPublic = 'false';
-                       $sections = '';
-                       if ($this->showNonPublic) {
-                               $nonPublic = 'true';
-                       }
-                       if ($this->sections != SEARCH__ALL_SECTIONS) {
-                               $sections = $this->sections;
-                       }
+               $qpa = db_construct_qpa(false, 'SELECT forum.group_forum_id, 
forum.msg_id, ts_headline(forum.subject, q) AS subject, forum.post_date, 
users.realname, forum_group_list.forum_name, forum.subject||$2||forum.body as 
full_string_agg FROM forum, users, forum_group_list, forum_idx, to_tsquery($1) 
as q ',
+                                               array ($this->getFTIwords(), 
$this->field_separator));
+               $qpa = db_construct_qpa($qpa, 'WHERE users.user_id = 
forum.posted_by AND vectors @@ q AND forum.msg_id = forum_idx.msg_id AND 
forum_group_list.group_forum_id = forum.group_forum_id AND forum.group_forum_id 
IN (SELECT group_forum_id FROM forum_group_list WHERE group_id = $1) ',
+                                               array ($this->groupId));
 
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT forum.group_forum_id, 
forum.msg_id, ts_headline(forum.subject, q) AS subject, forum.post_date, 
users.realname, forum_group_list.forum_name, forum.subject||$2||forum.body as 
full_string_agg FROM forum, users, forum_group_list, forum_idx, to_tsquery($1) 
as q ',
-                                                array ($this->getFTIwords(),
-                                                       
$this->field_separator)) ;
-                       $qpa = db_construct_qpa($qpa,
-                                                'WHERE users.user_id = 
forum.posted_by AND vectors @@ q AND forum.msg_id = forum_idx.msg_id AND 
forum_group_list.group_forum_id = forum.group_forum_id AND forum.group_forum_id 
IN (SELECT group_forum_id FROM forum_group_list WHERE group_id = $1) ',
-                                                array ($this->groupId));
-                       if ($this->sections != SEARCH__ALL_SECTIONS) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND 
forum_group_list.group_forum_id = ANY ($1) ',
-                                                        array 
(db_int_array_to_any_clause ($this->sections))) ;
-                       }
-
-                       if(count($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'full_string_agg');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') ') ;
-                       }
+               if ($this->sections != SEARCH__ALL_SECTIONS) {
+                       $qpa = db_construct_qpa($qpa, 'AND 
forum_group_list.group_forum_id = ANY ($1) ',
+                                               
array(db_int_array_to_any_clause ($this->sections)));
+               }
 
-                       $qpa = db_construct_qpa($qpa,
-                                                'ORDER BY 
forum_group_list.forum_name ASC, forum.msg_id ASC, ts_rank(vectors, q) DESC') ;
-               } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT x.* FROM (SELECT 
forum.group_forum_id, forum.msg_id, forum.subject, forum.post_date, 
users.realname, forum_group_list.forum_name, forum.subject||$1||forum.body as 
full_string_agg FROM forum, users, forum_group_list WHERE users.user_id = 
forum.posted_by AND forum_group_list.group_forum_id = forum.group_forum_id AND 
forum.group_forum_id IN (SELECT group_forum_id FROM forum_group_list WHERE 
group_id = $2) ',
-                                                array ($this->field_separator,
-                                                       $this->groupId)) ;
-                       if ($this->sections != SEARCH__ALL_SECTIONS) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND 
forum_group_list.group_forum_id = ANY ($1) ',
-                                                        array 
(db_int_array_to_any_clause ($this->sections))) ;
-                       }
-                       $qpa = db_construct_qpa($qpa,
-                                                ') AS x WHERE ') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'full_string_agg') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY x.forum_name, 
x.msg_id') ;
+               if(count($this->phrases)) {
+                       $qpa = db_construct_qpa($qpa, 'AND (');
+                       $qpa = $this->addMatchCondition($qpa, 
'full_string_agg');
+                       $qpa = db_construct_qpa($qpa, ') ');
                }
+
+               $qpa = db_construct_qpa($qpa, 'ORDER BY 
forum_group_list.forum_name ASC, forum.msg_id ASC, ts_rank(vectors, q) DESC');
                return $qpa ;
        }
 
        /**
         * getSections - returns the list of available forums
         *
-        * @param $groupId int group id
-        * @param $showNonPublic boolean if we should consider non public 
sections
-        * @return array
+        * @param       int     $groupId        group id
+        * @param       boolean $showNonPublic  if we should consider non 
public sections
+        * @return      array
         */
        static function getSections($groupId, $showNonPublic=false) {
                $sql = 'SELECT group_forum_id, forum_name FROM forum_group_list 
WHERE group_id = $1 AND ';
diff --git a/src/common/search/FrsSearchQuery.class.php 
b/src/common/search/FrsSearchQuery.class.php
index 967ebfd..8fc2f34 100644
--- a/src/common/search/FrsSearchQuery.class.php
+++ b/src/common/search/FrsSearchQuery.class.php
@@ -44,12 +44,12 @@ class FrsSearchQuery extends SearchQuery {
        /**
         * Constructor
         *
-        * @param string        $words words we are searching for
-        * @param int           $offset offset
-        * @param bool          $isExact if we want to search for all the words 
or if only one matching the query is sufficient
-        * @param int           $groupId group id
-        * @param string        $sections sections to search in
-        * @param bool          $showNonPublic
+        * @param       string  $words          words we are searching for
+        * @param       int     $offset         offset
+        * @param       bool    $isExact        if we want to search for all 
the words or if only one matching the query is sufficient
+        * @param       int     $groupId        group id
+        * @param       string  $sections       sections to search in
+        * @param       bool    $showNonPublic
         */
        function __construct($words, $offset, $isExact, $groupId, 
$sections=SEARCH__ALL_SECTIONS, $showNonPublic=false) {
                $this->groupId = $groupId;
@@ -63,86 +63,42 @@ class FrsSearchQuery extends SearchQuery {
        /**
         * getQuery - get the query built to get the search results
         *
-        * @return array query+params array
+        * @return      array   query+params array
         */
        function getQuery() {
+               $qpa = db_construct_qpa(false, 'SELECT 
ts_headline(frs_package.name, q) AS package_name, ts_headline(frs_release.name, 
q) as release_name, frs_release.release_date, frs_release.release_id, 
users.realname FROM frs_file, frs_release, users, frs_package, to_tsquery($1) 
AS q, frs_release_idx r, frs_file_idx f WHERE frs_release.released_by = 
users.user_id AND r.release_id = frs_release.release_id AND f.file_id = 
frs_file.file_id AND frs_package.package_id = frs_release.package_id AND 
frs_file.release_id=frs_release.release_id AND frs_package.group_id=$2 ',
+                                                array($this->getFTIwords(), 
$this->groupId));
+               if ($this->sections != SEARCH__ALL_SECTIONS) {
+                       $qpa = db_construct_qpa($qpa, 'AND 
frs_package.package_id = ANY ($1) ',
+                                                       
array(db_int_array_to_any_clause ($this->sections)));
+               }
+               if (!$this->showNonPublic) {
+                       $qpa = db_construct_qpa($qpa, 'AND is_public = 1 ');
+               }
+               $qpa = db_construct_qpa($qpa, 'AND (f.vectors @@ q OR r.vectors 
@@ q) ');
+               if(count($this->phrases)) {
+                       $qpa = db_construct_qpa($qpa, 'AND ((');
+                       $qpa = $this->addMatchCondition($qpa, 
'frs_release.changes');
+                       $qpa = db_construct_qpa($qpa, ') OR (');
+                       $qpa = $this->addMatchCondition($qpa, 
'frs_release.notes');
+                       $qpa = db_construct_qpa($qpa, ') OR (');
+                       $qpa = $this->addMatchCondition($qpa, 
'frs_release.name');
+                       $qpa = db_construct_qpa($qpa, ') OR (');
+                       $qpa = $this->addMatchCondition($qpa, 
'frs_file.filename');
+                       $qpa = db_construct_qpa($qpa, ')) ');
+               }
 
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $qpa = db_construct_qpa() ;
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT 
ts_headline(frs_package.name, q) AS package_name, ts_headline(frs_release.name, 
q) as release_name, frs_release.release_date, frs_release.release_id, 
users.realname FROM frs_file, frs_release, users, frs_package, to_tsquery($1) 
AS q, frs_release_idx r, frs_file_idx f WHERE frs_release.released_by = 
users.user_id AND r.release_id = frs_release.release_id AND f.file_id = 
frs_file.file_id AND frs_package.package_id = frs_release.package_id AND 
frs_file.release_id=frs_release.release_id AND frs_package.group_id=$2 ',
-                                                array ($this->getFTIwords(),
-                                                       $this->groupId)) ;
-                       if ($this->sections != SEARCH__ALL_SECTIONS) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND 
frs_package.package_id = ANY ($1) ',
-                                                        array 
(db_int_array_to_any_clause ($this->sections))) ;
-                       }
-                       if (!$this->showNonPublic) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND is_public = 1 ') ;
-                       }
-                       $qpa = db_construct_qpa($qpa,
-                                                'AND (f.vectors @@ q OR 
r.vectors @@ q) ') ;
-                       if(count($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND ((') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'frs_release.changes');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') OR (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'frs_release.notes');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') OR (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'frs_release.name');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') OR (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'frs_file.filename');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ')) ') ;
-                       }
-
-                       $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY frs_package.name, 
frs_release.name') ;
+               $qpa = db_construct_qpa($qpa, ' ORDER BY frs_package.name, 
frs_release.name');
 
-               } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT frs_package.name as 
package_name, frs_release.name as release_name, frs_release.release_date, 
frs_release.release_id, users.realname FROM frs_file, frs_release, users, 
frs_package WHERE frs_release.released_by = users.user_id AND 
frs_package.package_id = frs_release.package_id AND 
frs_file.release_id=frs_release.release_id AND frs_package.group_id = $1 ',
-                                                array ($this->groupId)) ;
-                       if ($this->sections != SEARCH__ALL_SECTIONS) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND 
frs_package.package_id = ANY ($1) ',
-                                                        array 
(db_int_array_to_any_clause ($this->sections))) ;
-                       }
-                       if (!$this->showNonPublic) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND is_public = 1 ') ;
-                       }
-                       $qpa = db_construct_qpa($qpa,
-                                                'AND ((') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'frs_release.changes') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ') OR (') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'frs_release.notes') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ') OR (') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'frs_release.name') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ') OR (') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'frs_file.filename') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ')) ORDER BY frs_package.name, 
frs_release.name') ;
-               }
                return $qpa ;
        }
 
        /**
         * getSections - returns the list of available forums
         *
-        * @param $groupId int group id
-        * @param $showNonPublic boolean if we should consider non public 
sections
-        * @return array
+        * @param       int     $groupId        group id
+        * @param       boolean $showNonPublic  if we should consider non 
public sections
+        * @return      array
         */
        static function getSections($groupId, $showNonPublic) {
                $sql = 'SELECT package_id, name FROM frs_package WHERE 
group_id=$1';
diff --git a/src/common/search/NewsSearchQuery.class.php 
b/src/common/search/NewsSearchQuery.class.php
index 3653cba..692a853 100644
--- a/src/common/search/NewsSearchQuery.class.php
+++ b/src/common/search/NewsSearchQuery.class.php
@@ -37,10 +37,10 @@ class NewsSearchQuery extends SearchQuery {
        /**
         * Constructor
         *
-        * @param string $words words we are searching for
-        * @param int $offset offset
-        * @param boolean $isExact if we want to search for all the words or if 
only one matching the query is sufficient
-        * @param int $groupId group id
+        * @param       string  $words          words we are searching for
+        * @param       int     $offset         offset
+        * @param       boolean $isExact        if we want to search for all 
the words or if only one matching the query is sufficient
+        * @param       int     $groupId        group id
         */
        function __construct($words, $offset, $isExact, $groupId) {
                $this->groupId = $groupId;
@@ -51,57 +51,39 @@ class NewsSearchQuery extends SearchQuery {
        /**
         * getQuery - get the query built to get the search results
         *
-        * @return array query+params array
+        * @return      array   query+params array
         */
        function getQuery() {
+               $group_id=$this->groupId;
 
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $group_id=$this->groupId;
-
-                       $words = $this->getFTIwords();
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT x.* FROM (SELECT 
ts_headline(news_bytes.summary, q) as summary, news_bytes.post_date, 
news_bytes.forum_id, users.realname, summary||$1||details AS full_string_agg, 
news_bytes_idx.vectors FROM news_bytes, users, to_tsquery($2) AS q, 
news_bytes_idx WHERE (news_bytes.group_id=$3 AND news_bytes.is_approved <> 4 
AND news_bytes_idx.id = news_bytes.id AND 
news_bytes.submitted_by=users.user_id) AND vectors @@ q) AS x ',
-                                                array ($this->field_separator,
-                                                       $words,
-                                                       $group_id)) ;
-                       if (count ($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'WHERE ');
-                               $qpa = $this->addMatchCondition ($qpa, 
'full_string_agg') ;
-                       }
-                       $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY ts_rank(vectors, 
to_tsquery($1)) DESC, post_date DESC',
-                                                array($words)) ;
-               } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT x.* FROM (SELECT 
news_bytes.summary, news_bytes.post_date, news_bytes.forum_id, users.realname, 
summary||$1||details AS full_string_agg FROM news_bytes, users WHERE 
group_id=$2 AND is_approved <> 4 AND news_bytes.submitted_by = users.user_id) 
AS x WHERE ',
-                                                array ($this->field_separator,
-                                                       $this->groupId)) ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'full_string_agg') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY post_date DESC') ;
+               $words = $this->getFTIwords();
+               $qpa = db_construct_qpa(false, 'SELECT x.* FROM (SELECT 
ts_headline(news_bytes.summary, q) as summary, news_bytes.post_date, 
news_bytes.forum_id, users.realname, summary||$1||details AS full_string_agg, 
news_bytes_idx.vectors FROM news_bytes, users, to_tsquery($2) AS q, 
news_bytes_idx WHERE (news_bytes.group_id=$3 AND news_bytes.is_approved <> 4 
AND news_bytes_idx.id = news_bytes.id AND 
news_bytes.submitted_by=users.user_id) AND vectors @@ q) AS x ',
+                                               array ($this->field_separator, 
$words, $group_id));
+               if (count ($this->phrases)) {
+                       $qpa = db_construct_qpa($qpa, 'WHERE ');
+                       $qpa = $this->addMatchCondition($qpa, 
'full_string_agg');
                }
-               return $qpa ;
+               $qpa = db_construct_qpa($qpa, ' ORDER BY ts_rank(vectors, 
to_tsquery($1)) DESC, post_date DESC',
+                                               array($words));
+
+               return $qpa;
        }
 
        /**
         * getSections - returns the list of available forums
         *
-        * @param int $groupId group id
-        * @param bool $showNonPublic if we should consider non public sections
-        * @return array
+        * @param       int     $groupId        group id
+        * @param       bool    $showNonPublic  if we should consider non 
public sections
+        * @return      array
         */
-       static function getSections($groupId, $showNonPublic=false) {
+       static function getSections($groupId, $showNonPublic = false) {
 
                // Select survey of the project
                $sql = 'SELECT group_forum_id, forum_name FROM forum_group_list 
WHERE group_id = $1 AND ';
                $sql .= 'group_forum_id IN (SELECT forum_id FROM news_bytes) 
ORDER BY forum_name';
 
                $sections = array();
-               $res = db_query_params ($sql,
-                                       array ($groupId));
+               $res = db_query_params($sql, array ($groupId));
                while($data = db_fetch_array($res)) {
                        if 
(forge_check_perm('forum',$data['group_forum_id'],'read')) {
                                $sections[$data['group_forum_id']] = 
$data['forum_name'];
diff --git a/src/common/search/PeopleSearchQuery.class.php 
b/src/common/search/PeopleSearchQuery.class.php
index 2bf122e..4fa9f4b 100644
--- a/src/common/search/PeopleSearchQuery.class.php
+++ b/src/common/search/PeopleSearchQuery.class.php
@@ -30,43 +30,22 @@ class PeopleSearchQuery extends SearchQuery {
        /**
         * getQuery - get the query built to get the search results
         *
-        * @return array query+params array
+        * @return      array   query+params array
         */
        function getQuery() {
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $words = $this->getFTIwords();
-                       $qpa = db_construct_qpa($qpa,
-                                                '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 ',
-                                                array ($words,
-                                                       'A'));
-                       if (count ($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        $this->getOperator()) ;
-                               $qpa = db_construct_qpa($qpa,
-                                                        '(') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'user_name');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') OR (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'realname');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ')') ;
-                       }
-                       $qpa = db_construct_qpa($qpa,
-                                                ') ORDER BY ts_rank(vectors, 
q) DESC, user_name') ;
-               } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT 
user_name,user_id,realname FROM users WHERE ((') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 'user_name') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ') OR (') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 'realname') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ')) AND status=$1 ORDER BY 
user_name',
-                                                array ('A')) ;
+               $words = $this->getFTIwords();
+               $qpa = db_construct_qpa(false, '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 ',
+                                               array ($words, 'A'));
+               if (count ($this->phrases)) {
+                       $qpa = db_construct_qpa($qpa, $this->getOperator());
+                       $qpa = db_construct_qpa($qpa, '(');
+                       $qpa = $this->addMatchCondition($qpa, 'user_name');
+                       $qpa = db_construct_qpa($qpa, ') OR (');
+                       $qpa = $this->addMatchCondition($qpa, 'realname');
+                       $qpa = db_construct_qpa($qpa, ')') ;
                }
-               return $qpa ;
+               $qpa = db_construct_qpa($qpa, ') ORDER BY ts_rank(vectors, q) 
DESC, user_name');
+               return $qpa;
        }
 }
 
diff --git a/src/common/search/ProjectSearchQuery.class.php 
b/src/common/search/ProjectSearchQuery.class.php
index 2638394..e5b89d9 100644
--- a/src/common/search/ProjectSearchQuery.class.php
+++ b/src/common/search/ProjectSearchQuery.class.php
@@ -34,47 +34,21 @@ class ProjectSearchQuery extends SearchQuery {
         * @return array query+params array
         */
        function getQuery() {
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $words = $this->getFTIwords();
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT DISTINCT ON 
(ts_rank(vectors, q), group_name) type_id, g.group_id, ts_headline(group_name, 
q) as group_name, unix_group_name, ts_headline(short_description, q) as 
short_description FROM groups AS g, to_tsquery($1) AS q, groups_idx as i WHERE 
g.status in ($2, $3) ',
-                                                array ($words,
-                                                       'A',
-                                                       'H')) ;
-                       $qpa = db_construct_qpa($qpa,
-                                                'AND vectors @@ q ') ;
-                       if (count($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        ' AND ((') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'group_name');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') OR (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'short_description');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') OR (') ;
-                               $qpa = $this->addMatchCondition($qpa, 
'unix_group_name');
-                               $qpa = db_construct_qpa($qpa,
-                                                        ')) ') ;
-                       }
-                       $qpa = db_construct_qpa($qpa,
-                                                'AND g.group_id = i.group_id 
ORDER BY ts_rank(vectors, q) DESC, group_name') ;
-               } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT g.group_name AS 
group_name, g.unix_group_name AS unix_group_name, g.type_id AS type_id, 
g.group_id AS group_id, g.short_description AS short_description FROM groups g 
WHERE g.status IN ($1, $2) AND ((',
-                                                array ('A', 'H')) ;
-                       $qpa = $this->addIlikeCondition ($qpa, 'g.group_name') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ') OR (') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'g.short_description') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ') OR (') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'g.unix_group_name') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ')) ORDER BY g.group_name') ;
+               $words = $this->getFTIwords();
+               $qpa = db_construct_qpa(false, 'SELECT DISTINCT ON 
(ts_rank(vectors, q), group_name) type_id, g.group_id, ts_headline(group_name, 
q) as group_name, unix_group_name, ts_headline(short_description, q) as 
short_description FROM groups AS g, to_tsquery($1) AS q, groups_idx as i WHERE 
g.status in ($2, $3) ',
+                                               array ($words, 'A', 'H'));
+               $qpa = db_construct_qpa($qpa, 'AND vectors @@ q ');
+               if (count($this->phrases)) {
+                       $qpa = db_construct_qpa($qpa, ' AND ((');
+                       $qpa = $this->addMatchCondition($qpa, 'group_name');
+                       $qpa = db_construct_qpa($qpa, ') OR (');
+                       $qpa = $this->addMatchCondition($qpa, 
'short_description');
+                       $qpa = db_construct_qpa($qpa, ') OR (');
+                       $qpa = $this->addMatchCondition($qpa, 
'unix_group_name');
+                       $qpa = db_construct_qpa($qpa, ')) ');
                }
-               return $qpa ;
+               $qpa = db_construct_qpa($qpa, 'AND g.group_id = i.group_id 
ORDER BY ts_rank(vectors, q) DESC, group_name');
+               return $qpa;
        }
 
 }
diff --git a/src/common/search/SkillSearchQuery.class.php 
b/src/common/search/SkillSearchQuery.class.php
index e2ae921..5b01da2 100644
--- a/src/common/search/SkillSearchQuery.class.php
+++ b/src/common/search/SkillSearchQuery.class.php
@@ -33,45 +33,22 @@ class SkillSearchQuery extends SearchQuery {
         * @return array query+params array
         */
        function getQuery() {
-
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $words = $this->getFTIwords();
-                       $qpa = db_construct_qpa($qpa,
-                                                '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 ',
-                                                array ($words)) ;
-                       if (count ($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        $this->getOperator()) ;
-                               $qpa = db_construct_qpa($qpa,
-                                                        ' ((') ;
-                               $qpa = $this->addMatchCondition ($qpa, 
'skills_data.title') ;
-                               $qpa = db_construct_qpa($qpa,
-                                                        ') OR (') ;
-                               $qpa = $this->addMatchCondition ($qpa, 
'skills_data.keywords') ;
-                               $qpa = db_construct_qpa($qpa,
-                                                        '))') ;
-                       }
-                       $qpa = db_construct_qpa($qpa,
-                                                ')') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                'AND 
skills_data.skills_data_id = skills_data_idx.skills_data_id ') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                'AND 
(skills_data.user_id=users.user_id) AND 
(skills_data.type=skills_data_types.type_id) ') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                'ORDER BY ts_rank(vectors, q) 
DESC, finish DESC') ;
-               } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT * FROM skills_data, 
users, skills_data_types WHERE ((') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'skills_data.title') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ') OR (') ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'skills_data.keywords') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ')) AND 
(skills_data.user_id=users.user_id) AND 
(skills_data.type=skills_data_types.type_id) ORDER BY finish DESC') ;
+               $words = $this->getFTIwords();
+               $qpa = db_construct_qpa(false, '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 ',
+                                               array($words));
+               if (count ($this->phrases)) {
+                       $qpa = db_construct_qpa($qpa, $this->getOperator());
+                       $qpa = db_construct_qpa($qpa, ' ((');
+                       $qpa = $this->addMatchCondition($qpa, 
'skills_data.title');
+                       $qpa = db_construct_qpa($qpa, ') OR (');
+                       $qpa = $this->addMatchCondition($qpa, 
'skills_data.keywords');
+                       $qpa = db_construct_qpa($qpa, '))');
                }
-               return $qpa ;
+               $qpa = db_construct_qpa($qpa, ')');
+               $qpa = db_construct_qpa($qpa, 'AND skills_data.skills_data_id = 
skills_data_idx.skills_data_id ');
+               $qpa = db_construct_qpa($qpa, 'AND 
(skills_data.user_id=users.user_id) AND 
(skills_data.type=skills_data_types.type_id) ');
+               $qpa = db_construct_qpa($qpa, 'ORDER BY ts_rank(vectors, q) 
DESC, finish DESC');
+               return $qpa;
        }
 }
 
diff --git a/src/common/search/TasksSearchQuery.class.php 
b/src/common/search/TasksSearchQuery.class.php
index aec7cb0..6019883 100644
--- a/src/common/search/TasksSearchQuery.class.php
+++ b/src/common/search/TasksSearchQuery.class.php
@@ -44,12 +44,12 @@ class TasksSearchQuery extends SearchQuery {
        /**
         * Constructor
         *
-        * @param string        $words words we are searching for
-        * @param int           $offset offset
-        * @param bool          $isExact if we want to search for all the words 
or if only one matching the query is sufficient
-        * @param int           $groupId group id
-        * @param string        $sections sections to search in
-        * @param bool          $showNonPublic flag if private sections are 
searched too
+        * @param       string  $words          words we are searching for
+        * @param       int     $offset         offset
+        * @param       bool    $isExact        if we want to search for all 
the words or if only one matching the query is sufficient
+        * @param       int     $groupId        group id
+        * @param       string  $sections       sections to search in
+        * @param       bool    $showNonPublic  flag if private sections are 
searched too
         */
        function __construct($words, $offset, $isExact, $groupId, 
$sections=SEARCH__ALL_SECTIONS, $showNonPublic=false) {
                $this->groupId = $groupId;
@@ -63,65 +63,36 @@ class TasksSearchQuery extends SearchQuery {
        /**
         * getQuery - get the query built to get the search results
         *
-        * @return array query+params array
+        * @return      array   query+params array
         */
        function getQuery() {
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $words = $this->getFTIwords();
-
-                       if (count($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'SELECT x.* FROM 
(SELECT project_task.project_task_id, project_task.group_project_id, 
project_task.summary, project_task.percent_complete, project_task.start_date, 
project_task.end_date, users.realname, project_group_list.project_name, 
project_task.summary||$1||project_task.details||$1||coalesce(ff_string_agg(project_messages.body),
 $1) as full_string_agg, project_task_idx.vectors FROM project_task LEFT OUTER 
JOIN project_messages USING (project_task_id), users, project_group_list, 
project_task_idx WHERE users.user_id = project_task.created_by AND 
project_task.group_project_id = project_group_list.group_project_id AND 
project_group_list.group_id = $2 ',
-                                                        array 
($this->field_separator, $this->groupId)) ;
-
-                               if ($this->sections != SEARCH__ALL_SECTIONS) {
-                                       $qpa = db_construct_qpa($qpa,
-                                                                'AND 
project_group_list.group_project_id = ANY ($1) ',
-                                                                array 
(db_int_array_to_any_clause ($this->sections))) ;
-                               }
-
-                               $qpa = db_construct_qpa($qpa,
-                                                        ' AND 
project_task.project_task_id = project_task_idx.project_task_id AND vectors @@ 
to_tsquery($1) GROUP BY project_task.project_task_id, 
project_task.group_project_id, project_task.summary, 
project_task.percent_complete, project_task.start_date, project_task.end_date, 
users.realname, project_group_list.project_name, project_task.details, vectors) 
AS x WHERE ',
-                                                        array ($words)) ;
-                               $qpa = $this->addMatchCondition ($qpa, 
'full_string_agg') ;
-                               $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY ts_rank(vectors, 
to_tsquery($1)) DESC',
-                                                array($words)) ;
-                       } else {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'SELECT 
project_task.project_task_id, project_task.group_project_id, 
project_task.summary, project_task.percent_complete, project_task.start_date, 
project_task.end_date, users.realname, project_group_list.project_name, 
project_task_idx.vectors FROM project_task, users, project_group_list, 
project_task_idx WHERE users.user_id = project_task.created_by AND 
project_task.group_project_id = project_group_list.group_project_id AND 
project_group_list.group_id = $1 ',
-                                                        array 
($this->groupId)) ;
-
-                               if ($this->sections != SEARCH__ALL_SECTIONS) {
-                                       $qpa = db_construct_qpa($qpa,
-                                                                'AND 
project_group_list.group_project_id = ANY ($1) ',
-                                                                array 
(db_int_array_to_any_clause ($this->sections))) ;
-                               }
-
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND 
project_task.project_task_id = project_task_idx.project_task_id AND vectors @@ 
to_tsquery($1) ORDER BY ts_rank(vectors, to_tsquery($1)) DESC',
-                                                        array ($words)) ;
+               $words = $this->getFTIwords();
+
+               if (count($this->phrases)) {
+                       $qpa = db_construct_qpa(false, 'SELECT x.* FROM (SELECT 
project_task.project_task_id, project_task.group_project_id, 
project_task.summary, project_task.percent_complete, project_task.start_date, 
project_task.end_date, users.realname, project_group_list.project_name, 
project_task.summary||$1||project_task.details||$1||coalesce(ff_string_agg(project_messages.body),
 $1) as full_string_agg, project_task_idx.vectors FROM project_task LEFT OUTER 
JOIN project_messages USING (project_task_id), users, project_group_list, 
project_task_idx WHERE users.user_id = project_task.created_by AND 
project_task.group_project_id = project_group_list.group_project_id AND 
project_group_list.group_id = $2 ',
+                                                       
array($this->field_separator, $this->groupId));
+
+                       if ($this->sections != SEARCH__ALL_SECTIONS) {
+                               $qpa = db_construct_qpa($qpa, 'AND 
project_group_list.group_project_id = ANY ($1) ',
+                                                               
array(db_int_array_to_any_clause ($this->sections)));
                        }
 
+                       $qpa = db_construct_qpa($qpa, ' AND 
project_task.project_task_id = project_task_idx.project_task_id AND vectors @@ 
to_tsquery($1) GROUP BY project_task.project_task_id, 
project_task.group_project_id, project_task.summary, 
project_task.percent_complete, project_task.start_date, project_task.end_date, 
users.realname, project_group_list.project_name, project_task.details, vectors) 
AS x WHERE ',
+                                                       array($words));
+                       $qpa = $this->addMatchCondition($qpa, 
'full_string_agg');
+                       $qpa = db_construct_qpa($qpa, ' ORDER BY 
ts_rank(vectors, to_tsquery($1)) DESC',
+                                               array($words));
                } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT x.* FROM (SELECT 
project_task.project_task_id, project_task.group_project_id, 
project_task.summary, project_task.percent_complete, project_task.start_date, 
project_task.end_date, users.realname, project_group_list.project_name, 
project_task.summary||$1||project_task.details||$1||coalesce(ff_string_agg(project_messages.body),
 $1) as full_string_agg FROM project_task LEFT OUTER JOIN project_messages 
USING (project_task_id), users, project_group_list WHERE users.user_id = 
project_task.created_by AND project_task.group_project_id = 
project_group_list.group_project_id AND project_group_list.group_id = $2 ',
-                                                array ($this->field_separator, 
$this->groupId)) ;
+                       $qpa = db_construct_qpa(false, 'SELECT 
project_task.project_task_id, project_task.group_project_id, 
project_task.summary, project_task.percent_complete, project_task.start_date, 
project_task.end_date, users.realname, project_group_list.project_name, 
project_task_idx.vectors FROM project_task, users, project_group_list, 
project_task_idx WHERE users.user_id = project_task.created_by AND 
project_task.group_project_id = project_group_list.group_project_id AND 
project_group_list.group_id = $1 ',
+                                                       array($this->groupId));
 
                        if ($this->sections != SEARCH__ALL_SECTIONS) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND 
project_group_list.group_project_id = ANY ($1) ',
-                                                        array 
(db_int_array_to_any_clause ($this->sections))) ;
+                               $qpa = db_construct_qpa($qpa, 'AND 
project_group_list.group_project_id = ANY ($1) ',
+                                                               
array(db_int_array_to_any_clause ($this->sections)));
                        }
 
-                       $qpa = db_construct_qpa($qpa,
-                                                'GROUP BY 
project_task.project_task_id, project_task.group_project_id, 
project_task.summary, project_task.percent_complete, project_task.start_date, 
project_task.end_date, users.realname, project_group_list.project_name, 
project_task.details) AS x WHERE ',
-                                                array ()) ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'full_string_agg') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY project_task_id') ;
+                       $qpa = db_construct_qpa($qpa, 'AND 
project_task.project_task_id = project_task_idx.project_task_id AND vectors @@ 
to_tsquery($1) ORDER BY ts_rank(vectors, to_tsquery($1)) DESC',
+                                                       array($words));
                }
 
                return $qpa ;
@@ -130,17 +101,16 @@ class TasksSearchQuery extends SearchQuery {
        /**
         * getSections - returns the list of available subprojects
         *
-        * @param $groupId int group id
-        * @param $showNonPublic boolean if we should consider non public 
sections
-        * @return array
+        * @param       int     $groupId        group id
+        * @param       boolean $showNonPublic  if we should consider non 
public sections
+        * @return      array
         */
-       static function getSections($groupId, $showNonPublic=false) {
+       static function getSections($groupId, $showNonPublic = false) {
                $sql = 'SELECT group_project_id, project_name FROM 
project_group_list WHERE group_id=$1' ;
                $sql .= ' ORDER BY project_name';
 
                $sections = array();
-               $res = db_query_params ($sql,
-                                       array ($groupId));
+               $res = db_query_params($sql, array($groupId));
                while($data = db_fetch_array($res)) {
                        if 
(forge_check_perm('pm',$data['group_project_id'],'read')) {
                                $sections[$data['group_project_id']] = 
$data['project_name'];
diff --git a/src/common/search/TrackersSearchQuery.class.php 
b/src/common/search/TrackersSearchQuery.class.php
index cdecdda..3608e17 100644
--- a/src/common/search/TrackersSearchQuery.class.php
+++ b/src/common/search/TrackersSearchQuery.class.php
@@ -44,12 +44,12 @@ class TrackersSearchQuery extends SearchQuery {
        /**
         * Constructor
         *
-        * @param string        $words words we are searching for
-        * @param int           $offset offset
-        * @param bool          $isExact if we want to search for all the words 
or if only one matching the query is sufficient
-        * @param int           $groupId group id
-        * @param string        $sections sections to search in
-        * @param bool          $showNonPublic flag if private sections are 
searched too
+        * @param       string  $words          words we are searching for
+        * @param       int     $offset         offset
+        * @param       bool    $isExact        if we want to search for all 
the words or if only one matching the query is sufficient
+        * @param       int     $groupId        group id
+        * @param       string  $sections       sections to search in
+        * @param       bool    $showNonPublic  flag if private sections are 
searched too
         */
        function __construct($words, $offset, $isExact, $groupId, 
$sections=SEARCH__ALL_SECTIONS, $showNonPublic=false) {
                $this->groupId = $groupId;
@@ -66,80 +66,49 @@ class TrackersSearchQuery extends SearchQuery {
         * @return array query+params array
         */
        function getQuery() {
-               $qpa = db_construct_qpa() ;
-
-               if (forge_get_config('use_fti')) {
-                       $words = $this->getFTIwords();
-
-                       if (count($this->phrases)) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'SELECT x.* FROM 
(SELECT artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, 
artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body),
 $1) as full_string_agg, artifact_idx.vectors FROM artifact LEFT OUTER JOIN 
artifact_message USING (artifact_id), users, artifact_group_list, artifact_idx 
WHERE users.user_id = artifact.submitted_by AND artifact.group_artifact_id = 
artifact_group_list.group_artifact_id AND artifact_group_list.group_id = $2 ',
-                                                        array 
($this->field_separator, $this->groupId)) ;
-
-                               if ($this->sections != SEARCH__ALL_SECTIONS) {
-                                       $qpa = db_construct_qpa($qpa,
-                                                                'AND 
artifact_group_list.group_artifact_id = ANY ($1) ',
-                                                                array 
(db_int_array_to_any_clause ($this->sections))) ;
-                               }
-
-                               $qpa = db_construct_qpa($qpa,
-                                                        ' AND 
artifact.artifact_id = artifact_idx.artifact_id AND vectors @@ to_tsquery($1) 
GROUP BY artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, artifact.details, vectors) AS x WHERE ',
-                                                        array ($words)) ;
-                               $qpa = $this->addMatchCondition ($qpa, 
'full_string_agg') ;
-                               $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY ts_rank(vectors, 
to_tsquery($1)) DESC',
-                                                array($words)) ;
-                       } else {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'SELECT 
artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, artifact_idx.vectors FROM artifact, users, 
artifact_group_list, artifact_idx WHERE users.user_id = artifact.submitted_by 
AND artifact.group_artifact_id = artifact_group_list.group_artifact_id AND 
artifact_group_list.group_id = $1 ',
-                                                        array 
($this->groupId)) ;
-
-                               if ($this->sections != SEARCH__ALL_SECTIONS) {
-                                       $qpa = db_construct_qpa($qpa,
-                                                                'AND 
artifact_group_list.group_artifact_id = ANY ($1) ',
-                                                                array 
(db_int_array_to_any_clause ($this->sections))) ;
-                               }
-
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND 
artifact.artifact_id = artifact_idx.artifact_id AND vectors @@ to_tsquery($1) 
ORDER BY ts_rank(vectors, to_tsquery($1)) DESC',
-                                                        array ($words)) ;
+               $words = $this->getFTIwords();
+
+               if (count($this->phrases)) {
+                       $qpa = db_construct_qpa(false, 'SELECT x.* FROM (SELECT 
artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, 
artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body),
 $1) as full_string_agg, artifact_idx.vectors FROM artifact LEFT OUTER JOIN 
artifact_message USING (artifact_id), users, artifact_group_list, artifact_idx 
WHERE users.user_id = artifact.submitted_by AND artifact.group_artifact_id = 
artifact_group_list.group_artifact_id AND artifact_group_list.group_id = $2 ',
+                                                       
array($this->field_separator, $this->groupId));
+
+                       if ($this->sections != SEARCH__ALL_SECTIONS) {
+                               $qpa = db_construct_qpa($qpa, 'AND 
artifact_group_list.group_artifact_id = ANY ($1) ',
+                                                               array 
(db_int_array_to_any_clause ($this->sections)));
                        }
 
+                       $qpa = db_construct_qpa($qpa, ' AND 
artifact.artifact_id = artifact_idx.artifact_id AND vectors @@ to_tsquery($1) 
GROUP BY artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, artifact.details, vectors) AS x WHERE ',
+                                                       array($words));
+                       $qpa = $this->addMatchCondition($qpa, 
'full_string_agg');
+                       $qpa = db_construct_qpa($qpa, ' ORDER BY 
ts_rank(vectors, to_tsquery($1)) DESC',
+                                               array($words));
                } else {
-                       $qpa = db_construct_qpa($qpa,
-                                                'SELECT x.* FROM (SELECT 
artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, 
artifact.summary||$1||artifact.details||$1||coalesce(ff_string_agg(artifact_message.body),
 $1) as full_string_agg FROM artifact LEFT OUTER JOIN artifact_message USING 
(artifact_id), users, artifact_group_list WHERE users.user_id = 
artifact.submitted_by AND artifact.group_artifact_id = 
artifact_group_list.group_artifact_id AND artifact_group_list.group_id = $2 ',
-                                                array ($this->field_separator, 
$this->groupId)) ;
+                       $qpa = db_construct_qpa(false, 'SELECT 
artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, artifact_idx.vectors FROM artifact, users, 
artifact_group_list, artifact_idx WHERE users.user_id = artifact.submitted_by 
AND artifact.group_artifact_id = artifact_group_list.group_artifact_id AND 
artifact_group_list.group_id = $1 ',
+                                                       array($this->groupId));
 
                        if ($this->sections != SEARCH__ALL_SECTIONS) {
-                               $qpa = db_construct_qpa($qpa,
-                                                        'AND 
artifact_group_list.group_artifact_id = ANY ($1) ',
-                                                        array 
(db_int_array_to_any_clause ($this->sections))) ;
+                               $qpa = db_construct_qpa($qpa, 'AND 
artifact_group_list.group_artifact_id = ANY ($1) ',
+                                                               
array(db_int_array_to_any_clause ($this->sections)));
                        }
 
-                       $qpa = db_construct_qpa($qpa,
-                                                'GROUP BY 
artifact.artifact_id, artifact.group_artifact_id, artifact.summary, 
artifact.open_date, users.realname, artifact.details) AS x WHERE ',
-                                                array ()) ;
-                       $qpa = $this->addIlikeCondition ($qpa, 
'full_string_agg') ;
-                       $qpa = db_construct_qpa($qpa,
-                                                ' ORDER BY artifact_id') ;
+                       $qpa = db_construct_qpa($qpa, 'AND artifact.artifact_id 
= artifact_idx.artifact_id AND vectors @@ to_tsquery($1) ORDER BY 
ts_rank(vectors, to_tsquery($1)) DESC',
+                                                       array($words));
                }
-
-               return $qpa ;
+               return $qpa;
        }
 
        /**
         * getSections - returns the list of available trackers
         *
-        * @param $groupId int group id
-        * @param $showNonPublic boolean if we should consider non public 
sections
+        * @param int           $groupId        group id
+        * @param boolean       $showNonPublic  if we should consider non 
public sections
         * @return array
         */
-       static function getSections($groupId, $showNonPublic=false) {
+       static function getSections($groupId, $showNonPublic = false) {
                $sql = 'SELECT group_artifact_id, name FROM artifact_group_list 
WHERE group_id = $1';
                $sql .= ' ORDER BY name';
 
-               $res = db_query_params ($sql,
-                                       array ($groupId));
+               $res = db_query_params ($sql, array($groupId));
                $sections = array();
                while($data = db_fetch_array($res)) {
                        if 
(forge_check_perm('tracker',$data['group_artifact_id'],'read')) {
diff --git a/src/etc/config.ini.d/defaults.ini 
b/src/etc/config.ini.d/defaults.ini
index 3975306..4377c9a 100644
--- a/src/etc/config.ini.d/defaults.ini
+++ b/src/etc/config.ini.d/defaults.ini
@@ -57,7 +57,6 @@ use_activity = yes
 use_docman = yes
 use_forum = yes
 use_frs = yes
-use_fti = yes
 use_ftp = yes
 use_ftp_uploads = no
 use_gateways = yes
diff --git 
a/src/www/search/include/renderers/FullProjectHtmlSearchRenderer.class.php 
b/src/www/search/include/renderers/FullProjectHtmlSearchRenderer.class.php
index 89857ac..d14e6b0 100644
--- a/src/www/search/include/renderers/FullProjectHtmlSearchRenderer.class.php
+++ b/src/www/search/include/renderers/FullProjectHtmlSearchRenderer.class.php
@@ -87,7 +87,7 @@ class FullProjectHtmlSearchRenderer extends 
HtmlGroupSearchRenderer {
                global $HTML;
                if (!$this->words) {
                        echo $HTML->error_msg(_('Error')._(': ')._('Please 
enter a term to search for'));
-               } elseif (!forge_get_config('use_fti') && (strlen($this->words) 
< 3)) {
+               } elseif (strlen($this->words) < 3) {
                        echo $HTML->error_msg(_('Error')._(': ')._('Search must 
be at least three characters'));
                } else {
                        echo $this->getResult();
diff --git 
a/src/www/search/include/renderers/ProjectHtmlSearchRenderer.class.php 
b/src/www/search/include/renderers/ProjectHtmlSearchRenderer.class.php
index 3fd24b1..0fd7bdd 100644
--- a/src/www/search/include/renderers/ProjectHtmlSearchRenderer.class.php
+++ b/src/www/search/include/renderers/ProjectHtmlSearchRenderer.class.php
@@ -94,12 +94,8 @@ class ProjectHtmlSearchRenderer extends HtmlSearchRenderer {
                $project_name = $this->getResultId('unix_group_name');
                $project_id = $this->getResultId('group_id');
 
-               if (forge_get_config('use_fti')) {
-                       // If FTI is being used, the project name returned by 
the query will be "<b>projectname</b>", so
-                       // we remove the HTML code (otherwise we'd get an error)
-                       $project_name = str_replace('<b>', '', $project_name);
-                       $project_name = str_replace('</b>', '', $project_name);
-               }
+               $project_name = str_replace('<b>', '', $project_name);
+               $project_name = str_replace('</b>', '', $project_name);
 
                if ($this->getResultId('type') == 2) {
                        session_redirect('/foundry/'.$project_name.'/');

-----------------------------------------------------------------------

Summary of changes:
 src/CHANGES                                        |   1 +
 src/bin/migrate-to-ini-files.sh                    |   1 -
 src/common/search/ArtifactSearchQuery.class.php    |  47 +++------
 src/common/search/DocsSearchQuery.class.php        |  45 ++-------
 .../search/ExportProjectSearchQuery.class.php      |  75 ++++----------
 src/common/search/ForumSearchQuery.class.php       |  52 +++-------
 src/common/search/ForumsSearchQuery.class.php      |  90 ++++++-----------
 src/common/search/FrsSearchQuery.class.php         | 108 ++++++---------------
 src/common/search/NewsSearchQuery.class.php        |  60 ++++--------
 src/common/search/PeopleSearchQuery.class.php      |  47 +++------
 src/common/search/ProjectSearchQuery.class.php     |  54 +++--------
 src/common/search/SkillSearchQuery.class.php       |  53 +++-------
 src/common/search/TasksSearchQuery.class.php       |  94 ++++++------------
 src/common/search/TrackersSearchQuery.class.php    |  93 ++++++------------
 src/etc/config.ini.d/defaults.ini                  |   1 -
 .../FullProjectHtmlSearchRenderer.class.php        |   2 +-
 .../renderers/ProjectHtmlSearchRenderer.class.php  |   8 +-
 17 files changed, 257 insertions(+), 574 deletions(-)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to