6252-subproject-users-in-filters.patch

Holger Just, 2010-08-31 16:04

Download (1.77 KB)

View differences:

app/models/query.rb
185 185
    user_values = []
186 186
    user_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged?
187 187
    if project
188
      user_values += User.active.all(
189
        :include => :members,
190
        :conditions => {"#{Member.table_name}.project_id" => project.self_and_descendants.visible}
191
      ).collect{|u| [u.name, u.id.to_s]}
188
      projects = project.self_and_descendants.visible
192 189
    else
193
      project_ids = Project.all(:conditions => Project.visible_by(User.current)).collect(&:id)
194
      if project_ids.any?
195
        # members of the user's projects
196
        user_values += User.active.find(:all, :conditions => ["#{User.table_name}.id IN (SELECT DISTINCT user_id FROM members WHERE project_id IN (?))", project_ids]).sort.collect{|s| [s.name, s.id.to_s] }
197
      end
190
      projects = Project.visible
198 191
    end
192
    user_values += User.active.all(
193
      :include => :members,
194
      :conditions => {"#{Member.table_name}.project_id" => projects}
195
    ).collect{|u| [u.name, u.id.to_s]}
199 196
    @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values } unless user_values.empty?
200 197
    @available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
201 198
    
202
-