summaryrefslogtreecommitdiffstats
path: root/app/controllers/search_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-05-14 17:46:58 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-05-14 17:46:58 +0000
commit7b13b58a2f247bab702d00b2a061ce4844d66b68 (patch)
tree58f129b2d2bae1fce660f8d1d165d89eef9e9846 /app/controllers/search_controller.rb
parentb11dd1f2130d058ff9770f7747c3c5f5a71193a6 (diff)
downloadredmine-7b13b58a2f247bab702d00b2a061ce4844d66b68.tar.gz
redmine-7b13b58a2f247bab702d00b2a061ce4844d66b68.zip
Text search added on messages.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@533 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/search_controller.rb')
-rw-r--r--app/controllers/search_controller.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index c463e4a35..01c72f182 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -18,11 +18,14 @@
class SearchController < ApplicationController
layout 'base'
+ helper :messages
+ include MessagesHelper
+
def index
@question = params[:q] || ""
@question.strip!
@all_words = params[:all_words] || (params[:submit] ? false : true)
- @scope = params[:scope] || (params[:submit] ? [] : %w(projects issues changesets news documents wiki) )
+ @scope = params[:scope] || (params[:submit] ? [] : %w(projects issues changesets news documents wiki messages) )
# quick jump to an issue
if @scope.include?('issues') && @question.match(/^#?(\d+)$/) && Issue.find_by_id($1, :include => :project, :conditions => Project.visible_by(logged_in_user))
@@ -52,6 +55,9 @@ class SearchController < ApplicationController
@results += @project.documents.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'documents'
@results += @project.wiki.pages.find(:all, :limit => limit, :include => :content, :conditions => [ (["(LOWER(title) like ? OR LOWER(text) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @project.wiki && @scope.include?('wiki')
@results += @project.repository.changesets.find(:all, :limit => limit, :conditions => [ (["(LOWER(comments) like ?)"] * like_tokens.size).join(operator), * (like_tokens).sort] ) if @project.repository && @scope.include?('changesets')
+ Message.with_scope :find => {:conditions => ["#{Board.table_name}.project_id = ?", @project.id]} do
+ @results += Message.find(:all, :include => :board, :limit => limit, :conditions => [ (["(LOWER(subject) like ? OR LOWER(content) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'messages'
+ end
else
Project.with_scope(:find => {:conditions => Project.visible_by(logged_in_user)}) do
@results += Project.find(:all, :limit => limit, :conditions => [ (["(LOWER(name) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'projects'