You are here

function feeds_import_form_submit in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 feeds.pages.inc \feeds_import_form_submit()
  2. 6 feeds.pages.inc \feeds_import_form_submit()
  3. 7 feeds.pages.inc \feeds_import_form_submit()

Submit handler for feeds_import_form().

File

./feeds.pages.inc, line 143
Menu callbacks, form callbacks and helpers.

Code

function feeds_import_form_submit($form, &$form_state) {

  // Save source and import.
  $source = feeds_source($form['#importer_id']);
  if (!empty($form_state['values']['feeds']) && is_array($form_state['values']['feeds'])) {
    $source
      ->addConfig($form_state['values']['feeds']);
    $source
      ->save();
  }

  // Refresh feed if import on create is selected.
  if ($source->importer->config['import_on_create']) {
    $source
      ->startImport();
    if ($source->importer->config['process_in_background']) {
      drupal_set_message(t('Import scheduled.'));
    }
  }

  // Add to schedule, make sure importer is scheduled, too.
  $source
    ->ensureSchedule();

  // If an import is only triggered by periodic import, check if it is about to
  // be rescheduled so there is at least a message.
  if (!$source->importer->config['import_on_create']) {

    // Check if the importer is about to be rescheduled.
    $importers = feeds_reschedule();
    if (isset($importers[$form['#importer_id']])) {
      drupal_set_message(t('Rescheduling the import will happen on the next cron run.'), 'status');
    }
  }
}