From 4f8a69e148225aaf4e76a0109cbfd0493d43e17f Mon Sep 17 00:00:00 2001 From: Jhon Date: Thu, 9 Apr 2026 15:05:25 -0400 Subject: [PATCH] Considers DOI versioning setting in preprint deposit Signed-off-by: Jhon --- filter/PreprintCrossrefXmlFilter.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/filter/PreprintCrossrefXmlFilter.php b/filter/PreprintCrossrefXmlFilter.php index 3bce08592f..d386911d78 100644 --- a/filter/PreprintCrossrefXmlFilter.php +++ b/filter/PreprintCrossrefXmlFilter.php @@ -17,6 +17,7 @@ use APP\core\Application; use APP\plugins\generic\crossref\CrossrefExportDeployment; use APP\publication\Publication; +use PKP\context\Context; use DOMDocument; use PKP\i18n\LocaleConversion; use PKP\submission\PKPSubmission; @@ -64,10 +65,16 @@ public function &process(&$pubObjects) $bodyNode = $doc->createElementNS($deployment->getNamespace(), 'body'); $rootNode->appendChild($bodyNode); + $doiVersioning = (bool) ($context->getData(Context::SETTING_DOI_VERSIONING) ?? true); foreach ($pubObjects as $pubObject) { - $publications = $pubObject->getData('publications')->toArray(); - // Use array reverse so that the latest version of the submission is first in the xml output and the DOI relations do not cause an error with Crossref - $publications = array_reverse($publications, true); + if (!$doiVersioning) { + $publications = [$pubObject->getCurrentPublication()]; + } else { + $publications = $pubObject->getData('publications')->toArray(); + // Use array reverse so that the latest version of the submission is first in the xml output and the DOI relations do not cause an error with Crossref + $publications = array_reverse($publications, true); + } + foreach ($publications as $publication) { if ($publication->getDoi() && $publication->getData('status') === PKPSubmission::STATUS_PUBLISHED) { $postedContentNode = $this->createPostedContentNode($doc, $publication, $pubObject); @@ -118,7 +125,8 @@ public function createHeadNode($doc) $plugin = $deployment->getPlugin(); $headNode = $doc->createElementNS($deployment->getNamespace(), 'head'); $headNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'doi_batch_id', htmlspecialchars($context->getData('acronym', $context->getPrimaryLocale()) . '_' . time(), ENT_COMPAT, 'UTF-8'))); - $headNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'timestamp', date('YmdHisv'))); + $timestamp = (new \DateTime())->format('YmdHisv'); + $headNode->appendChild($doc->createElementNS($deployment->getNamespace(), 'timestamp', $timestamp)); $depositorNode = $doc->createElementNS($deployment->getNamespace(), 'depositor'); $depositorName = $plugin->getSetting($context->getId(), 'depositorName'); if (empty($depositorName)) {