summaryrefslogtreecommitdiffstats
path: root/app/models/news.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-13 14:26:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-13 14:26:54 +0000
commitbb477a3a0fe71f0e15b78b6e0fafb017065fba26 (patch)
tree5fe5daa3d87fa80c93b0e77bc95552079a1389c5 /app/models/news.rb
parent6610bb6b6cbb1ef72787542063359de04fbab6be (diff)
downloadredmine-bb477a3a0fe71f0e15b78b6e0fafb017065fba26.tar.gz
redmine-bb477a3a0fe71f0e15b78b6e0fafb017065fba26.zip
Make sure users don't get notified for thing they can not view (#3589).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3169 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/news.rb')
-rw-r--r--app/models/news.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/models/news.rb b/app/models/news.rb
index c53fb05f9..a7b173439 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -29,6 +29,17 @@ class News < ActiveRecord::Base
acts_as_activity_provider :find_options => {:include => [:project, :author]},
:author_key => :author_id
+ def visible?(user=User.current)
+ !user.nil? && user.allowed_to?(:view_news, project)
+ 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
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")