diff --git a/app/models/cost_query/filter/user_id.rb b/app/models/cost_query/filter/user_id.rb index 5dc72a81b6..1c58411a28 100644 --- a/app/models/cost_query/filter/user_id.rb +++ b/app/models/cost_query/filter/user_id.rb @@ -23,10 +23,16 @@ class CostQuery::Filter::UserId < Report::Filter::Base end def self.available_values(*) - users = Project.visible.collect(&:users).flatten.uniq.sort + # All users which are members in projects the user can see. + # Excludes the anonymous user + users = User.joins(members: :project) + .merge(Project.visible) + .where.not(id: User.anonymous) + .order_by_name + .select(User::USER_FORMATS_STRUCTURE[Setting.user_format].map(&:to_s) << :id) + .distinct + values = users.map { |u| [u.name, u.id] } - values.delete_if { |u| (u.first.include? 'OpenProject Admin') || (u.first.include? 'Anonymous') } - values.sort! values.unshift ["<< #{::I18n.t(:label_me)} >>", User.current.id.to_s] if User.current.logged? values end diff --git a/lib/open_project/reporting/engine.rb b/lib/open_project/reporting/engine.rb index 3a0700b2a0..5311292cd5 100644 --- a/lib/open_project/reporting/engine.rb +++ b/lib/open_project/reporting/engine.rb @@ -63,7 +63,7 @@ module OpenProject::Reporting after: :time_entries, caption: :cost_reports_title, if: Proc.new { |project| project.module_enabled?(:reporting_module) }, - html: { class: 'icon2 icon-stats' } + html: { class: 'icon2 icon-cost-reports' } # Cost reports should remove the default time entries menu item hide_menu_item :project_menu,