5 * This file contains no working PHP code; it exists to provide additional
6 * documentation for doxygen as well as to document hooks in the standard
16 * Declare this module's structured permissions.
18 * A set of structured permissions is defined as a list of objects and a list
19 * of verbs. The permissions are created by combining these. For example, the
20 * list of node types and the verbs (create, edit, delete) form a grid of
21 * permissions for operations on all the node types.
23 * This hook may be placed in the file MODULE.permissions.inc.
26 * An array of data for object types that have multiple permissions associated
27 * with them. The array keys are object machine names, eg, 'node' (though note
28 * these need not be entities).
29 * Values are arrays with the following properties:
30 * - 'label': The human-readable label of the object type.
31 * - 'objects': An array of the different objects of this type that have
32 * their own permissions, for example, node types, which each provide
33 * permissions such as 'create foo node types'. These will form the rows
34 * of the permissions grid. The keys are the substrings of the permission
35 * strings, and the values are human-readable labels.
36 * - 'verb_groups': An array of one or more verb groups. Each verb group
37 * defines a list of verbs and a pattern for the permissions using those
38 * verbs. The verb groups keys are arbitrary (but using the name of the
39 * providing module is a good idea for ease of alterability), and each
40 * array has the following properties:
41 * - 'verbs': An array of verbs. The keys are the 'machine names', that is,
42 * the strings that are replaced into the pattern. The values may be
43 * human-readable labels. Note that verb machine names must be unique
44 * across all the verb groups for the object type.
45 * - 'pattern': The pattern of the permissions machine name, with the
46 * following replacements:
47 * - '%verb': The verb of the permission. This takes all the keys in the
48 * verbs array in this verb group.
49 * - '%object': The object of the permission. This takes all the keys in
51 * - 'object_process_callback' (optional) A function to process the object
52 * name before replacing it into the pattern. (This is just a hack for
55 function hook_permission_grid_info() {
58 'label' => t('Content type'),
60 'verb_groups' => array(
62 'pattern' => '%verb %object content',
64 'create' => t('Create'),
65 'edit own' => t('Edit own'),
66 'edit any' => t('Edit any'),
67 'delete own' => t('Delete own'),
68 'delete any' => t('Delete any'),
75 $node_types = node_type_get_types();
76 $configured_types = node_permissions_get_configured_types();
77 foreach ($configured_types as
$type) {
78 $return['node']['objects'][$type] = $node_types[$type]->name
;
85 * Alter the structured permission info defined by other modules.
87 function hook_permission_grid_info_alter(&$info) {
88 // Add a 'publish own node' verb.
89 $info['node']['verb_groups']['node']['verbs']['publish own'] = t('Publish own');