diff options
Diffstat (limited to 'app/models/issue_query.rb')
-rw-r--r-- | app/models/issue_query.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb index 9f541cc54..1c60c6b61 100644 --- a/app/models/issue_query.rb +++ b/app/models/issue_query.rb @@ -272,6 +272,8 @@ class IssueQuery < Query add_available_filter "issue_id", :type => :integer, :label => :label_issue + add_available_filter "any_searchable", :type => :search + Tracker.disabled_core_fields(trackers).each do |field| delete_available_filter field end @@ -774,6 +776,33 @@ class IssueQuery < Query sql_for_field(field, operator, value, Project.table_name, "status") end + def sql_for_any_searchable_field(field, operator, value) + question = value.first + + # Fetch search results only from the selected and visible (sub-)projects + project_scope = Project.allowed_to(:view_issues) + if project + projects = project_scope.where(project_statement) + elsif has_filter?('project_id') + projects = project_scope.where( + sql_for_field('project_id', operator_for('project_id'), values_for('project_id'), Project.table_name, 'id') + ) + else + projects = nil + end + + fetcher = Redmine::Search::Fetcher.new( + question, User.current, ['issue'], projects, attachments: '0' + ) + ids = fetcher.result_ids.map(&:last) + if ids.present? + sw = operator == '!~' ? 'NOT' : '' + "#{Issue.table_name}.id #{sw} IN (#{ids.join(',')})" + else + '1=0' + end + end + def find_assigned_to_id_filter_values(values) Principal.visible.where(:id => values).map {|p| [p.name, p.id.to_s]} end |