You are here

function _node_mass_update_batch_process in Drupal 6

Same name and namespace in other branches
  1. 8 core/modules/node/node.admin.inc \_node_mass_update_batch_process()
  2. 7 modules/node/node.admin.inc \_node_mass_update_batch_process()
  3. 9 core/modules/node/node.admin.inc \_node_mass_update_batch_process()

Node Mass Update Batch operation

1 string reference to '_node_mass_update_batch_process'
node_mass_update in modules/node/node.admin.inc
Make mass update of nodes, changing all nodes in the $nodes array to update them with the field values in $updates.

File

modules/node/node.admin.inc, line 390
Content administration and module settings UI.

Code

function _node_mass_update_batch_process($nodes, $updates, &$context) {
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = count($nodes);
    $context['sandbox']['nodes'] = $nodes;
  }

  // Process nodes by groups of 5.
  $count = min(5, count($context['sandbox']['nodes']));
  for ($i = 1; $i <= $count; $i++) {

    // For each nid, load the node, reset the values, and save it.
    $nid = array_shift($context['sandbox']['nodes']);
    $node = _node_mass_update_helper($nid, $updates);

    // Store result for post-processing in the finished callback.
    $context['results'][] = l($node->title, 'node/' . $node->nid);

    // Update our progress information.
    $context['sandbox']['progress']++;
  }

  // Inform the batch engine that we are not finished,
  // and provide an estimation of the completion level we reached.
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}