You are here

function biblio_form_import_submit in Bibliography Module 5

File

./biblio.module, line 2878

Code

function biblio_form_import_submit($form_id, $form_values) {
  $op = $form_values['op'];
  if ($form_values['op'] == t('Import') && isset($form_values['filetype'])) {
    $import = file_check_upload('file_upload');
    if ($import) {
      $import = file_save_upload($import);
      drupal_set_message(t("@file was uploaded", array(
        '@file' => $import->filename,
      )), 'status');

      // Concatenate all the terms of the different vocabularies
      // in a single array to be sent to _biblio_import
      $terms = array();
      foreach (array_keys($form_values) as $key) {
        if (preg_match('/(vocabulary[0-9]+)/', $key)) {
          if ($form_values[$key] > 0) {
            $terms[] = $form_values[$key];
          }
        }
      }

      // Added the $terms argument
      // the array of terms to be attached to the node(s)
      $userid = isset($form_values['userid']) ? $form_values['userid'] : 1;
      $filetype = $form_values['filetype'];
      $content = _biblio_import($userid, $import->filepath, $filetype, $terms);
      file_delete($import->filepath);
    }
    else {
      drupal_set_message(t("File was NOT successfully uploaded"), 'error');
    }
  }
}