You are here

function views_bulk_operations_plugin_style::populate_operations in Views Bulk Operations (VBO) 6

Same name and namespace in other branches
  1. 6.3 views_bulk_operations_plugin_style.inc \views_bulk_operations_plugin_style::populate_operations()
1 call to views_bulk_operations_plugin_style::populate_operations()
views_bulk_operations_plugin_style::init in ./views_bulk_operations_plugin_style.inc
Implementation of views_plugin::init().

File

./views_bulk_operations_plugin_style.inc, line 292

Class

views_bulk_operations_plugin_style

Code

function populate_operations() {
  module_load_include('inc', 'node', 'node.admin');
  $operations = array();
  foreach (_views_bulk_operations_get_object_info() as $object_type => $object_info) {
    $hook_name = $object_type . '_operations';
    foreach (module_invoke_all($hook_name) as $operation) {
      if (empty($operation['callback'])) {
        continue;
      }
      $key = $operation['callback'] . (empty($operation['callback arguments']) ? '' : '-' . md5(serialize($operation['callback arguments'])));
      if (!isset($operation['behavior'])) {

        // assume operations modify nodes by default
        $operation['behavior'] = array(
          'changes_node_property',
        );
      }
      $operations[$key] = array(
        'key' => $key,
        'label' => $operation['label'],
        'callback' => $operation['callback'],
        'callback arguments' => isset($operation['callback arguments']) ? $operation['callback arguments'] : array(),
        'configurable' => isset($operation['configurable']) ? $operation['configurable'] : FALSE,
        'form properties' => isset($operation['form properties']) ? $operation['form properties'] : array(),
        'source' => 'operation',
        'type' => $object_type,
        'aggregate' => isset($operation['aggregate']) ? (int) $operation['aggregate'] : VBO_AGGREGATE_OPTIONAL,
        'access op' => $this
          ->get_access_op($operation),
        'permissions' => isset($operation['permissions']) ? $operation['permissions'] : NULL,
        'hooks' => array(),
      );
    }
  }
  $action_operations = actions_list() + $this
    ->get_custom_actions();
  foreach ($action_operations as $callback => $operation) {
    $key = isset($operation['key']) ? $operation['key'] : $callback;
    $operations[$key] = array(
      'key' => $key,
      'label' => $operation['description'],
      'callback' => isset($operation['callback']) ? $operation['callback'] : $callback,
      'callback arguments' => isset($operation['parameters']) ? $operation['parameters'] : array(),
      'configurable' => isset($operation['configurable']) ? $operation['configurable'] : FALSE,
      'form properties' => isset($operation['form properties']) ? $operation['form properties'] : array(),
      'source' => 'action',
      'type' => $operation['type'],
      'aggregate' => isset($operation['aggregate']) ? (int) $operation['aggregate'] : VBO_AGGREGATE_FORBIDDEN,
      'access op' => $this
        ->get_access_op($operation),
      'permissions' => isset($operation['permissions']) ? $operation['permissions'] : NULL,
      'hooks' => isset($operation['hooks']) ? array_keys((array) $operation['hooks']) : array(),
    );
  }
  uasort($operations, create_function('$a, $b', 'return strcasecmp($a["label"], $b["label"]);'));
  $this->all_operations = $operations;
}