Index: trip_search.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/trip_search/trip_search.module,v retrieving revision 1.37 diff -u -r1.37 trip_search.module --- trip_search.module 27 Sep 2005 19:27:11 -0000 1.37 +++ trip_search.module 27 Oct 2005 17:35:57 -0000 @@ -826,6 +826,7 @@ $query->delimiter_right = '%%'; $query->wildcard = '%%'; } + $new_wheres = array(); // Generate SQL snippet for required words. if($keys->require) { $keys->require = str_replace('*', $query->wildcard, $keys->require); @@ -833,7 +834,7 @@ foreach ($query->fields as $field) { $requires[] = $field . " " . $query->like . " '" . $query->delimiter_left . $require . $query->delimiter_right . "'"; } - $query->wheres[] = '(' . implode(' OR ', $requires) . ')'; + $new_wheres[] = '(' . implode(' OR ', $requires) . ')'; array_splice ($requires, 0); } } @@ -848,7 +849,7 @@ $wheres[] = implode(' OR ', $ors); array_splice ($ors, 0); } - $query->wheres[] = '((' . implode(') OR (', $wheres) . '))' ; + $new_wheres[] = '((' . implode(') OR (', $wheres) . '))' ; array_splice ($wheres, 0); } } @@ -860,10 +861,17 @@ $nullcheck = "(ISNULL($field) OR "; $excludes[] = $nullcheck. $field . " " . $query->not_like . " '" . $query->delimiter_left . $exclude . $query->delimiter_right . "')"; } - $query->wheres[] = '(' . implode(' AND ', $excludes) . ')'; + $new_wheres[] = '(' . implode(' AND ', $excludes) . ')'; array_splice ($excludes, 0); } } + // Add new conditions and fulltext search, if any + if ($query->match) { + $query->wheres[] = $new_wheres ? ('('. $query->match .' OR ('. implode(' AND ', $new_wheres) .'))') : $query->match; + } + else if ($new_wheres) { + $query->wheres = $query->wheres ? array_merge($query->wheres, $new_wheres) : $new_wheres; + } return $query; } @@ -966,7 +974,7 @@ $query->selects = 'n.title,n.type,nr.body,n.sticky'; if (variable_get('trip_search_type', 'basic') == 'mysql_full') { if ($search_string = trip_search_translate_keys($keys, 'mysql_full')) { - $query->wheres[] = 'MATCH (n.title,nr.body) AGAINST (\'' . $search_string . '\' IN BOOLEAN MODE)'; + $query->match = 'MATCH (n.title,nr.body) AGAINST (\'' . $search_string . '\' IN BOOLEAN MODE)'; } } else { @@ -1043,7 +1051,7 @@ } $query->order_bys[] = 'n.sticky DESC'; $query->order_bys[] = 'n.created DESC'; - if ($query->fields) { + if ($query->fields || $query->match) { $query = trip_search_expand_query($query, $keys); } switch ($op) {