From 5e65efa3f1229f4825d9ef9dca5c364fe195a515 Mon Sep 17 00:00:00 2001 From: Guilherme Godoy Date: Wed, 3 Jul 2024 09:29:14 +0100 Subject: [PATCH] fix bug to add an author as a primary contact to a submission --- .../csv/CSVImportExportPlugin.inc.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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);