# populate the watcher list with the same user list as other user filters if the user has the :view_issue_watchers permission in at least one project
# populate the watcher list with the same user list as other user filters if the user has the :view_work_package_watchers permission in at least one project
# TODO: this could be differentiated more, e.g. all users could watch issues in public projects, but won't necessarily be shown here
# TODO: this could be differentiated more, e.g. all users could watch issues in public projects, but won't necessarily be shown here
@ -433,7 +433,7 @@ class Query < ActiveRecord::Base
sql_parts<<"#{WorkPackage.table_name}.id #{operator=='='?'IN':'NOT IN'} (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='WorkPackage' AND #{sql_for_fieldfield,'=',[user_id],db_table,db_field})"
sql_parts<<"#{WorkPackage.table_name}.id #{operator=='='?'IN':'NOT IN'} (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='WorkPackage' AND #{sql_for_fieldfield,'=',[user_id],db_table,db_field})"
end
end
# filter watchers only in projects the user has the permission to view watchers in
# filter watchers only in projects the user has the permission to view watchers in
sql_parts<<"#{WorkPackage.table_name}.id #{operator=='='?'IN':'NOT IN'} (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='WorkPackage' AND #{sql_for_fieldfield,'=',v,db_table,db_field})"\
sql_parts<<"#{WorkPackage.table_name}.id #{operator=='='?'IN':'NOT IN'} (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='WorkPackage' AND #{sql_for_fieldfield,'=',v,db_table,db_field})"\
" AND #{Project.table_name}.id IN (#{project_ids.join(',')})"unlessproject_ids.empty?
" AND #{Project.table_name}.id IN (#{project_ids.join(',')})"unlessproject_ids.empty?