summaryrefslogtreecommitdiffstats
path: root/vendor/plugins/acts_as_activity_provider
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-04 23:42:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-12-04 23:42:49 +0000
commit4485745dc6cf4d2f047a833617424ac333ed7d89 (patch)
treefd86c1297eb59c62eda1146c98739cb137454651 /vendor/plugins/acts_as_activity_provider
parent0a92e382fa18325a633a73b3f5f13fa831d4e016 (diff)
downloadredmine-4485745dc6cf4d2f047a833617424ac333ed7d89.tar.gz
redmine-4485745dc6cf4d2f047a833617424ac333ed7d89.zip
Use scopes instead of ARCondition.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8088 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor/plugins/acts_as_activity_provider')
-rw-r--r--vendor/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb21
1 files changed, 8 insertions, 13 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 9d45ee3f2..7c8dbe1df 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
@@ -54,37 +54,32 @@ module Redmine
provider_options = activity_provider_options[event_type]
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
- scope_options = {}
- cond = ARCondition.new
+ scope = self
+
if from && to
- cond.add(["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
+ scope = scope.scoped(:conditions => ["#{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])
+ 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_options[:order] = "#{table_name}.id DESC"
- scope_options[:limit] = options[:limit]
+ scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit])
end
- scope = self
if provider_options.has_key?(:permission)
- cond.add(Project.allowed_to_condition(user, provider_options[:permission] || :view_project, options))
+ scope = scope.scoped(:conditions => Project.allowed_to_condition(user, provider_options[:permission] || :view_project, options))
elsif respond_to?(:visible)
scope = scope.visible(user, 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."
- cond.add(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
+ scope = scope.scoped(:conditions => Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
end
- scope_options[:conditions] = cond.conditions
- with_scope(:find => scope_options) do
- scope.find(:all, provider_options[:find_options].dup)
- end
+ scope.all(provider_options[:find_options].dup)
end
end
end