diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-02-27 21:03:15 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-02-27 21:03:15 +0000 |
commit | 75324e48592fbe141a66ba7e5dbda8553bbd2db1 (patch) | |
tree | 5193ae090dfe3ac07c6e6cd2672813f7d89eee4b /app/controllers/projects_controller.rb | |
parent | 93f07c78d6bb53a4e3c71953211c8beb011155f4 (diff) | |
download | redmine-75324e48592fbe141a66ba7e5dbda8553bbd2db1.tar.gz redmine-75324e48592fbe141a66ba7e5dbda8553bbd2db1.zip |
added a simple search engine. left to do:
- full content search (only subject/titles for now)
- pagination
- results presentation improvement
git-svn-id: http://redmine.rubyforge.org/svn/trunk@279 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r-- | app/controllers/projects_controller.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ce2e39fac..ab1cb3e1b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -539,6 +539,18 @@ class ProjectsController < ApplicationController end
end
+ def search
+ @token = params[:token]
+ @scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) )
+
+ if @token and @token.length > 2
+ @results = []
+ @results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject like ?", "%#{@token}%"] ) if @scope.include? 'issues'
+ @results += @project.news.find(:all, :conditions => ["news.title like ?", "%#{@token}%"], :include => :author ) if @scope.include? 'news'
+ @results += @project.documents.find(:all, :conditions => ["title like ?", "%#{@token}%"] ) if @scope.include? 'documents'
+ end
+ end
+
private
# Find project of id params[:id]
# if not found, redirect to project list
|