You are here

function date_tools_copy_import_event_form_submit in Date 6.2

Event import processing.

File

date_tools/date_tools.event.inc, line 78
Code to migrate Events to use Date fields instead.

Code

function date_tools_copy_import_event_form_submit($form, &$form_state) {
  $form_state['rebuild'] = TRUE;
  extract($form_state['values']);
  if ($step != 2) {
    return;
  }

  // workaround to disable drupal messages when nodes are created or deleted

  //$messages = drupal_get_messages();

  // The array that maps event timezone zids to timezone names is in
  // date_php4_tz_map.inc, need to reverse it so the zid is the key.
  require_once './' . drupal_get_path('module', 'date_php4') . '/date_php4_tz_map.inc';
  $timezones = array(
    '' => '',
  );
  $map = $timezone_map;
  foreach ($map as $zone => $values) {
    if (!empty($values['zid'])) {
      $timezones[$values['zid']] = $zone;
    }
  }
  $rows = array();
  $i = 0;

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

  // write back the old messages

  //$_SESSION['messages'] = $messages;
  if (!empty($rows)) {
    drupal_set_message(format_plural(sizeof($rows), '1 event has been converted.', '@count events have been converted.'));
    drupal_set_message(theme('table', array(
      t('Node Title'),
      t('Original Node ID'),
      t('New Node ID'),
      t('Start date'),
      t('End date'),
    ), $rows));
  }
  else {
    drupal_set_message(t('No events have been converted.'));
  }
  return;
}