@@ -54,37 +54,32 module Redmine | |||
|
54 | 54 | provider_options = activity_provider_options[event_type] |
|
55 | 55 | raise "#{self.name} can not provide #{event_type} events." if provider_options.nil? |
|
56 | 56 | |
|
57 |
scope |
|
|
58 | cond = ARCondition.new | |
|
57 | scope = self | |
|
58 | ||
|
59 | 59 | if from && to |
|
60 |
|
|
|
60 | scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to]) | |
|
61 | 61 | end |
|
62 | 62 | |
|
63 | 63 | if options[:author] |
|
64 | 64 | return [] if provider_options[:author_key].nil? |
|
65 |
|
|
|
65 | scope = scope.scoped(:conditions => ["#{provider_options[:author_key]} = ?", options[:author].id]) | |
|
66 | 66 | end |
|
67 | 67 | |
|
68 | 68 | if options[:limit] |
|
69 | 69 | # id and creation time should be in same order in most cases |
|
70 |
scope |
|
|
71 | scope_options[:limit] = options[:limit] | |
|
70 | scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit]) | |
|
72 | 71 | end |
|
73 | 72 | |
|
74 | scope = self | |
|
75 | 73 | if provider_options.has_key?(:permission) |
|
76 |
|
|
|
74 | scope = scope.scoped(:conditions => Project.allowed_to_condition(user, provider_options[:permission] || :view_project, options)) | |
|
77 | 75 | elsif respond_to?(:visible) |
|
78 | 76 | scope = scope.visible(user, options) |
|
79 | 77 | else |
|
80 | 78 | 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 |
|
|
|
79 | scope = scope.scoped(:conditions => Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options)) | |
|
82 | 80 | end |
|
83 | scope_options[:conditions] = cond.conditions | |
|
84 | 81 | |
|
85 | with_scope(:find => scope_options) do | |
|
86 | scope.find(:all, provider_options[:find_options].dup) | |
|
87 | end | |
|
82 | scope.all(provider_options[:find_options].dup) | |
|
88 | 83 | end |
|
89 | 84 | end |
|
90 | 85 | end |
General Comments 0
You need to be logged in to leave comments.
Login now