@@ -36,7 +36,6 module Redmine | |||
|
36 | 36 | # We store these options in activity_provider_options hash |
|
37 | 37 | event_type = options.delete(:type) || self.name.underscore.pluralize |
|
38 | 38 | |
|
39 | options[:permission] = "view_#{self.name.underscore.pluralize}".to_sym unless options.has_key?(:permission) | |
|
40 | 39 | options[:timestamp] ||= "#{table_name}.created_on" |
|
41 | 40 | options[:find_options] ||= {} |
|
42 | 41 | options[:author_key] = "#{table_name}.#{options[:author_key]}" if options[:author_key].is_a?(Symbol) |
@@ -60,20 +59,31 module Redmine | |||
|
60 | 59 | if from && to |
|
61 | 60 | cond.add(["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to]) |
|
62 | 61 | end |
|
62 | ||
|
63 | 63 | if options[:author] |
|
64 | 64 | return [] if provider_options[:author_key].nil? |
|
65 | 65 | cond.add(["#{provider_options[:author_key]} = ?", options[:author].id]) |
|
66 | 66 | end |
|
67 | cond.add(Project.allowed_to_condition(user, provider_options[:permission], options)) if provider_options[:permission] | |
|
68 | scope_options[:conditions] = cond.conditions | |
|
67 | ||
|
69 | 68 | if options[:limit] |
|
70 | 69 | # id and creation time should be in same order in most cases |
|
71 | 70 | scope_options[:order] = "#{table_name}.id DESC" |
|
72 | 71 | scope_options[:limit] = options[:limit] |
|
73 | 72 | end |
|
74 | 73 | |
|
74 | scope = self | |
|
75 | if provider_options.has_key?(:permission) | |
|
76 | cond.add(Project.allowed_to_condition(user, provider_options[:permission] || :view_project, options)) | |
|
77 | elsif respond_to?(:visible) | |
|
78 | scope = scope.visible(user, options) | |
|
79 | else | |
|
80 | ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option." | |
|
81 | cond.add(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options)) | |
|
82 | end | |
|
83 | scope_options[:conditions] = cond.conditions | |
|
84 | ||
|
75 | 85 | with_scope(:find => scope_options) do |
|
76 | find(:all, provider_options[:find_options].dup) | |
|
86 | scope.find(:all, provider_options[:find_options].dup) | |
|
77 | 87 | end |
|
78 | 88 | end |
|
79 | 89 | end |
General Comments 0
You need to be logged in to leave comments.
Login now