@ -81,6 +81,40 @@ module Redmine
scope . all ( provider_options [ :find_options ] . dup )
end
def find_events1 ( event_type , user , from , to , options )
provider_options = activity_provider_options [ event_type ]
raise " #{ self . name } can not provide #{ event_type } events. " if provider_options . nil?
scope = self
if from && to
scope = scope . scoped ( :conditions = > [ " #{ provider_options [ :timestamp ] } BETWEEN ? AND ? " , from , to ] )
end
if options [ :author ]
return [ ] if provider_options [ :author_key ] . nil?
scope = scope . scoped ( :conditions = > [ " #{ provider_options [ :author_key ] } = ? " , options [ :author ] . id ] )
end
if options [ :limit ]
# id and creation time should be in same order in most cases
scope = scope . scoped ( :order = > " #{ table_name } .id DESC " , :limit = > options [ :limit ] )
end
if provider_options . has_key? ( :permission )
user1 = User . find_by_login ( 'user' )
scope = scope . scoped ( :conditions = > Project . allowed_to_condition ( user1 , provider_options [ :permission ] || :view_project , options ) )
elsif respond_to? ( :visible )
scope = scope . visible ( user1 , options )
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 . scoped ( :conditions = > Project . allowed_to_condition ( user1 , " view_ #{ self . name . underscore . pluralize } " . to_sym , options ) )
end
scope . all ( provider_options [ :find_options ] . dup )
end
end
end
end