summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-13 19:38:06 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-13 19:38:06 +0000
commit980b6db5c0227a9376392962e706aecf3fc1c066 (patch)
tree0359c6a6c716f2e549abd6baa950b14ffc80e0bc /app
parent919d0a68c39b14ac8970ad889e6dc9345fade7f0 (diff)
downloadredmine-980b6db5c0227a9376392962e706aecf3fc1c066.tar.gz
redmine-980b6db5c0227a9376392962e706aecf3fc1c066.zip
Adds "me" to user custom fields filters (#9923).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8638 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/query.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index 1286fe86b..9846acd63 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -688,6 +688,12 @@ class Query < ActiveRecord::Base
def sql_for_custom_field(field, operator, value, custom_field_id)
db_table = CustomValue.table_name
db_field = 'value'
+ filter = @available_filters[field]
+ if filter && filter[:format] == 'user'
+ if value.delete('me')
+ value.push User.current.id.to_s
+ end
+ end
"#{Issue.table_name}.id IN (SELECT #{Issue.table_name}.id FROM #{Issue.table_name} LEFT OUTER JOIN #{db_table} ON #{db_table}.customized_type='Issue' AND #{db_table}.customized_id=#{Issue.table_name}.id AND #{db_table}.custom_field_id=#{custom_field_id} WHERE " +
sql_for_field(field, operator, value, db_table, db_field, true) + ')'
end
@@ -816,11 +822,15 @@ class Query < ActiveRecord::Base
options = { :type => :float, :order => 20 }
when "user", "version"
next unless project
- options = { :type => :list_optional, :values => field.possible_values_options(project), :order => 20}
+ values = field.possible_values_options(project)
+ if User.current.logged? && field.field_format == 'user'
+ values.unshift ["<< #{l(:label_me)} >>", "me"]
+ end
+ options = { :type => :list_optional, :values => values, :order => 20}
else
options = { :type => :string, :order => 20 }
end
- @available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
+ @available_filters["cf_#{field.id}"] = options.merge({ :name => field.name, :format => field.field_format })
end
end