diff --git a/plugins/importexport/csv/CSVImportExportPlugin.inc.php b/plugins/importexport/csv/CSVImportExportPlugin.inc.php index 5bcff5e425..218f7017b0 100755 --- a/plugins/importexport/csv/CSVImportExportPlugin.inc.php +++ b/plugins/importexport/csv/CSVImportExportPlugin.inc.php @@ -200,8 +200,8 @@ function executeCLI($scriptName, &$args) { $submissionDao->updateObject($submission); $contactEmail = $press->getContactEmail(); - $authorString = trim($authorString, '"'); // remove double quotes if present. - $authors = preg_split('/;/', $authorString); + $authorsString = trim($authorString, '"'); // remove double quotes if present. + $authors = preg_split('/;/', $authorsString); $firstAuthor = true; foreach ($authors as $authorString) { @@ -226,12 +226,21 @@ function executeCLI($scriptName, &$args) { $author->setGivenName($givenName, $locale); $author->setFamilyName($familyName, $locale); $author->setEmail($emailAddress); + $insertPrimaryContactId = false; + if ($firstAuthor) { - $author->setPrimaryContact(1); + $author->setPrimaryContact(true); $firstAuthor = false; + $insertPrimaryContactId = true; } + + $author->setData('publicationId', $publicationId); $authorDao->insertObject($author); + + if ($insertPrimaryContactId) { + $publication->setData('primaryContactId', $author->getId()); + } } // Authors done. $publication->setData('abstract', $abstract, $locale);