diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 241da0bd..eae38016 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -48,7 +48,7 @@ class SearchController < ApplicationController return end - @object_types = %w(issues news documents changesets wiki_pages messages projects) + @object_types = Redmine::Search.available_search_types.dup if projects_to_search.is_a? Project # don't search projects @object_types.delete('projects') diff --git a/lib/redmine.rb b/lib/redmine.rb index d9a1f406..09ee2f5c 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -1,6 +1,7 @@ require 'redmine/access_control' require 'redmine/menu_manager' require 'redmine/activity' +require 'redmine/search' require 'redmine/mime_type' require 'redmine/core_ext' require 'redmine/themes' @@ -178,6 +179,16 @@ Redmine::Activity.map do |activity| activity.register :time_entries, :default => false end +Redmine::Search.map do |search| + search.register :issues + search.register :news + search.register :documents + search.register :changesets + search.register :wiki_pages + search.register :messages + search.register :projects +end + Redmine::WikiFormatting.map do |format| format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper end diff --git a/lib/redmine/search.rb b/lib/redmine/search.rb index ed1f629e..153197ea 100644 --- a/lib/redmine/search.rb +++ b/lib/redmine/search.rb @@ -17,6 +17,23 @@ module Redmine module Search + + mattr_accessor :available_search_types + + @@available_search_types = [] + + class << self + def map(&block) + yield self + end + + # Registers a search provider + def register(search_type, options={}) + search_type = search_type.to_s + @@available_search_types << search_type unless @@available_search_types.include?(search_type) + end + end + module Controller def self.included(base) base.extend(ClassMethods)