summaryrefslogtreecommitdiffstats
path: root/lib/plugins/acts_as_searchable
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-13 09:20:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-13 09:20:11 +0000
commit628d05629b734371d3e850a95dadf0be30c5ef20 (patch)
tree58a9da4e8266ee45a0800996f9228e9d2a45108c /lib/plugins/acts_as_searchable
parenta74d55edd99a4bae23e7d9cbd76136ffa7707ccf (diff)
downloadredmine-628d05629b734371d3e850a95dadf0be30c5ef20.tar.gz
redmine-628d05629b734371d3e850a95dadf0be30c5ef20.zip
Role-based issue custom field visibility (#5037).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12012 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/plugins/acts_as_searchable')
-rw-r--r--lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb11
1 files changed, 6 insertions, 5 deletions
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 5a1f36752..3e91c72dc 100644
--- a/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb
+++ b/lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb
@@ -81,12 +81,13 @@ module Redmine
token_clauses = columns.collect {|column| "(LOWER(#{column}) LIKE ?)"}
if !options[:titles_only] && searchable_options[:search_custom_fields]
- searchable_custom_field_ids = CustomField.where(:type => "#{self.name}CustomField", :searchable => true).pluck(:id)
- if searchable_custom_field_ids.any?
- custom_field_sql = "#{table_name}.id IN (SELECT customized_id FROM #{CustomValue.table_name}" +
+ searchable_custom_fields = CustomField.where(:type => "#{self.name}CustomField", :searchable => true)
+ searchable_custom_fields.each do |field|
+ sql = "#{table_name}.id IN (SELECT customized_id FROM #{CustomValue.table_name}" +
" WHERE customized_type='#{self.name}' AND customized_id=#{table_name}.id AND LOWER(value) LIKE ?" +
- " AND #{CustomValue.table_name}.custom_field_id IN (#{searchable_custom_field_ids.join(',')}))"
- token_clauses << custom_field_sql
+ " AND #{CustomValue.table_name}.custom_field_id = #{field.id})" +
+ " AND #{field.visibility_by_project_condition(searchable_options[:project_key], user)}"
+ token_clauses << sql
end
end