There is a long permission list at admin/people/permissions
.
For example there is permission with title Article: Edit any content
.
But where can I get the string which can be used with function user_access()
?
2 Answers
It's pretty lo-tech but you can actually get it with developer tools/firebug.
If you inspect one of the checkboxes next to a permission you'll see something like this for the name
attribute:
That's your permission string: edit any media_gallery content
The more bulletproof way to find out the exact string would be to inspect the module's implementation of hook_permission()
. In this case that would be node_permission()
which internally calls node_list_permissions()
.
If you look through that last function it should become quite clear what permission strings are generated for the various node operations.
Pop Devel on your site and head to yoursite.com/devel/php and enter the following:
$permissions = module_invoke('node', 'permission');
dsm($permissions);
The key for each part of the array will be the string you want to apply the permission.
The following will get a list of permissions on every enabled module on your site (modules sorted by name):
foreach (module_list(FALSE, FALSE, TRUE) as $module) {
if ($permissions = module_invoke($module, 'permission')) {
// Print the module title
dsm($module);
// Print the permisions
dsm($permissions);
}
}