Display latest user's activity on account/show view.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2066 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2008-11-30 11:18:22 +00:00
parent b5fcea9e74
commit fce4615f10
14 changed files with 86 additions and 22 deletions
+8 -2
View File
@@ -25,7 +25,7 @@ module Redmine
@@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)
options.assert_valid_keys(:project, :with_subprojects, :author)
@user = user
@project = options[:project]
@options = options
@@ -58,14 +58,20 @@ module Redmine
end
# Returns an array of events for the given date range
def events(from, to)
def events(from = nil, to = nil, options={})
e = []
@options[:limit] = options[:limit]
@scope.each do |event_type|
constantized_providers(event_type).each do |provider|
e += provider.find_events(event_type, @user, from, to, @options)
end
end
if options[:limit]
e.sort! {|a,b| b.event_date <=> a.event_date}
e = e.slice(0, options[:limit])
end
e
end