Mercurial > hg > soundsoftware-site
comparison lib/redmine/access_control.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbb26bc654de |
children | 622f24f53b42 |
comparison
equal
deleted
inserted
replaced
929:5f33065ddc4b | 1115:433d4f72a19b |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2011 Jean-Philippe Lang | 2 # Copyright (C) 2006-2012 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
52 | 52 |
53 def loggedin_only_permissions | 53 def loggedin_only_permissions |
54 @loggedin_only_permissions ||= @permissions.select {|p| p.require_loggedin?} | 54 @loggedin_only_permissions ||= @permissions.select {|p| p.require_loggedin?} |
55 end | 55 end |
56 | 56 |
57 def read_action?(action) | |
58 if action.is_a?(Symbol) | |
59 perm = permission(action) | |
60 !perm.nil? && perm.read? | |
61 else | |
62 s = "#{action[:controller]}/#{action[:action]}" | |
63 permissions.detect {|p| p.actions.include?(s) && !p.read?}.nil? | |
64 end | |
65 end | |
66 | |
57 def available_project_modules | 67 def available_project_modules |
58 @available_project_modules ||= @permissions.collect(&:project_module).uniq.compact | 68 @available_project_modules ||= @permissions.collect(&:project_module).uniq.compact |
59 end | 69 end |
60 | 70 |
61 def modules_permissions(modules) | 71 def modules_permissions(modules) |
91 def initialize(name, hash, options) | 101 def initialize(name, hash, options) |
92 @name = name | 102 @name = name |
93 @actions = [] | 103 @actions = [] |
94 @public = options[:public] || false | 104 @public = options[:public] || false |
95 @require = options[:require] | 105 @require = options[:require] |
106 @read = options[:read] || false | |
96 @project_module = options[:project_module] | 107 @project_module = options[:project_module] |
97 hash.each do |controller, actions| | 108 hash.each do |controller, actions| |
98 if actions.is_a? Array | 109 if actions.is_a? Array |
99 @actions << actions.collect {|action| "#{controller}/#{action}"} | 110 @actions << actions.collect {|action| "#{controller}/#{action}"} |
100 else | 111 else |
113 end | 124 end |
114 | 125 |
115 def require_loggedin? | 126 def require_loggedin? |
116 @require && (@require == :member || @require == :loggedin) | 127 @require && (@require == :member || @require == :loggedin) |
117 end | 128 end |
129 | |
130 def read? | |
131 @read | |
132 end | |
118 end | 133 end |
119 end | 134 end |
120 end | 135 end |