summaryrefslogtreecommitdiffstats
path: root/app/models/query.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-10 18:46:29 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-10 18:46:29 +0000
commit109b42f4828c0966e771809afcfd99d545af3ca0 (patch)
tree48fde0459480cc5e94773a75406fc7ff4c1e79fa /app/models/query.rb
parent4c656fcffcfe43482d62065122f6029bba62090d (diff)
downloadredmine-109b42f4828c0966e771809afcfd99d545af3ca0.tar.gz
redmine-109b42f4828c0966e771809afcfd99d545af3ca0.zip
Added a "Member of Group" to the issues filter. #5869
This filter will check an issue's assigned to field for users in (or not in) specific groups. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4077 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/query.rb')
-rw-r--r--app/models/query.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/query.rb b/app/models/query.rb
index b1f784528..96e99ef94 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -195,6 +195,9 @@ class Query < ActiveRecord::Base
end
@available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
+
+ group_values = Group.all.collect {|g| [g.name, g.id] }
+ @available_filters["member_of_group"] = { :type => :list_optional, :order => 6, :values => group_values } unless group_values.empty?
if User.current.logged?
@available_filters["watcher_id"] = { :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] }
@@ -432,6 +435,22 @@ class Query < ActiveRecord::Base
db_field = 'user_id'
sql << "#{Issue.table_name}.id #{ operator == '=' ? 'IN' : 'NOT IN' } (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND "
sql << sql_for_field(field, '=', v, db_table, db_field) + ')'
+ elsif field == "member_of_group" # named field
+ if operator == '*' # Any group
+ groups = Group.all
+ members_of_groups = groups.collect(&:user_ids).flatten.compact.collect(&:to_s)
+ operator = '=' # Override the operator since we want to find by assigned_to
+ elsif operator == "!*"
+ groups = Group.all
+ members_of_groups = groups.collect(&:user_ids).flatten.compact.collect(&:to_s)
+ operator = '!' # Override the operator since we want to find by assigned_to
+ else
+ groups = Group.find_all_by_id(v)
+ members_of_groups = groups.collect(&:user_ids).flatten.compact.collect(&:to_s)
+ end
+
+ sql << '(' + sql_for_field("assigned_to_id", operator, members_of_groups, Issue.table_name, "assigned_to_id", false) + ')'
+
else
# regular field
db_table = Issue.table_name