return"#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND (#{Project.table_name}.is_public = #{connection.quoted_true} or #{Project.table_name}.id IN (#{user.memberships.collect(&:project_id).join(',')}))"
return"#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND (#{Project.table_name}.is_public = #{connection.quoted_true} or #{Project.table_name}.id IN (#{user.memberships.map(&:project_id).join(',')}))"
else
return"#{Project.table_name}.status=#{Project::STATUS_ACTIVE} AND #{Project.table_name}.is_public = #{connection.quoted_true}"
end
@ -337,7 +337,7 @@ class Project < ActiveRecord::Base
end
user.projects_by_role.eachdo|role,projects|
ifrole.allowed_to?(permission)
statement_by_role[role]="#{Project.table_name}.id IN (#{projects.collect(&:id).join(',')})"
statement_by_role[role]="#{Project.table_name}.id IN (#{projects.map(&:id).join(',')})"
end
end
else
@ -442,7 +442,7 @@ class Project < ActiveRecord::Base
defarchive
# Check that there is no issue of a non descendant project that is assigned
principals=Principal.active.where(["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))",visible_projects.collect(&:id)]).sort
principals=Principal.active.where(["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))",visible_projects.map(&:id)]).sort
@ -302,10 +302,10 @@ class Query < ActiveRecord::Base
# main project only
else
# all subprojects
ids+=project.descendants.collect(&:id)
ids+=project.descendants.map(&:id)
end
elsifSetting.display_subprojects_work_packages?
ids+=project.descendants.collect(&:id)
ids+=project.descendants.map(&:id)
end
project_clauses<<"#{Project.table_name}.id IN (%s)"%ids.join(',')
elsifproject
@ -358,7 +358,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})"
end
# 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,'=',values,db_table,db_field})"\
" AND #{Project.table_name}.id IN (#{project_ids.join(',')})"unlessproject_ids.empty?
sql<<"(#{sql_parts.join(' OR ')})"
@ -379,7 +379,7 @@ class Query < ActiveRecord::Base