From a45c2fa9127d58a3ecfe408ccbed1921695ec574 Mon Sep 17 00:00:00 2001 From: Thiago Date: Mon, 2 Sep 2024 20:12:29 -0400 Subject: [PATCH 1/2] Call publication edit hook when chapter and representation is updated --- .../grid/catalogEntry/PublicationFormatGridHandler.inc.php | 6 ++++++ .../grid/catalogEntry/form/PublicationFormatForm.inc.php | 4 ++-- controllers/grid/users/chapter/ChapterGridHandler.inc.php | 4 ++-- controllers/grid/users/chapter/form/ChapterForm.inc.php | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php b/controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php index 4c95898eec0..c8c8c2d092a 100644 --- a/controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php +++ b/controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php @@ -324,6 +324,8 @@ function deleteFormat($args, $request) { $notificationMgr = new NotificationManager(); $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.removedPublicationFormat'))); + $publication = Services::get('publication')->edit($publication, [], $request); + return DAO::getDataChangedEvent(); } @@ -383,6 +385,8 @@ function setApproved($args, $request) { $publicationFormatTombstoneMgr->insertTombstoneByPublicationFormat($representation, $request->getContext()); } + $publication = Services::get('publication')->edit($publication, [], $request); + return DAO::getDataChangedEvent($representation->getId()); } @@ -425,6 +429,8 @@ function setAvailable($args, $request) { $publicationFormatTombstoneMgr->insertTombstoneByPublicationFormat($publicationFormat, $context); } + $publication = Services::get('publication')->edit($publication, [], $request); + return DAO::getDataChangedEvent($publicationFormat->getId()); } diff --git a/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php b/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php index 17030b384f0..25924cef24a 100644 --- a/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php +++ b/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php @@ -188,8 +188,8 @@ function execute(...$functionParams) { SubmissionLog::logEvent(Application::get()->getRequest(), $this->getMonograph(), SUBMISSION_LOG_PUBLICATION_FORMAT_CREATE, 'submission.event.publicationFormatCreated', array('formatName' => $publicationFormat->getLocalizedName())); } + $publication = Services::get('publication')->edit($publication, [], Application::get()->getRequest()); + return $representationId; } } - - diff --git a/controllers/grid/users/chapter/ChapterGridHandler.inc.php b/controllers/grid/users/chapter/ChapterGridHandler.inc.php index 8097ac269c6..40af8b22c64 100644 --- a/controllers/grid/users/chapter/ChapterGridHandler.inc.php +++ b/controllers/grid/users/chapter/ChapterGridHandler.inc.php @@ -482,6 +482,8 @@ function deleteChapter($args, $request) { $chapterDao = DAORegistry::getDAO('ChapterDAO'); /* @var $chapterDao ChapterDAO */ $chapterDao->deleteById($chapterId); + $publication = $this->getPublication(); + $publication = Services::get('publication')->edit($publication, [], $request); return DAO::getDataChangedEvent(); } @@ -495,5 +497,3 @@ function _getChapterFromRequest($request) { ); } } - - diff --git a/controllers/grid/users/chapter/form/ChapterForm.inc.php b/controllers/grid/users/chapter/form/ChapterForm.inc.php index d262f87e711..06d5bce9f9c 100644 --- a/controllers/grid/users/chapter/form/ChapterForm.inc.php +++ b/controllers/grid/users/chapter/form/ChapterForm.inc.php @@ -238,8 +238,8 @@ function execute(...$functionParams) { DAORegistry::getDAO('SubmissionFileDAO')->updateChapterFiles($selectedFiles, $this->getChapter()->getId()); } + $publication = Services::get('publication')->edit($publication, [], Application::get()->getRequest()); + return true; } } - - From 606d7eacb5e9d04de3e0609a84b72ec943d76566 Mon Sep 17 00:00:00 2001 From: Thiago Date: Mon, 2 Sep 2024 20:17:58 -0400 Subject: [PATCH 2/2] Call form execute hook after object update --- .../grid/catalogEntry/form/PublicationFormatForm.inc.php | 4 ++-- controllers/grid/users/chapter/form/ChapterForm.inc.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php b/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php index 25924cef24a..ad46d8f1a01 100644 --- a/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php +++ b/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php @@ -155,8 +155,6 @@ function readInputData() { * @see Form::execute() */ function execute(...$functionParams) { - parent::execute(...$functionParams); - $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO'); /* @var $publicationFormatDao PublicationFormatDAO */ $publicationFormat = $this->getPublicationFormat(); if (!$publicationFormat) { @@ -188,6 +186,8 @@ function execute(...$functionParams) { SubmissionLog::logEvent(Application::get()->getRequest(), $this->getMonograph(), SUBMISSION_LOG_PUBLICATION_FORMAT_CREATE, 'submission.event.publicationFormatCreated', array('formatName' => $publicationFormat->getLocalizedName())); } + parent::execute(...$functionParams); + $publication = Services::get('publication')->edit($publication, [], Application::get()->getRequest()); return $representationId; diff --git a/controllers/grid/users/chapter/form/ChapterForm.inc.php b/controllers/grid/users/chapter/form/ChapterForm.inc.php index 06d5bce9f9c..afa0da40f8a 100644 --- a/controllers/grid/users/chapter/form/ChapterForm.inc.php +++ b/controllers/grid/users/chapter/form/ChapterForm.inc.php @@ -198,8 +198,6 @@ function readInputData() { * @see Form::execute() */ function execute(...$functionParams) { - parent::execute(...$functionParams); - $chapterDao = DAORegistry::getDAO('ChapterDAO'); /* @var $chapterDao ChapterDAO */ $chapter = $this->getChapter(); $isEdit = !!$chapter; @@ -238,6 +236,8 @@ function execute(...$functionParams) { DAORegistry::getDAO('SubmissionFileDAO')->updateChapterFiles($selectedFiles, $this->getChapter()->getId()); } + parent::execute(...$functionParams); + $publication = Services::get('publication')->edit($publication, [], Application::get()->getRequest()); return true;