summaryrefslogtreecommitdiffstats
path: root/app/models/news.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-01-17 14:14:12 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-01-17 14:14:12 +0000
commite3618bdbecd9b5d86eb6d2c8c256ba3fcdf05189 (patch)
tree3b54c10eecece6cc2674491a76a4e5e932d82d1e /app/models/news.rb
parent7f29c2fd88f271ac59f1c10b90942fec57b35ae2 (diff)
downloadredmine-e3618bdbecd9b5d86eb6d2c8c256ba3fcdf05189.tar.gz
redmine-e3618bdbecd9b5d86eb6d2c8c256ba3fcdf05189.zip
Add support for multiple email addresses per user (#4244).
git-svn-id: http://svn.redmine.org/redmine/trunk@13886 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/news.rb')
-rw-r--r--app/models/news.rb23
1 files changed, 16 insertions, 7 deletions
diff --git a/app/models/news.rb b/app/models/news.rb
index e0793d9a8..b8bc35f39 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -54,20 +54,29 @@ class News < ActiveRecord::Base
user.allowed_to?(:comment_news, project)
end
+ def notified_users
+ project.users.select {|user| user.notify_about?(self) && user.allowed_to?(:view_news, project)}
+ end
+
def recipients
- project.users.select {|user| user.notify_about?(self) && user.allowed_to?(:view_news, project)}.map(&:mail)
+ notified_users.map(&:mail)
end
- # Returns the email addresses that should be cc'd when a new news is added
- def cc_for_added_news
- cc = []
+ # Returns the users that should be cc'd when a new news is added
+ def notified_watchers_for_added_news
+ watchers = []
if m = project.enabled_module('news')
- cc = m.notified_watchers
+ watchers = m.notified_watchers
unless project.is_public?
- cc = cc.select {|user| project.users.include?(user)}
+ watchers = watchers.select {|user| project.users.include?(user)}
end
end
- cc.map(&:mail)
+ watchers
+ end
+
+ # Returns the email addresses that should be cc'd when a new news is added
+ def cc_for_added_news
+ notified_watchers_for_added_news.map(&:mail)
end
# returns latest news for projects visible by user