summaryrefslogtreecommitdiffstats
path: root/app/models/document.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2011-01-23 16:47:59 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2011-01-23 16:47:59 +0000
commitb20210e83c42807e6445b827504afe64323e272d (patch)
treeeff39b4fa611cd9ec6fae61ff6e124d091dbaeee /app/models/document.rb
parent777ccf1328c9ebfac33f23e965eccfb5578f182f (diff)
downloadredmine-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/document.rb')
-rw-r--r--app/models/document.rb3
1 files changed, 3 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