summaryrefslogtreecommitdiffstats
path: root/app/models/journal.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-13 09:20:11 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-07-13 09:20:11 +0000
commit628d05629b734371d3e850a95dadf0be30c5ef20 (patch)
tree58a9da4e8266ee45a0800996f9228e9d2a45108c /app/models/journal.rb
parenta74d55edd99a4bae23e7d9cbd76136ffa7707ccf (diff)
downloadredmine-628d05629b734371d3e850a95dadf0be30c5ef20.tar.gz
redmine-628d05629b734371d3e850a95dadf0be30c5ef20.zip
Role-based issue custom field visibility (#5037).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12012 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/journal.rb')
-rw-r--r--app/models/journal.rb28
1 files changed, 24 insertions, 4 deletions
diff --git a/app/models/journal.rb b/app/models/journal.rb
index a75c112db..c14051f83 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -53,6 +53,18 @@ class Journal < ActiveRecord::Base
(details.empty? && notes.blank?) ? false : super
end
+ def visible_details(user=User.current)
+ details.select do |detail|
+ if detail.property == 'cf'
+ field_id = detail.prop_key
+ field = CustomField.find_by_id(field_id)
+ field && field.visible_by?(project, user)
+ else
+ true
+ end
+ end
+ end
+
# Returns the new status if the journal contains a status change, otherwise nil
def new_status
c = details.detect {|detail| detail.prop_key == 'status_id'}
@@ -93,20 +105,28 @@ class Journal < ActiveRecord::Base
@notify = arg
end
- def recipients
+ def notified_users
notified = journalized.notified_users
if private_notes?
notified = notified.select {|user| user.allowed_to?(:view_private_notes, journalized.project)}
end
- notified.map(&:mail)
+ notified
end
- def watcher_recipients
+ def recipients
+ notified_users.map(&:mail)
+ end
+
+ def notified_watchers
notified = journalized.notified_watchers
if private_notes?
notified = notified.select {|user| user.allowed_to?(:view_private_notes, journalized.project)}
end
- notified.map(&:mail)
+ notified
+ end
+
+ def watcher_recipients
+ notified_watchers.map(&:mail)
end
private