summaryrefslogtreecommitdiffstats
path: root/vendor/plugins
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-11-30 11:18:22 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-11-30 11:18:22 +0000
commitfce4615f10ad81b9070e65a45f9d37b1c571ccd7 (patch)
treeb922752605cd207cf51e72866f435af8427ea468 /vendor/plugins
parentb5fcea9e7414647533ee333485ed8c93b9cff82f (diff)
downloadredmine-fce4615f10ad81b9070e65a45f9d37b1c571ccd7.tar.gz
redmine-fce4615f10ad81b9070e65a45f9d37b1c571ccd7.zip
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
Diffstat (limited to 'vendor/plugins')
-rw-r--r--vendor/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/vendor/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/vendor/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
index 7c4fac8b1..d631935e0 100644
--- a/vendor/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
+++ b/vendor/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
@@ -29,7 +29,7 @@ module Redmine
send :include, Redmine::Acts::ActivityProvider::InstanceMethods
end
- options.assert_valid_keys(:type, :permission, :timestamp, :find_options)
+ options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options)
self.activity_provider_options ||= {}
# One model can provide different event types
@@ -39,6 +39,7 @@ module Redmine
options[:permission] = "view_#{self.name.underscore.pluralize}".to_sym unless options.has_key?(:permission)
options[:timestamp] ||= "#{table_name}.created_on"
options[:find_options] ||= {}
+ options[:author_key] = "#{table_name}.#{options[:author_key]}" if options[:author_key].is_a?(Symbol)
self.activity_provider_options[event_type] = options
end
end
@@ -54,10 +55,21 @@ module Redmine
provider_options = activity_provider_options[event_type]
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
- cond = ARCondition.new(["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
+ scope_options = {}
+ cond = ARCondition.new
+ if from && to
+ cond.add(["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
+ end
+ if options[:author]
+ return [] if provider_options[:author_key].nil?
+ cond.add(["#{provider_options[:author_key]} = ?", options[:author].id])
+ end
cond.add(Project.allowed_to_condition(user, provider_options[:permission], options)) if provider_options[:permission]
+ scope_options[:conditions] = cond.conditions
+ scope_options[:order] = "#{provider_options[:timestamp]} DESC"
+ scope_options[:limit] = options[:limit]
- with_scope(:find => { :conditions => cond.conditions }) do
+ with_scope(:find => scope_options) do
find(:all, provider_options[:find_options])
end
end