function biblio_import_finalize in Bibliography Module 7
Same name and namespace in other branches
- 6.2 includes/biblio.import.export.inc \biblio_import_finalize()
- 6 biblio.import.export.inc \biblio_import_finalize()
- 7.2 includes/biblio.import.export.inc \biblio_import_finalize()
2 calls to biblio_import_finalize()
- biblio_import_batch_finished in includes/
biblio.import.export.inc - biblio_import_form_submit in includes/
biblio.import.export.inc - Implementation of hook_submit() for the biblio_import_form.
File
- includes/
biblio.import.export.inc, line 377 - Functions that are used to import and export biblio data.
Code
function biblio_import_finalize($success, $results) {
global $user;
$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);
foreach ($dups as $nid) {
$message = '';
$message = t('The item you are trying to import already exists in the database, see');
$message .= ' ' . l('node/' . $nid, 'node/' . $nid);
drupal_set_message($message, 'status');
watchdog($format, $message, array(), WATCHDOG_ERROR);
}
}
}
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);
}
$userid = isset($results['userid']) ? $results['userid'] : $user->uid;
if (user_access('administer biblio') && count($nids) && $user->uid != $userid) {
db_update('node')
->fields(array(
'uid' => $results['userid'],
))
->condition('nid', $nids, 'IN')
->execute();
db_update('node_revision')
->fields(array(
'uid' => $results['userid'],
))
->condition('nid', $nids, 'IN')
->execute();
}
}