Module: Redmine::Acts::ActivityProvider::InstanceMethods::ClassMethods
- Defined in:
- lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
Instance Method Summary collapse
-
#find_events(event_type, user, from, to, options) ⇒ Object
Returns events of type event_type visible by user that occurred between from and to.
Instance Method Details
#find_events(event_type, user, from, to, options) ⇒ Object
Returns events of type event_type visible by user that occurred between from and to
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb', line 52 def find_events(event_type, user, from, to, ) = [event_type] raise "#{self.name} can not provide #{event_type} events." if .nil? scope = ([:scope] || self) if from && to scope = scope.where("#{[:timestamp]} BETWEEN ? AND ?", from, to) end if [:author] return [] if [:author_key].nil? scope = scope.where("#{[:author_key]} = ?", [:author].id) end if [:limit] # id and creation time should be in same order in most cases scope = scope.reorder("#{table_name}.id DESC").limit([:limit]) end if .has_key?(:permission) scope = scope.where(Project.allowed_to_condition(user, [:permission] || :view_project, )) elsif respond_to?(:visible) scope = scope.visible(user, ) else 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." scope = scope.where(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, )) end scope.to_a end |