summaryrefslogtreecommitdiffstats
path: root/app/models/news.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2014-02-09 11:54:21 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2014-02-09 11:54:21 +0000
commit1ad33134d3005af9a1c8357a55e8c6ab9332d4fa (patch)
treed964e26f55acaa8791ab15776de735fc3cfc682b /app/models/news.rb
parentfa31229a2338706455dd754fd57e7f7e8ebf26a7 (diff)
downloadredmine-1ad33134d3005af9a1c8357a55e8c6ab9332d4fa.tar.gz
redmine-1ad33134d3005af9a1c8357a55e8c6ab9332d4fa.zip
Enable the watching of news (#2549).
git-svn-id: http://svn.redmine.org/redmine/trunk@12866 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/news.rb')
-rw-r--r--app/models/news.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/models/news.rb b/app/models/news.rb
index d9b0f513e..c1f6655a5 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -54,6 +54,18 @@ class News < ActiveRecord::Base
project.users.select {|user| user.notify_about?(self)}.map(&:mail)
end
+ # Returns the email addresses that should be cc'd when a new news is added
+ def cc_for_added_news
+ cc = []
+ if m = project.enabled_module('news')
+ cc = m.notified_watchers
+ unless project.is_public?
+ cc = cc.select {|user| project.users.include?(user)}
+ end
+ end
+ cc.map(&:mail)
+ end
+
# returns latest news for projects visible by user
def self.latest(user = User.current, count = 5)
visible(user).includes([:author, :project]).order("#{News.table_name}.created_on DESC").limit(count).all