diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-30 08:52:39 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-30 08:52:39 +0000 |
commit | ebe10fa6452de7ea6c5759bfd9c7b439091b54cd (patch) | |
tree | 30eb8f2f6fb758c41530597814c2e9d048fc75c8 /app/controllers/projects_controller.rb | |
parent | 833c5035a697858cfc390b08e5db204ba30831d9 (diff) | |
download | redmine-ebe10fa6452de7ea6c5759bfd9c7b439091b54cd.tar.gz redmine-ebe10fa6452de7ea6c5759bfd9c7b439091b54cd.zip |
Added a quick search form in page header. Search functionality moved to a dedicated controller.
When used:
* outside of a project: searches projects
* inside a project: searches issues, changesets, news, documents and wiki pages of the current project
If an issue number is given, user is redirected to the corresponding issue.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@489 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r-- | app/controllers/projects_controller.rb | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a47126052..ffc71ce1f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -612,33 +612,7 @@ class ProjectsController < ApplicationController render :template => "projects/gantt.rhtml" end end - - def search - @question = params[:q] || "" - @question.strip! - @all_words = params[:all_words] || (params[:submit] ? false : true) - @scope = params[:scope] || (params[:submit] ? [] : %w(issues changesets news documents wiki) ) - # tokens must be at least 3 character long - @tokens = @question.split.uniq.select {|w| w.length > 2 } - if !@tokens.empty? - # no more than 5 tokens to search for - @tokens.slice! 5..-1 if @tokens.size > 5 - # strings used in sql like statement - like_tokens = @tokens.collect {|w| "%#{w.downcase}%"} - operator = @all_words ? " AND " : " OR " - limit = 10 - @results = [] - @results += @project.issues.find(:all, :limit => limit, :include => :author, :conditions => [ (["(LOWER(subject) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort] ) if @scope.include? 'issues' - @results += @project.news.find(:all, :limit => limit, :conditions => [ (["(LOWER(title) like ? OR LOWER(description) like ?)"] * like_tokens.size).join(operator), * (like_tokens * 2).sort], :include => :author ) if @scope.include? 'news' - @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') - @question = @tokens.join(" ") - else - @question = "" - end - end - + def feeds @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)] @key = logged_in_user.get_or_create_rss_key.value if logged_in_user |