You are here

function quotes_submit in Quotes 5

Implementation of hook_submit().

File

./quotes.module, line 358

Code

function quotes_submit(&$node) {
  global $_quotes_importing;

  // Bail if we are actively importing or doing a single quote.
  if ($_quotes_importing || arg(3) != 'import') {
    return;
  }

  // If the node is being submitted, we will perform the actual import
  // here, submitting each imported quote as a separate node.
  $_quotes_importing = TRUE;
  $count = 0;
  foreach (_quotes_parse_import($node, TRUE) as $quote) {
    ++$count;
    $temp = $node;
    $temp->body = $quote->body;
    $temp->teaser = '';
    $temp->quotes_author = $quote->quotes_author;
    $temp->quotes_citation = $quote->quotes_citation;
    drupal_execute('quotes_node_form', (array) $temp, array(
      'type' => 'quotes',
    ));
    if (form_get_errors()) {
      form_set_error('body', t('Only the first !count quotes were imported.', array(
        '!count' => $count,
      )));
      return;
    }
  }
  $_quotes_importing = FALSE;
  drupal_set_message(t('!count quotes imported.', array(
    '!count' => $count,
  )));
  drupal_goto('quotes');
}