Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#8940 consider urnCheckNo setting, fix publish preview #1396

Merged
merged 3 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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