You are here

function _views_bulk_operations_batch_process in Views Bulk Operations (VBO) 6.3

Helper function to handle Batch API operations.

1 string reference to '_views_bulk_operations_batch_process'
_views_bulk_operations_execute in ./views_bulk_operations.module
Helper function to execute the chosen action upon selected objects.

File

./views_bulk_operations.module, line 662
Allows operations to be performed on items selected in a view.

Code

function _views_bulk_operations_batch_process($oid, $row, &$context) {
  module_load_include('inc', 'node', 'node.admin');
  $operation = $_SESSION['vbo_options']['operation'];
  $params = $_SESSION['vbo_options']['params'];
  $object_info = $_SESSION['vbo_options']['object_info'];
  if (!isset($context['results']['time'])) {
    $context['results']['time'] = microtime(TRUE);
  }
  $object = call_user_func($object_info['load'], $oid);
  if (!_views_bulk_operations_object_permission($operation, $object, $object_info)) {
    $context['results']['log'][] = t('Skipped %action on @type %title due to insufficient permissions.', array(
      '%action' => $operation['label'],
      '@type' => t($object_info['type']),
      '%title' => $object->{$object_info['title']},
    ));
    return;
  }
  _views_bulk_operations_action_do($operation, $oid, $object, $row, $params, $object_info);
  $context['results']['log'][] = t('Performed %action on @type %title.', array(
    '%action' => $operation['label'],
    '@type' => t($object_info['type']),
    '%title' => $object->{$object_info['title']},
  ));
  if (isset($context['results']['rows'])) {
    $context['results']['rows'] += 1;
  }
  else {
    $context['results']['rows'] = 1;
  }
}