Skip to content

[OPS][main] #10669 Change Version support for publications #971

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
18 changes: 18 additions & 0 deletions classes/components/forms/publication/PublishForm.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file classes/components/form/publication/PublishForm.php
*
Expand All @@ -15,6 +16,7 @@

namespace APP\components\forms\publication;

use APP\facades\Repo;
use APP\publication\Publication;
use PKP\components\forms\FieldHTML;
use PKP\components\forms\FormComponent;
Expand Down Expand Up @@ -56,6 +58,22 @@ public function __construct($action, $publication, $submissionContext, $requirem
'label' => $submitLabel,
],
]);

// If publication does not have a version stage assigned
$publicationVersion = $publication->getVersion();
if (!isset($publicationVersion)) {
$submission = Repo::submission()->get($publication->getData('submissionId'));
$nextVersion = Repo::submission()->getNextAvailableVersion($submission, Publication::DEFAULT_VERSION_STAGE, false);

$msg .= '<p>' . __('publication.required.versionStage') . '</p>';
$msg .= '<p>' . __('publication.required.versionStage.assignment', [
'versionString' => $nextVersion
]) . '</p>';
} else {
$msg .= '<p>' . __('publication.required.versionStage.alreadyAssignment', [
'versionString' => $publicationVersion
]) . '</p>';
}
} else {
$msg = '<p>' . __('publication.publish.requirements') . '</p>';
$msg .= '<ul>';
Expand Down
12 changes: 11 additions & 1 deletion classes/migration/install/OPSMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace APP\migration\install;

use APP\publication\enums\VersionStage;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
Expand Down Expand Up @@ -87,12 +88,21 @@ public function up(): void

$table->tinyInteger('status')->default(1); // PKPSubmission::STATUS_QUEUED
$table->string('url_path', 64)->nullable();
$table->bigInteger('version')->nullable();
$table->index(['url_path'], 'publications_url_path');

$table->bigInteger('doi_id')->nullable();
$table->foreign('doi_id')->references('doi_id')->on('dois')->nullOnDelete();
$table->index(['doi_id'], 'publications_doi_id');

$table->enum('version_stage', array_column(VersionStage::cases(), 'value'))->nullable();
$table->integer('version_minor')->nullable();
$table->integer('version_major')->nullable();
$table->datetime('created_at')->after('date_published');

$table->bigInteger('source_publication_id')->nullable()->after('publication_id');
$table->foreign('source_publication_id', 'publications_source_publication_id')
->references('publication_id')->on('publications')->nullOnDelete();
$table->index(['source_publication_id'], 'publications_source_publication_id_index');
});
// The following foreign key relationships are for tables defined in SubmissionsMigration
// but they depend on publications to exist so are created here.
Expand Down
8 changes: 6 additions & 2 deletions classes/publication/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ class DAO extends \PKP\publication\DAO
'submissionId' => 'submission_id',
'status' => 'status',
'urlPath' => 'url_path',
'version' => 'version',
'doiId' => 'doi_id'
'doiId' => 'doi_id',
'versionStage' => 'version_stage',
'versionMinor' => 'version_minor',
'versionMajor' => 'version_major',
'createdAt' => 'created_at',
'sourcePublicationId' => 'source_publication_id'
];

/**
Expand Down
3 changes: 3 additions & 0 deletions classes/publication/Publication.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@

use APP\core\Application;
use APP\file\PublicFileManager;
use APP\publication\enums\VersionStage;
use PKP\publication\PKPPublication;

class Publication extends PKPPublication
{
public const DEFAULT_VERSION_STAGE = VersionStage::AUTHOR_ORIGINAL;

public const PUBLICATION_RELATION_NONE = 1;
public const PUBLICATION_RELATION_PUBLISHED = 3;

Expand Down
5 changes: 3 additions & 2 deletions classes/publication/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use APP\core\Application;
use APP\facades\Repo;
use APP\publication\enums\VersionStage;
use APP\submission\Submission;
use Illuminate\Support\Facades\App;
use PKP\context\Context;
Expand Down Expand Up @@ -96,9 +97,9 @@ public function validate($publication, array $props, Submission $submission, Con
}

/** @copydoc \PKP\publication\Repository::version() */
public function version(Publication $publication): int
public function version(Publication $publication, ?VersionStage $versionStage = null, bool $isMinorVersion = true): int
{
$newId = parent::version($publication);
$newId = parent::version($publication, $versionStage, $isMinorVersion);

$context = Application::get()->getRequest()->getContext();

Expand Down
36 changes: 36 additions & 0 deletions classes/publication/enums/VersionStage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* @file publication/enums/VersionStage.php
*
* Copyright (c) 2023-2024 Simon Fraser University
* Copyright (c) 2023-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class VersionStage
*
* @brief Enumeration for publication version stages
*
* see also https://www.niso.org/standards-committees/jav-revision
*/

namespace APP\publication\enums;

enum VersionStage: string
{
case AUTHOR_ORIGINAL = 'AO';
case SUBMITTED_MANUSCRIPT = 'SM';

public function labelKey(): string
{
return match ($this) {
self::AUTHOR_ORIGINAL => 'publication.versionStage.authorOriginal',
self::SUBMITTED_MANUSCRIPT => 'publication.versionStage.submittedManuscript',
};
}

public function label(?string $locale = null): string
{
return __($this->labelKey(), locale: $locale);
}
}
8 changes: 6 additions & 2 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,15 @@
<migration class="APP\migration\install\ReviewerRecommendationsMigration" />
<migration class="APP\migration\upgrade\v3_6_0\I1660_ReviewerRecommendations"/>
<migration class="APP\migration\upgrade\v3_6_0\I10404_UpdateCategoryImageNameFields"/>
<note file="docs/release-notes/README-3.6.0" />
</upgrade>

<upgrade minversion="3.1.0.0" maxversion="3.5.9.9">
<note file="docs/release-notes/README-3.6.0" />
</upgrade>
<migration class="PKP\migration\upgrade\v3_6_0\I4860_MigratePublicationVersion"/>
<migration class="PKP\migration\upgrade\v3_6_0\I4860_MigratePublicationAddCreatedAt"/>
<migration class="PKP\migration\upgrade\v3_6_0\I4860_MigratePublicationVersionSourcePublicationId"/>
<note file="docs/release-notes/README-3.6.0" />
</upgrade>

<!-- update plugin configuration - should be done as the final upgrade task -->
<code function="addPluginVersions" />
Expand Down
8 changes: 7 additions & 1 deletion locale/en/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,10 @@ msgstr "Add any information that you think our moderators should know before pos
msgid "submission.copyright.description"
msgstr ""
"Please read and understand the copyright terms for submissions to this "
"preprint server."
"preprint server."

msgid "publication.versionStage.authorOriginal"
msgstr "Author Original"

msgid "publication.versionStage.submittedManuscript"
msgstr "Submitted Manuscript"
2 changes: 1 addition & 1 deletion templates/frontend/objects/preprint_details.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
</h2>
<ul class="value">
{foreach from=array_reverse($preprint->getPublishedPublications()) item=iPublication}
{capture assign="name"}{translate key="submission.versionIdentity" datePublished=$iPublication->getData('datePublished')|date_format:$dateFormatShort version=$iPublication->getData('version')}{/capture}
{capture assign="name"}{translate key="submission.versionIdentity" datePublished=$iPublication->getData('datePublished')|date_format:$dateFormatShort version=$iPublication->getData('versionString')}{/capture}
<li>
{if $iPublication->getId() === $publication->getId()}
{$name}
Expand Down