You are here

function biblio_import_finalize in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 includes/biblio.import.export.inc \biblio_import_finalize()
  2. 7 includes/biblio.import.export.inc \biblio_import_finalize()
  3. 7.2 includes/biblio.import.export.inc \biblio_import_finalize()
2 calls to biblio_import_finalize()
biblio_import_batch_finished in ./biblio.import.export.inc
biblio_import_form_submit in ./biblio.import.export.inc
Implementation of hook_submit() for the biblio_import_form.

File

./biblio.import.export.inc, line 306
Functions that are used to import and export biblio data.

Code

function biblio_import_finalize($success, $results) {
  $format = $results['format'];
  $nids = $results['nids'];
  $dups = $results['dups'];
  $total = count($nids) + count($dups);

  //    drupal_set_message(t("<i><b>%count</b></i> of <i><b>%total</b></i> nodes were successfully imported.", array('%count' => count($nids), '%total' => $total)), (count($nids) != $total)?'warning':'status');
  if ($success && (count($nids) || count($dups))) {
    $message = t("The file <i><b>@file</b></i> was successfully uploaded.", array(
      '@file' => $results['file']->filename,
    ));
    drupal_set_message($message, 'status');
    watchdog($format, $message);
    $count = count($nids);
    $message = format_plural($count, 'One of @total node imported.', '@count of @total nodes imported.', array(
      '@total' => $total,
    ));
    drupal_set_message($message, 'status');
    watchdog($format, $message, array(
      '@count' => $count,
      '@total' => $total,
    ), WATCHDOG_INFO);
    if (count($dups)) {
      $count = count($dups);
      $message = format_plural($count, 'One duplicate node skipped.', '@count duplicate nodes skipped.');
      drupal_set_message($message, 'status');
      watchdog($format, $message, array(
        '@count' => $count,
      ), WATCHDOG_INFO);
    }
  }
  else {
    $count = count($nids);
    $message = t('Import finished with an error!  ') . format_plural($count, 'One node imported.', '@count nodes imported.');
    drupal_set_message($message, 'error');
    watchdog($format, $message, array(
      '@count' => $count,
    ), WATCHDOG_ERROR);
  }
  $user = $results['user'];
  $userid = $results['userid'];
  if (user_access('administer biblio') && count($nids) && $user->uid != $userid) {
    db_query('UPDATE {node} SET uid = %d WHERE nid IN(%s)', $userid, implode(',', $nids));
    db_query('UPDATE {node_revisions} SET uid = %d WHERE nid IN(%s)', $userid, implode(',', $nids));
  }
}