diff --git a/classes/monograph/ChapterDAO.php b/classes/monograph/ChapterDAO.php index 8bbcd74adb9..6e78402be93 100644 --- a/classes/monograph/ChapterDAO.php +++ b/classes/monograph/ChapterDAO.php @@ -115,8 +115,6 @@ public function getByDoiId(int $doiId): DAOResultFactory /** * Retrieve all chapters by source chapter id. - * - * */ public function getBySourceChapterId(int $sourceChapterId, bool $orderByPublicationId = true): DAOResultFactory { @@ -134,6 +132,23 @@ public function getBySourceChapterId(int $sourceChapterId, bool $orderByPublicat ); } + /** + * Retrieve a chapter by source chapter ID and publication ID. + */ + public function getChapterBySourceChapterId(int $sourceChapterId, int $publicationId): Chapter|null + { + $result = $this->retrieve( + 'SELECT * + FROM submission_chapters + WHERE (source_chapter_id = ? OR (source_chapter_id IS NULL AND chapter_id = ?)) + AND publication_id = ?', + [$sourceChapterId, $sourceChapterId, $publicationId] + ); + + $row = $result->current(); + return $row ? $this->_fromRow((array) $row) : null; + } + /** * Get the list of fields for which locale data is stored. * @@ -141,7 +156,12 @@ public function getBySourceChapterId(int $sourceChapterId, bool $orderByPublicat */ public function getLocaleFieldNames() { - return ['title', 'subtitle','abstract']; + $localFieldNames = parent::getLocaleFieldNames(); + $localFieldNames[] = 'title'; + $localFieldNames[] = 'subtitle'; + $localFieldNames[] = 'abstract'; + + return $localFieldNames; } /** diff --git a/pages/catalog/CatalogBookHandler.php b/pages/catalog/CatalogBookHandler.php index 1d019956002..c0b7925a1ca 100755 --- a/pages/catalog/CatalogBookHandler.php +++ b/pages/catalog/CatalogBookHandler.php @@ -288,7 +288,7 @@ public function book($args, $request) } // Display - if (!Hook::call('CatalogBookHandler::book', [&$request, &$submission])) { + if (!Hook::call('CatalogBookHandler::book', [&$request, &$submission, &$this->publication, &$this->chapter])) { $templateMgr->display('frontend/pages/book.tpl'); if ($this->isChapterRequest) { event(new UsageEvent(Application::ASSOC_TYPE_CHAPTER, $request->getContext(), $submission, null, null, $this->chapter));