You are here

function _views_bulk_operations_execute_single in Views Bulk Operations (VBO) 6

Helper function to handle Batch API operations.

1 string reference to '_views_bulk_operations_execute_single'
_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 1586
Allows operations to be performed on items selected in a view.

Code

function _views_bulk_operations_execute_single($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);
    $context['results']['rows'] = 0;
  }
  $object = call_user_func($object_info['load'], $oid);
  if (!$object) {
    $context['results']['log'][] = t('Skipped %operation on @type id %oid because it was not found.', array(
      '%operation' => $operation['label'],
      '@type' => t($operation['type']),
      '%oid' => $oid,
    ));
    return;
  }
  if (!_views_bulk_operations_object_permission($operation, $object, $object_info)) {
    $context['results']['log'][] = t('Skipped %operation on @type %title due to insufficient permissions.', array(
      '%operation' => $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'][] = $context['message'] = t('Performed %operation on @type %title.', array(
    '%operation' => $operation['label'],
    '@type' => t($object_info['type']),
    '%title' => $object->{$object_info['title']},
  ));
  $context['results']['rows'] += 1;
}