+
diff --git a/config/locales/en.yml b/config/locales/en.yml
index c7d13cc..86d9b50 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -930,6 +930,7 @@ en:
label_search_attachments_yes: Search attachment filenames and descriptions
label_search_attachments_no: Do not search attachments
label_search_attachments_only: Search attachments only
+ label_search_open_issues_only: Open issues only
button_login: Login
button_submit: Submit
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 26857d9..1c5fbf8 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -950,6 +950,7 @@ fr:
label_search_attachments_yes: Rechercher les noms et descriptions de fichiers
label_search_attachments_no: Ne pas rechercher les fichiers
label_search_attachments_only: Rechercher les fichiers uniquement
+ label_search_open_issues_only: Demandes ouvertes uniquement
button_login: Connexion
button_submit: Soumettre
diff --git a/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb b/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb
index 2ffe79e..86d954d 100644
--- a/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb
+++ b/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb
@@ -89,7 +89,7 @@ module Redmine
unless options[:attachments] == 'only'
r = fetch_ranks_and_ids(
- search_scope(user, projects).
+ search_scope(user, projects, options).
where(search_tokens_condition(columns, tokens, options[:all_words])),
options[:limit]
)
@@ -109,7 +109,7 @@ module Redmine
visibility = clauses.join(' OR ')
r |= fetch_ranks_and_ids(
- search_scope(user, projects).
+ search_scope(user, projects, options).
joins(:custom_values).
where(visibility).
where(search_tokens_condition(["#{CustomValue.table_name}.value"], tokens, options[:all_words])),
@@ -121,7 +121,7 @@ module Redmine
if !options[:titles_only] && searchable_options[:search_journals]
r |= fetch_ranks_and_ids(
- search_scope(user, projects).
+ search_scope(user, projects, options).
joins(:journals).
where("#{Journal.table_name}.private_notes = ? OR (#{Project.allowed_to_condition(user, :view_private_notes)})", false).
where(search_tokens_condition(["#{Journal.table_name}.notes"], tokens, options[:all_words])),
@@ -133,7 +133,7 @@ module Redmine
if searchable_options[:search_attachments] && (options[:titles_only] ? options[:attachments] == 'only' : options[:attachments] != '0')
r |= fetch_ranks_and_ids(
- search_scope(user, projects).
+ search_scope(user, projects, options).
joins(:attachments).
where(search_tokens_condition(["#{Attachment.table_name}.filename", "#{Attachment.table_name}.description"], tokens, options[:all_words])),
options[:limit]
@@ -180,7 +180,7 @@ module Redmine
private :fetch_ranks_and_ids
# Returns the search scope for user and projects
- def search_scope(user, projects)
+ def search_scope(user, projects, options={})
if projects.is_a?(Array) && projects.empty?
# no results
return none
@@ -188,7 +188,7 @@ module Redmine
scope = (searchable_options[:scope] || self)
if scope.is_a? Proc
- scope = scope.call
+ scope = scope.call(options)
end
if respond_to?(:visible) && !searchable_options.has_key?(:permission)
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb
index d57cc07..924c049 100644
--- a/test/functional/search_controller_test.rb
+++ b/test/functional/search_controller_test.rb
@@ -209,6 +209,15 @@ class SearchControllerTest < ActionController::TestCase
assert_equal 2, results.size
end
+ def test_search_open_issues
+ Issue.generate! :subject => 'search_open'
+ Issue.generate! :subject => 'search_open', :status_id => 5
+
+ get :index, :id => 1, :q => 'search_open', :open_issues => '1'
+ results = assigns(:results)
+ assert_equal 1, results.size
+ end
+
def test_search_all_words
# 'all words' is on by default
get :index, :id => 1, :q => 'recipe updating saving', :all_words => '1'