Skip to content

Commit

Permalink
Merge pull request #1396 from bozana/8940
Browse files Browse the repository at this point in the history
pkp/pkp-lib#8940 consider urnCheckNo setting, fix publish preview
  • Loading branch information
bozana authored Apr 28, 2023
2 parents f1f2878 + 81277ae commit 6ab05f7
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 205 deletions.
45 changes: 23 additions & 22 deletions classes/plugins/PubIdPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use PKP\core\DataObject;
use PKP\core\PKPString;
use PKP\db\DAORegistry;

use PKP\plugins\PKPPubIdPlugin;
use PKP\submission\Representation;
use PKP\submissionFile\SubmissionFile;
Expand All @@ -45,7 +44,12 @@ public function getPubObjectTypes()
}

/**
* @copydoc PKPPubIdPlugin::getPubId()
* Get the public identifier.
*
* @param object $pubObject
* Publication, Representation, SubmissionFile, Chapter
*
* @return string
*/
public function getPubId($pubObject)
{
Expand All @@ -62,29 +66,26 @@ public function getPubId($pubObject)
$pubObjectType = $this->getPubObjectType($pubObject);

// Initialize variables for publication objects.
$submission = ($pubObjectType == 'Submission' ? $pubObject : null);
$submission = null;
// Publication is actually handled differently now, but keep it here however for now.
$publication = ($pubObjectType == 'Publication' ? $pubObject : null);
$representation = ($pubObjectType == 'Representation' ? $pubObject : null);
$submissionFile = ($pubObjectType == 'SubmissionFile' ? $pubObject : null);
$chapter = ($pubObjectType == 'Chapter' ? $pubObject : null);

// Get the context id.
if ($pubObjectType == 'Submission') {
$contextId = $pubObject->getContextId();
} else {
// Retrieve the submission.
if (is_a($pubObject, 'Chapter') || is_a($pubObject, 'Representation')) {
$publication = Repo::publication()->get($pubObject->getData('publicationId'));
$submission = Repo::submission()->get($publication->getData('submissionId'));
} else {
assert(is_a($pubObject, 'SubmissionFile'));
$submission = Repo::submission()->get($pubObject->getData('submissionId'));
}
if (!$submission) {
return null;
}
// Now we can identify the context.
$contextId = $submission->getContextId();
// Retrieve the submission.
if (is_a($pubObject, 'Chapter') || is_a($pubObject, 'Representation')) {
$publication = Repo::publication()->get($pubObject->getData('publicationId'));
$submission = Repo::submission()->get($publication->getData('submissionId'));
} else { // Publication or SubmissionFile
$submission = Repo::submission()->get($pubObject->getData('submissionId'));
}
if (!$submission) {
return null;
}
// Now we can identify the context.
$contextId = $submission->getData('contextId');

// Check the context
$context = $this->getContext($contextId);
if (!$context) {
Expand Down Expand Up @@ -214,7 +215,7 @@ public static function generateCustomPattern(
*/
public function getDAOs()
{
return array_merge(parent::getDAOs(), ['Chapter' => DAORegistry::getDAO('ChapterDAO')]);
return array_merge(parent::getDAOs(), [DAORegistry::getDAO('ChapterDAO')]);
}

/**
Expand All @@ -233,6 +234,6 @@ public function checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId)
}
}

return true;
return parent::checkDuplicate($pubId, $pubObjectType, $excludeId, $contextId);
}
}
2 changes: 2 additions & 0 deletions js/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import CatalogListPanel from '@/components/ListPanel/submissions/CatalogListPane

// Required by the URN plugin
import FieldText from '@/components/Form/fields/FieldText.vue';
import FieldPubId from '@/components/Form/fields/FieldPubId.vue';

// Expose Vue, the registry and controllers in a global var
window.pkp = Object.assign(PkpLoad, {
Expand Down Expand Up @@ -65,4 +66,5 @@ window.pkp = Object.assign(PkpLoad, {

// Required by the URN plugin
window.pkp.Vue.component('field-text', FieldText);
window.pkp.Vue.component('field-pub-id', FieldPubId);
window.pkp.Vue.component('catalog-list-panel', CatalogListPanel);
Loading

0 comments on commit 6ab05f7

Please sign in to comment.