Index: app/controllers/search_controller.rb =================================================================== --- app/controllers/search_controller.rb (revision 3409) +++ app/controllers/search_controller.rb (working copy) @@ -48,7 +48,7 @@ return end - @object_types = %w(issues news documents changesets wiki_pages messages projects) + @object_types = Redmine::Acts::Searchable.available_search_types if projects_to_search.is_a? Project # don't search projects @object_types.delete('projects') Index: vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb =================================================================== --- vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb (revision 3409) +++ vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb (working copy) @@ -18,6 +18,17 @@ module Redmine module Acts module Searchable + + mattr_accessor :available_search_types + @@available_search_types = [] + class << self + # Registers a search type + def register(search_type) + search_type = search_type.to_s + @@available_search_types << search_type.pluralize.underscore unless @@available_search_types.include?(search_type) + end + end + def self.included(base) base.extend ClassMethods end @@ -52,6 +63,7 @@ searchable_options[:search_custom_fields] = !reflect_on_association(:custom_values).nil? send :include, Redmine::Acts::Searchable::InstanceMethods + Redmine::Acts::Searchable.register(self) end end @@ -100,9 +112,11 @@ find_options[:conditions] = [sql, * (tokens * token_clauses.size).sort] project_conditions = [] - project_conditions << (searchable_options[:permission].nil? ? Project.visible_by(User.current) : + if searchable_options[:project_key] != "" + project_conditions << (searchable_options[:permission].nil? ? Project.visible_by(User.current) : Project.allowed_to_condition(User.current, searchable_options[:permission])) - project_conditions << "#{searchable_options[:project_key]} IN (#{projects.collect(&:id).join(',')})" unless projects.nil? + project_conditions << "#{searchable_options[:project_key]} IN (#{projects.collect(&:id).join(',')})" unless projects.nil? + end results = [] results_count = 0