diff --git a/classes/issue/DAO.php b/classes/issue/DAO.php index c76f9e2b479..a981d79a2c8 100644 --- a/classes/issue/DAO.php +++ b/classes/issue/DAO.php @@ -1,4 +1,5 @@ join('issues AS i', 'ist.issue_id', '=', 'i.issue_id') ->where('ist.setting_name', '=', "pub-id::{$pubIdType}") - ->where('ist.setting_value', '<>', $pubId) + ->where('ist.setting_value', '=', $pubId) ->where('i.issue_id', '<>', $excludePubObjectId) ->where('i.journal_id', '=', $contextId) ->count() > 0; diff --git a/classes/journal/JournalDAO.php b/classes/journal/JournalDAO.php index 68c2c778261..5b1b716e38b 100644 --- a/classes/journal/JournalDAO.php +++ b/classes/journal/JournalDAO.php @@ -118,7 +118,7 @@ public function anyPubIdExists( $pubObjectDaos = [ Application::ASSOC_TYPE_ISSUE => Repo::issue()->dao, Application::ASSOC_TYPE_PUBLICATION => Repo::publication()->dao, - Application::ASSOC_TYPE_GALLEY => Application::getRepresentationDAO(), + Application::ASSOC_TYPE_REPRESENTATION => Application::getRepresentationDAO(), Application::ASSOC_TYPE_ISSUE_GALLEY => DAORegistry::getDAO('IssueGalleyDAO'), Application::ASSOC_TYPE_SUBMISSION_FILE => Repo::submissionFile()->dao, ]; diff --git a/classes/plugins/PubIdPlugin.php b/classes/plugins/PubIdPlugin.php index e0102724d21..37e743402fc 100644 --- a/classes/plugins/PubIdPlugin.php +++ b/classes/plugins/PubIdPlugin.php @@ -140,18 +140,16 @@ public function getPubObjectTypes() /** * @copydoc PKPPubIdPlugin::checkDuplicate() */ - public function checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId) + public function checkDuplicate($pubId, $pubObject, $contextId) { - foreach ($this->getPubObjectTypes() as $type => $fqcn) { - if ($type === 'Issue') { - $excludeTypeId = $type === $pubObjectType ? $excludeId : null; - if (Repo::issue()->dao->pubIdExists($this->getPubIdType(), $pubId, $excludeTypeId, $contextId)) { - return false; - } + $allowedPubObjectTypes = $this->getPubObjectTypes(); + if ($pubObject instanceof $allowedPubObjectTypes['Issue']) { + if (Repo::issue()->dao->pubIdExists($this->getPubIdType(), $pubId, $pubObject->getId(), $contextId)) { + return false; } + return true; } - - return parent::checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId); + return parent::checkDuplicate($pubId, $pubObject, $contextId); } /** diff --git a/plugins/pubIds/urn/URNPubIdPlugin.php b/plugins/pubIds/urn/URNPubIdPlugin.php index 3080fef68b1..a12acdcba35 100755 --- a/plugins/pubIds/urn/URNPubIdPlugin.php +++ b/plugins/pubIds/urn/URNPubIdPlugin.php @@ -21,6 +21,7 @@ use APP\plugins\PubIdPlugin; use APP\plugins\pubIds\urn\classes\form\FieldPubIdUrn; use APP\plugins\pubIds\urn\classes\form\FieldTextUrn; +use APP\plugins\pubIds\urn\classes\form\URNSettingsForm; use APP\template\TemplateManager; use PKP\components\forms\FormComponent; use PKP\components\forms\publication\PKPPublicationIdentifiersForm; @@ -157,7 +158,7 @@ public function getPubIdAssignFile() */ public function instantiateSettingsForm($contextId) { - return new classes\form\URNSettingsForm($this, $contextId); + return new URNSettingsForm($this, $contextId); } /** @@ -312,7 +313,7 @@ public function validatePublicationUrn(string $hookName, array $args): void if (strpos($props['pub-id::other::urn'], $urnPrefix) !== 0) { $urnErrors[] = __('plugins.pubIds.urn.editor.missingPrefix', ['urnPrefix' => $urnPrefix]); } - if (!$this->checkDuplicate($props['pub-id::other::urn'], 'Publication', $submission->getId(), $contextId)) { + if (!$this->checkDuplicate($props['pub-id::other::urn'], $publication, $contextId)) { $urnErrors[] = $this->getNotUniqueErrorMsg(); } if (!empty($urnErrors)) {