Skip to content

Commit

Permalink
fix bug to add an author as a primary contact to a submission
Browse files Browse the repository at this point in the history
  • Loading branch information
Godoy0722 committed Jul 3, 2024
1 parent ab1c367 commit 5e65efa
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions plugins/importexport/csv/CSVImportExportPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 5e65efa

Please sign in to comment.