diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-01-23 16:47:59 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-01-23 16:47:59 +0000 |
commit | b20210e83c42807e6445b827504afe64323e272d (patch) | |
tree | eff39b4fa611cd9ec6fae61ff6e124d091dbaeee /app/models | |
parent | 777ccf1328c9ebfac33f23e965eccfb5578f182f (diff) | |
download | redmine-b20210e83c42807e6445b827504afe64323e272d.tar.gz redmine-b20210e83c42807e6445b827504afe64323e272d.zip |
Adds visible scope to redmine links queries.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4759 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/document.rb | 3 | ||||
-rw-r--r-- | app/models/message.rb | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/app/models/document.rb b/app/models/document.rb index 3aae39850..21232a2d9 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -29,6 +29,9 @@ class Document < ActiveRecord::Base validates_presence_of :project, :title, :category validates_length_of :title, :maximum => 60 + named_scope :visible, lambda {|*args| { :include => :project, + :conditions => Project.allowed_to_condition(args.first || User.current, :view_documents) } } + def visible?(user=User.current) !user.nil? && user.allowed_to?(:view_documents, project) end diff --git a/app/models/message.rb b/app/models/message.rb index 3744c239b..77c9ff550 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -42,6 +42,9 @@ class Message < ActiveRecord::Base after_create :add_author_as_watcher + named_scope :visible, lambda {|*args| { :include => {:board => :project}, + :conditions => Project.allowed_to_condition(args.first || User.current, :view_messages) } } + def visible?(user=User.current) !user.nil? && user.allowed_to?(:view_messages, project) end |