summaryrefslogtreecommitdiffstats
path: root/lib
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
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')
-rw-r--r--lib/plugins/acts_as_searchable/lib/acts_as_searchable.rb11
-rw-r--r--lib/redmine/export/pdf.rb8
2 files changed, 10 insertions, 9 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
diff --git a/lib/redmine/export/pdf.rb b/lib/redmine/export/pdf.rb
index f720e662a..193319aa5 100644
--- a/lib/redmine/export/pdf.rb
+++ b/lib/redmine/export/pdf.rb
@@ -256,7 +256,7 @@ module Redmine
def fetch_row_values(issue, query, level)
query.inline_columns.collect do |column|
s = if column.is_a?(QueryCustomFieldColumn)
- cv = issue.custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
+ cv = issue.visible_custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
show_value(cv)
else
value = issue.send(column.name)
@@ -571,8 +571,8 @@ module Redmine
right << nil
end
- half = (issue.custom_field_values.size / 2.0).ceil
- issue.custom_field_values.each_with_index do |custom_value, i|
+ half = (issue.visible_custom_field_values.size / 2.0).ceil
+ issue.visible_custom_field_values.each_with_index do |custom_value, i|
(i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value)]
end
@@ -683,7 +683,7 @@ module Redmine
pdf.RDMCell(190,5, title)
pdf.Ln
pdf.SetFontStyle('I',8)
- details_to_strings(journal.details, true).each do |string|
+ details_to_strings(journal.visible_details, true).each do |string|
pdf.RDMMultiCell(190,5, "- " + string)
end
if journal.notes?