You are here

function date_copy_import_event_form_submit in Date 5

Same name and namespace in other branches
  1. 5.2 date_copy/date_copy.module \date_copy_import_event_form_submit()
  2. 6 date_copy/date_copy.module \date_copy_import_event_form_submit()

Event import processing.

File

./date_copy.module, line 489

Code

function date_copy_import_event_form_submit($form_id, $form_values) {
  extract($form_values);
  if ($step != 2) {
    return;
  }

  // workaround to disable drupal messages when nodes are created or deleted
  $messages = drupal_get_messages();
  $rows = array();
  $i = 0;

  // Get $max records, 10 at a time.
  $limit = min(10, intval($max));
  while ($i < intval($max)) {
    $new_rows = date_copy_convert_events($source_type, $target_type, $date_field, $description_field, $limit, $i, $delete_old, $start_nid);
    $rows = array_merge($rows, $new_rows);
    $i += $limit;
  }

  // write back the old messages
  $_SESSION['messages'] = $messages;
  if (!empty($rows)) {
    drupal_set_message(t('%limit events have been converted.', array(
      '%limit' => sizeof($rows),
    )));
    drupal_set_message(theme('table', array(
      t('Title'),
      t('Source Id'),
      t('Target Id'),
      t('Start'),
      t('End'),
    ), $rows));
  }
  else {
    drupal_set_message(t('No events have been converted.'));
  }
  return;
}