Patch #4635 ยป query.rb.diff
app/models/query.rb (working copy) | ||
---|---|---|
194 | 194 |
|
195 | 195 |
if User.current.logged? |
196 | 196 |
@available_filters["watcher_id"] = { :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] } |
197 |
@available_filters["role_id"] = { :type => :list, :order => 16, :values => Role.find(:all, :order => 'builtin, position').collect{|r| [r.name, r.id.to_s]} } |
|
197 | 198 |
end |
198 | 199 |
|
199 | 200 |
if project |
... | ... | |
364 | 365 |
elsif project |
365 | 366 |
project_clauses << "#{Project.table_name}.id = %d" % project.id |
366 | 367 |
end |
368 | ||
367 | 369 |
project_clauses << Project.allowed_to_condition(User.current, :view_issues) |
368 | 370 |
project_clauses.join(' AND ') |
369 | 371 |
end |
... | ... | |
395 | 397 |
db_field = 'user_id' |
396 | 398 |
sql << "#{Issue.table_name}.id #{ operator == '=' ? 'IN' : 'NOT IN' } (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND " |
397 | 399 |
sql << sql_for_field(field, '=', v, db_table, db_field) + ')' |
400 |
elsif field == 'role_id' |
|
401 |
ids = [] |
|
402 |
ids += values_for("role_id").each(&:to_i) |
|
403 |
role_clauses = [] |
|
404 |
role_clauses << "#{Member.table_name}.user_id = %i" % User.current.id |
|
405 |
role_clauses << "#{Member.table_name}.id = #{MemberRole.table_name}.member_id" |
|
406 |
role_clauses << "#{MemberRole.table_name}.role_id IN (%s)" % ids.join(',') |
|
407 |
sql << "#{Project.table_name}.id #{ operator == '=' ? 'IN' : 'NOT IN' } (SELECT #{Member.table_name}.project_id FROM #{Member.table_name}, #{MemberRole.table_name} WHERE " |
|
408 |
sql << role_clauses.join(' AND ') + ')' |
|
398 | 409 |
else |
399 | 410 |
# regular field |
400 | 411 |
db_table = Issue.table_name |