Project

General

Profile

Patch #4800 ยป acts_as_searchable_registration_and_search_by_global_modules.patch

Andrew Chaika, 2010-02-11 09:19

View differences:

app/controllers/search_controller.rb (working copy)
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')
vendor/plugins/acts_as_searchable/lib/acts_as_searchable.rb (working copy)
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
......
searchable_options[:search_custom_fields] = !reflect_on_association(:custom_values).nil?
send :include, Redmine::Acts::Searchable::InstanceMethods
Redmine::Acts::Searchable.register(self)
end
end
......
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
    (1-1/1)