You are here

function views_bulk_operations_handler_field_operations::init in Views Bulk Operations (VBO) 7.3

Initialize the entity type.

Overrides views_handler_field_entity::init

File

views/views_bulk_operations_handler_field_operations.inc, line 12
Views field handler. Contains all relevant VBO options and related logic. Implements the Views Form API.

Class

views_bulk_operations_handler_field_operations
@file Views field handler. Contains all relevant VBO options and related logic. Implements the Views Form API.

Code

function init(&$view, &$options) {
  parent::init($view, $options);

  // Update old settings
  if (!empty($options['vbo']) && empty($this->options['vbo_operations'])) {
    $this->options['vbo_operations'] = $options['vbo']['operations'];
    unset($options['vbo']['operations']);
    $this->options['vbo_settings'] = $options['vbo'] + $this->options['vbo_settings'];
  }

  // When updating old Views it is possible for this value to stay empty.
  if (empty($this->options['vbo_settings']['entity_load_capacity'])) {
    $this->options['vbo_settings']['entity_load_capacity'] = 10;
  }
  foreach ($this->options['vbo_operations'] as $operation_id => &$operation_options) {

    // Prefix all un-prefixed operations.
    if (strpos($operation_id, '::') === FALSE) {
      $operations = views_bulk_operations_get_operation_info();

      // Basically, guess.
      foreach (array(
        'action',
        'rules_component',
      ) as $operation_type) {
        $new_operation_id = $operation_type . '::' . $operation_id;
        if (isset($operations[$new_operation_id])) {
          $this->options['vbo_operations'][$new_operation_id] = $operation_options;
          break;
        }
      }

      // Remove the old operation in any case.
      unset($this->options['vbo_operations'][$operation_id]);
    }

    // Rename the use_queue setting.
    if (isset($operation_options['use_queue']) && !isset($operation_options['postpone_processing'])) {
      $operation_options['postpone_processing'] = $operation_options['use_queue'];
      unset($operation_options['use_queue']);
    }
  }

  // Check whether this is a revision.
  $table_data = views_fetch_data($this->table);
  if (!empty($table_data['table']['revision'])) {
    $this->revision = TRUE;
  }
}