Refactor: Move recipients method into acts_as_event
acts_as_event should be the standard interface to Redmine events, like mail notifications, so having a standard recipients implementation there makes sense. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3358 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d43c860448
commit
358e3194d7
|
@ -46,11 +46,4 @@ class Document < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
@updated_on
|
@updated_on
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the mail adresses of users that should be notified
|
|
||||||
def recipients
|
|
||||||
notified = project.notified_users
|
|
||||||
notified.reject! {|user| !visible?(user)}
|
|
||||||
notified.collect(&:mail)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -90,13 +90,6 @@ class Message < ActiveRecord::Base
|
||||||
usr && usr.logged? && (usr.allowed_to?(:delete_messages, project) || (self.author == usr && usr.allowed_to?(:delete_own_messages, project)))
|
usr && usr.logged? && (usr.allowed_to?(:delete_messages, project) || (self.author == usr && usr.allowed_to?(:delete_own_messages, project)))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the mail adresses of users that should be notified
|
|
||||||
def recipients
|
|
||||||
notified = project.notified_users
|
|
||||||
notified.reject! {|user| !visible?(user)}
|
|
||||||
notified.collect(&:mail)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def add_author_as_watcher
|
def add_author_as_watcher
|
||||||
|
|
|
@ -33,13 +33,6 @@ class News < ActiveRecord::Base
|
||||||
!user.nil? && user.allowed_to?(:view_news, project)
|
!user.nil? && user.allowed_to?(:view_news, project)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the mail adresses of users that should be notified
|
|
||||||
def recipients
|
|
||||||
notified = project.notified_users
|
|
||||||
notified.reject! {|user| !visible?(user)}
|
|
||||||
notified.collect(&:mail)
|
|
||||||
end
|
|
||||||
|
|
||||||
# returns latest news for projects visible by user
|
# returns latest news for projects visible by user
|
||||||
def self.latest(user = User.current, count = 5)
|
def self.latest(user = User.current, count = 5)
|
||||||
find(:all, :limit => count, :conditions => Project.allowed_to_condition(user, :view_news), :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
find(:all, :limit => count, :conditions => Project.allowed_to_condition(user, :view_news), :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")
|
||||||
|
|
|
@ -68,6 +68,13 @@ module Redmine
|
||||||
(option.is_a?(Proc) ? option.call(self) : send(option)).merge(options)
|
(option.is_a?(Proc) ? option.call(self) : send(option)).merge(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the mail adresses of users that should be notified
|
||||||
|
def recipients
|
||||||
|
notified = project.notified_users
|
||||||
|
notified.reject! {|user| !visible?(user)}
|
||||||
|
notified.collect(&:mail)
|
||||||
|
end
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue