Module: Redmine::AccessControl

Defined in:
lib/redmine/access_control.rb

Defined Under Namespace

Classes: Mapper, Permission

Class Method Summary (collapse)

Class Method Details

+ (Object) allowed_actions(permission_name)

Returns the actions that are allowed by the permission of given name



40
41
42
43
# File 'lib/redmine/access_control.rb', line 40

def allowed_actions(permission_name)
  perm = permission(permission_name)
  perm ? perm.actions : []
end

+ (Object) available_project_modules



57
58
59
# File 'lib/redmine/access_control.rb', line 57

def available_project_modules
  @available_project_modules ||= @permissions.collect(&:project_module).uniq.compact
end

+ (Object) loggedin_only_permissions



53
54
55
# File 'lib/redmine/access_control.rb', line 53

def loggedin_only_permissions
  @loggedin_only_permissions ||= @permissions.select {|p| p.require_loggedin?}
end

+ (Object) map {|mapper| ... }

Yields:

  • (mapper)


22
23
24
25
26
27
# File 'lib/redmine/access_control.rb', line 22

def map
  mapper = Mapper.new
  yield mapper
  @permissions ||= []
  @permissions += mapper.mapped_permissions
end

+ (Object) members_only_permissions



49
50
51
# File 'lib/redmine/access_control.rb', line 49

def members_only_permissions
  @members_only_permissions ||= @permissions.select {|p| p.require_member?}
end

+ (Object) modules_permissions(modules)



61
62
63
# File 'lib/redmine/access_control.rb', line 61

def modules_permissions(modules)
  @permissions.select {|p| p.project_module.nil? || modules.include?(p.project_module.to_s)}
end

+ (Object) permission(name)

Returns the permission of given name or nil if it wasn't found Argument should be a symbol



35
36
37
# File 'lib/redmine/access_control.rb', line 35

def permission(name)
  permissions.detect {|p| p.name == name}
end

+ (Object) permissions



29
30
31
# File 'lib/redmine/access_control.rb', line 29

def permissions
  @permissions
end

+ (Object) public_permissions



45
46
47
# File 'lib/redmine/access_control.rb', line 45

def public_permissions
  @public_permissions ||= @permissions.select {|p| p.public?}
end