diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-18 09:07:42 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-18 09:07:42 +0000 |
commit | 886b9c14d0cb16e5ae132bdea545ddea771f7284 (patch) | |
tree | 9f88bcf5aa5c727912dc91e19a57212893c2f66e /lib/redmine/activity | |
parent | 5190fef9d61d20a5911dbeb7a35bdbee5e3c90d8 (diff) | |
download | redmine-886b9c14d0cb16e5ae132bdea545ddea771f7284.tar.gz redmine-886b9c14d0cb16e5ae132bdea545ddea771f7284.zip |
Fixed that Redmine::Activity::Fetcher should consider activity provider permission option if given (#18832).
git-svn-id: http://svn.redmine.org/redmine/trunk@13895 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/activity')
-rw-r--r-- | lib/redmine/activity/fetcher.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb index 85f31e2e9..1ae8c1091 100644 --- a/lib/redmine/activity/fetcher.rb +++ b/lib/redmine/activity/fetcher.rb @@ -21,9 +21,6 @@ module Redmine class Fetcher attr_reader :user, :project, :scope - # Needs to be unloaded in development mode - @@constantized_providers = Hash.new {|h,k| h[k] = Redmine::Activity.providers[k].collect {|t| t.constantize } } - def initialize(user, options={}) options.assert_valid_keys(:project, :with_subprojects, :author) @user = user @@ -38,7 +35,25 @@ module Redmine return @event_types unless @event_types.nil? @event_types = Redmine::Activity.available_event_types - @event_types = @event_types.select {|o| @project.self_and_descendants.detect {|p| @user.allowed_to?("view_#{o}".to_sym, p)}} if @project + if @project + projects = @project.self_and_descendants + @event_types = @event_types.select do |event_type| + keep = false + constantized_providers(event_type).each do |provider| + options = provider.activity_provider_options[event_type] + permission = options[:permission] + unless options.key?(:permission) + permission ||= "view_#{event_type}".to_sym + end + if permission + keep |= projects.any? {|p| @user.allowed_to?(permission, p)} + else + keep = true + end + end + keep + end + end @event_types end @@ -88,7 +103,7 @@ module Redmine private def constantized_providers(event_type) - @@constantized_providers[event_type] + Redmine::Activity.providers[event_type].map(&:constantize) end end end |