3 * @file permission_grid.permissions.inc
4 * Contains hook implementations on behalf of other modules.
7 // =========================================================== Core modules
10 * Implements hook_permission_grid_info() on behalf of node module.
12 function node_permission_grid_info() {
15 'label' => t('Content type'),
17 'verb_groups' => array(
19 'pattern' => '%verb %object content',
21 'create' => t('Create'),
22 'edit own' => t('Edit own'),
23 'edit any' => t('Edit any'),
24 'delete own' => t('Delete own'),
25 'delete any' => t('Delete any'),
32 $node_types = node_type_get_types();
33 $configured_types = node_permissions_get_configured_types();
34 foreach ($configured_types as
$type) {
35 $return['node']['objects'][$type] = $node_types[$type]->name
;
42 * Implements hook_permission_grid_info() on behalf of taxonomy module.
44 function taxonomy_permission_grid_info() {
45 $vocabularies = taxonomy_get_vocabularies();
47 'vocabulary' => array(
48 'label' => t('Taxonomy'),
50 'verb_groups' => array(
52 'pattern' => '%verb terms in %object',
54 'edit' => t('Edit terms'),
55 'delete' => t('Delete terms'),
57 // Oh yeah, taxonomy module, you're so cool you get a special thing
58 // just for you. And by 'cool' I mean 'still in D6 land'.
59 'object_process_callback' => 'permission_grid_taxonomy_object_process',
65 foreach ($vocabularies as
$vocabulary) {
66 $return['vocabulary']['objects'][$vocabulary->machine_name
] = $vocabulary->name
;
73 * Object process callback for taxonomy vocabularies.
75 * This handles the weirdness with taxonomy permissions using vocabulary ids
76 * rather than machine names.
78 function permission_grid_taxonomy_object_process($object_name) {
79 $vocabulary_names = taxonomy_vocabulary_get_names();
80 return $vocabulary_names[$object_name]->vid
;
83 // =========================================================== Contrib modules
86 * Implements hook_permission_grid_info_alter() on behalf of vppr module.
88 function vppr_permission_grid_info_alter(&$info) {
89 $info['vocabulary']['verb_groups']['vppr'] = array(
90 'pattern' => '%verb %object vocabulary terms',
92 'administer' => t('Administer terms'),
98 * Implements hook_permission_grid_info() on behalf of profile2 module.
100 function profile2_permission_grid_info() {
103 'label' => t('Profiles'),
104 'objects' => array(),
105 'verb_groups' => array(
107 'pattern' => '%verb %object profile',
109 'edit own' => t('Edit own'),
110 'edit any' => t('Edit any'),
111 'view own' => t('View own'),
112 'view any' => t('View any'),
119 foreach (profile2_get_types() as
$type => $type_info) {
120 $return['profile2']['objects'][$type] = $type_info->label
;
127 * Implements hook_permission_grid_info() on behalf of commerce module.
129 function commerce_permission_grid_info() {
132 // @todo: other commerce entity types.
133 foreach (array('commerce_product') as
$entity_type) {
134 $entity_info = entity_get_info($entity_type);
136 foreach ($entity_info['bundles'] as
$bundle => $bundle_info) {
137 $types[$bundle] = $bundle_info['label'];
140 $info[$entity_type] = array(
141 'label' => $entity_info['label'],
143 'verb_groups' => array(
144 // Put plural first so 'create' comes first.
145 'commerce_plural' => array(
146 'pattern' => "%verb $entity_type entities of bundle %object",
148 'create' => t('Create'),
149 'edit own' => t('Edit own'),
150 'view own' => t('View own'),
153 'commerce_singular' => array(
154 'pattern' => "%verb $entity_type entity of bundle %object",
156 'edit any' => t('Edit any'),
157 'view any' => t('View any'),
167 * Implements hook_permission_grid_info() on behalf of flag module.
169 function flag_permission_grid_info() {
172 'label' => t('Flag'),
173 'objects' => array(),
174 'verb_groups' => array(
176 'pattern' => '%verb %object',
179 'unflag' => t('Unflag'),
186 foreach (flag_get_flags() as
$flag) {
187 $return['flag']['objects'][$flag->name
] = $flag->title
;