commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / views_bulk_operations / actions_permissions.module
1 <?php
2
3 /**
4 * Implements hook_permission().
5 */
6 function actions_permissions_permission() {
7 $permissions = array();
8 $actions = actions_list() + _actions_permissions_advanced_actions_list();
9 foreach ($actions as $key => $action) {
10 $permission = actions_permissions_get_perm($action['label'], $key);
11
12 $permissions[$permission] = array(
13 'title' => t('Execute %label', array('%label' => $action['label'])),
14 );
15 }
16 return $permissions;
17 }
18
19 /**
20 * Get a list of advanced actions (created through the Action UI).
21 */
22 function _actions_permissions_advanced_actions_list() {
23 $actions = array();
24 // Actions provided by Drupal that aren't usable in a VBO context.
25 $hidden_actions = array(
26 'system_block_ip_action',
27 'system_goto_action',
28 'system_message_action',
29 );
30
31 $result = db_query("SELECT * FROM {actions} WHERE parameters > ''");
32 foreach ($result as $action) {
33 if (in_array($action->callback, $hidden_actions)) {
34 continue;
35 }
36
37 $parameters = unserialize($action->parameters);
38 $actions[$action->aid] = array(
39 'label' => $action->label,
40 'type' => $action->type,
41 );
42 }
43 return $actions;
44 }
45
46 /**
47 * Returns the permission name used in user_access().
48 */
49 function actions_permissions_get_perm($label, $key) {
50 return "execute $key";
51 }