Skip to content

Commit

Permalink
pkp/pkp-lib#9468 assign DOIs only to chapters that have a landing pag…
Browse files Browse the repository at this point in the history
…e, and condsider chapter with DOI to have a landing page
  • Loading branch information
bozana committed Aug 14, 2024
1 parent 9cd1808 commit d2bde2d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions api/v1/_dois/BackendDoiHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public function editChapter(SlimRequest $slimRequest, APIResponse $response, arr
if (!$chapter) {
return $response->withStatus(404)->withJsonError('api.404.resourceNotFound');
}
if (!$chapter->isPageEnabled() && empty($chapter->getDoi())) {
return $response->withStatus(403)->withJsonError('api.dois.403.editItemDoiCantBeAssigned');
}

$publication = Repo::publication()->get($chapter->getData('publicationId'));
$submission = Repo::submission()->get($publication->getData('submissionId'));
Expand Down
8 changes: 4 additions & 4 deletions classes/monograph/Chapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,20 +330,20 @@ public function setSourceChapterId(?int $sourceChapterId): void
/**
* Is a landing page enabled or disabled.
*
* @return null|int
* @return null|bool
*/
public function isPageEnabled()
{
return $this->getData('isPageEnabled');
return $this->getData('isPageEnabled') || !empty($this->getDoi());
}

/**
* Enable or disable a landing page.
*
*/
public function setPageEnabled(?int $enable): void
public function setPageEnabled(?bool $enable): void
{
$this->setData('isPageEnabled', $enable);
$this->setData('isPageEnabled', $enable || !empty($this->getDoi()));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/submission/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function createDois(Submission $submission): array
/** @var ChapterDAO $chapterDao */
$chapterDao = DAORegistry::getDAO('ChapterDAO');
foreach ($chapters as $chapter) {
if (empty($chapter->getData('doiId'))) {
if (empty($chapter->getData('doiId')) && $chapter->isPageEnabled()) {
try {
$doiId = Repo::doi()->mintChapterDoi($chapter, $submission, $context);
$chapter->setData('doiId', $doiId);
Expand Down
1 change: 1 addition & 0 deletions controllers/grid/users/chapter/form/ChapterForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ public function fetch($request, $template = null, $display = false)
}, $selectedChapterAuthorsArray),
'chapterFileOptions' => $chapterFileOptions,
'selectedChapterFiles' => $selectedChapterFiles,
'doi' => $this->getChapter()?->getDoi()
]);

return parent::fetch($request, $template, $display);
Expand Down
3 changes: 3 additions & 0 deletions locale/en/submission.po
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ msgstr "Production Discussions"
msgid "publication.chapter.landingPage"
msgstr "Chapter Page"

msgid "publication.chapter.landingPage.doi.description"
msgstr "(This chapter will always be shown on its own page because it has a DOI.)"

msgid "publication.chapter.hasLandingPage"
msgstr ""
"Show this chapter on its own page and link to that page from the book's "
Expand Down
3 changes: 3 additions & 0 deletions templates/controllers/grid/users/chapter/form/chapterForm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@

{fbvFormSection list=true title="publication.chapter.landingPage" for="customExtras"}
{fbvElement type="checkbox" name="isPageEnabled" id="isPageEnabled" checked=$isPageEnabled|compare:true label="publication.chapter.hasLandingPage" value="1" translate="true"}
{if $doi}
<div class="pkpFormField__description">{translate key="publication.chapter.landingPage.doi.description"}</div>
{/if}
{/fbvFormSection}

{fbvFormSection list=true title="submission.submit.addAuthor"}
Expand Down

0 comments on commit d2bde2d

Please sign in to comment.