You are here

actions_permissions.module in Views Bulk Operations (VBO) 7.3

Same filename and directory in other branches
  1. 6.3 actions_permissions.module
  2. 6 actions_permissions.module

File

actions_permissions.module
View source
<?php

/**
 * Implements hook_permission().
 */
function actions_permissions_permission() {
  $permissions = array();
  $actions = actions_list() + _actions_permissions_advanced_actions_list();
  foreach ($actions as $key => $action) {
    $permission = actions_permissions_get_perm($action['label'], $key);
    $permissions[$permission] = array(
      'title' => t('Execute %label', array(
        '%label' => $action['label'],
      )),
    );
  }
  return $permissions;
}

/**
 * Get a list of advanced actions (created through the Action UI).
 */
function _actions_permissions_advanced_actions_list() {
  $actions = array();

  // Actions provided by Drupal that aren't usable in a VBO context.
  $hidden_actions = array(
    'system_block_ip_action',
    'system_goto_action',
    'system_message_action',
  );
  $result = db_query("SELECT * FROM {actions} WHERE parameters > ''");
  foreach ($result as $action) {
    if (in_array($action->callback, $hidden_actions)) {
      continue;
    }
    $parameters = unserialize($action->parameters);
    $actions[$action->aid] = array(
      'label' => $action->label,
      'type' => $action->type,
    );
  }
  return $actions;
}

/**
 * Returns the permission name used in user_access().
 */
function actions_permissions_get_perm($label, $key) {
  return "execute {$key}";
}

Functions

Namesort descending Description
actions_permissions_get_perm Returns the permission name used in user_access().
actions_permissions_permission Implements hook_permission().
_actions_permissions_advanced_actions_list Get a list of advanced actions (created through the Action UI).