You are here

function node_recur_node_batch_start in Node recur 7

Same name and namespace in other branches
  1. 7.2 node_recur.module \node_recur_node_batch_start()

Start the batch to generate recurring nodes

1 call to node_recur_node_batch_start()
node_recur_node_recur_confirm_submit in ./node_recur.pages.inc
Submit the node recur confirmation form

File

./node_recur.batch.inc, line 6

Code

function node_recur_node_batch_start($node, $start_dates, $end_dates = array()) {

  // Generate the batch operations
  $operations = array();
  if ($start_dates) {
    foreach ($start_dates as $key => $start_date) {
      $operations[] = array(
        'node_recur_node_batch_create_node',
        array(
          $node,
          $start_date,
          isset($end_dates[$key]) ? $end_dates[$key] : NULL,
        ),
      );
    }
  }

  // Generate the batch
  $batch = array(
    'title' => t('Generating items'),
    'operations' => $operations,
    'finished' => 'node_recur_node_batch_finished',
    'file' => drupal_get_path('module', 'node_recur') . '/node_recur.batch.inc',
  );

  // @todo: Best way to pass into finished callback?
  $_SESSION['batch_recur_nid'] = $node->nid;
  batch_set($batch);
}