Declaring custom permissions
As we saw briefly in Chapter 1, Introduction to Redmine Plugins, permissions are registered in our plugin's init.rb
file as part of the Redmine::Plugin.register
block.
While registering a new permission, we populate a hash, which takes a controller as key, and an array of actions as the value. The syntax for this command is as follows:
permission(name, actions, options = {})
The permission helper that is available to us (plugin authors) is actually just a wrapper around Redmine::AccessControl#map
, which is located in /path/to/redmine/lib/redmine/access_control.rb
.
Before registering our permissions, we need to understand the two scopes of permissions that are available: global and project module.
Global permissions are a bit deceptive as they aren't actually "global" in nature. In fact, they belong to the Project category and are essentially just a sum of a user's permissions across all projects for which they are members.
Note that global permissions can mean different...