You are here

function views_bulk_operations_operation_action_list in Views Bulk Operations (VBO) 7.3

Returns a prepared list of available actions.

Actions are fetched by invoking hook_action_info() and by loading advanced actions from the database.

Parameters

$operation_id: The full, prefixed operation_id of the operation (in this case, action) to return, or NULL to return an array with all operations.

1 string reference to 'views_bulk_operations_operation_action_list'
action.inc in plugins/operation_types/action.inc

File

plugins/operation_types/action.inc, line 27

Code

function views_bulk_operations_operation_action_list($operation_id = NULL) {
  $operations =& drupal_static(__FUNCTION__);
  if (!isset($operations)) {

    // Combined list of all actions and advanced actions.
    $actions_list = actions_list() + views_bulk_operations_operation_advanced_action_list();

    // 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',
    );
    $operations = array();
    foreach ($actions_list as $key => $action) {

      // Actions are keyed by callback.
      // Advanced actions are keyed by aid and store the callback separately.
      $callback = isset($action['callback']) ? $action['callback'] : $key;

      // This action needs to be skipped.
      if (in_array($callback, $hidden_actions)) {
        continue;
      }

      // All operations must be prefixed with the operation type.
      $new_operation_id = 'action::' . $key;
      $operations[$new_operation_id] = array(
        'operation_type' => 'action',
        'type' => $action['type'],
        // Keep the unprefixed key around, for internal use.
        'key' => $key,
        'callback' => $callback,
        'label' => isset($action['label']) ? $action['label'] : '',
        'parameters' => isset($action['parameters']) ? $action['parameters'] : array(),
        'configurable' => !empty($action['configurable']) || !empty($action['vbo_configurable']),
        'aggregate' => !empty($action['aggregate']),
        'behavior' => isset($action['behavior']) ? $action['behavior'] : array(),
        'permissions' => isset($action['permissions']) ? $action['permissions'] : NULL,
        'pass rows' => !empty($action['pass rows']),
      );
    }
  }
  if (isset($operation_id)) {
    return isset($operations[$operation_id]) ? $operations[$operation_id] : FALSE;
  }
  else {
    return $operations;
  }
}