summaryrefslogtreecommitdiffstats
path: root/lib/redmine/access_control.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-14 11:34:08 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-14 11:34:08 +0000
commit21c97c6a1376a38a3951c57069317c17c81029f8 (patch)
tree8d38f129585767d4c1eb2c78d0b9b978aff14d70 /lib/redmine/access_control.rb
parent29348fafb7ca43cb00ef80f29e61167647df0cd8 (diff)
downloadredmine-21c97c6a1376a38a3951c57069317c17c81029f8.tar.gz
redmine-21c97c6a1376a38a3951c57069317c17c81029f8.zip
Added project module concept.
A project module (eg. issue tracking, news, wiki,...) is a set of permissions that can enabled/disabled at project level. For each project, modules can be enabled on the project settings view ('Modules' tab). This requires a specific permission: 'Select project modules' (if this permission is turned off, only Redmine administrators can choose which modules a project uses). When applying this migration, all modules are enabled for all existing projects. git-svn-id: http://redmine.rubyforge.org/svn/trunk@725 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/access_control.rb')
-rw-r--r--lib/redmine/access_control.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/redmine/access_control.rb b/lib/redmine/access_control.rb
index 54b344b7e..f5b25f277 100644
--- a/lib/redmine/access_control.rb
+++ b/lib/redmine/access_control.rb
@@ -46,27 +46,47 @@ module Redmine
def loggedin_only_permissions
@loggedin_only_permissions ||= @permissions.select {|p| p.require_loggedin?}
end
+
+ def available_project_modules
+ @available_project_modules ||= @permissions.collect(&:project_module).uniq.compact
+ end
+
+ def modules_permissions(modules)
+ @permissions.select {|p| p.project_module.nil? || modules.include?(p.project_module.to_s)}
+ end
end
class Mapper
+ def initialize
+ @project_module = nil
+ end
+
def permission(name, hash, options={})
@permissions ||= []
+ options.merge!(:project_module => @project_module)
@permissions << Permission.new(name, hash, options)
end
+ def project_module(name, options={})
+ @project_module = name
+ yield self
+ @project_module = nil
+ end
+
def mapped_permissions
@permissions
end
end
class Permission
- attr_reader :name, :actions
+ attr_reader :name, :actions, :project_module
def initialize(name, hash, options)
@name = name
@actions = []
@public = options[:public] || false
@require = options[:require]
+ @project_module = options[:project_module]
hash.each do |controller, actions|
if actions.is_a? Array
@actions << actions.collect {|action| "#{controller}/#{action}"}