From 997c7f3b01e03d8a3eb3462472c36cf826fef7f8 Mon Sep 17 00:00:00 2001 From: Thiago Date: Wed, 4 Sep 2024 15:32:50 -0400 Subject: [PATCH 1/2] Call form execute hook after object update --- .../grid/catalogEntry/form/IdentificationCodeForm.inc.php | 4 +++- .../grid/catalogEntry/form/PublicationFormatForm.inc.php | 5 +++-- controllers/grid/users/chapter/form/ChapterForm.inc.php | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/controllers/grid/catalogEntry/form/IdentificationCodeForm.inc.php b/controllers/grid/catalogEntry/form/IdentificationCodeForm.inc.php index 1c988d8baff..4210987d6d6 100644 --- a/controllers/grid/catalogEntry/form/IdentificationCodeForm.inc.php +++ b/controllers/grid/catalogEntry/form/IdentificationCodeForm.inc.php @@ -177,7 +177,6 @@ public function readInputData() { * @copydoc Form::execute() */ public function execute(...$functionArgs) { - parent::execute(...$functionArgs); $identificationCodeDao = DAORegistry::getDAO('IdentificationCodeDAO'); /* @var $identificationCodeDao IdentificationCodeDAO */ $publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO'); /* @var $publicationFormatDao PublicationFormatDAO */ @@ -209,6 +208,9 @@ public function execute(...$functionArgs) { $identificationCodeId = $identificationCodeDao->insertObject($identificationCode); } + // in order to be able to use the hook + parent::execute(...$functionArgs); + return $identificationCodeId; } } diff --git a/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php b/controllers/grid/catalogEntry/form/PublicationFormatForm.inc.php index 17030b384f0..c065e47d6a7 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,9 @@ function execute(...$functionParams) { SubmissionLog::logEvent(Application::get()->getRequest(), $this->getMonograph(), SUBMISSION_LOG_PUBLICATION_FORMAT_CREATE, 'submission.event.publicationFormatCreated', array('formatName' => $publicationFormat->getLocalizedName())); } + // in order to be able to use the hook + parent::execute(...$functionParams); + return $representationId; } } diff --git a/controllers/grid/users/chapter/form/ChapterForm.inc.php b/controllers/grid/users/chapter/form/ChapterForm.inc.php index d262f87e711..f3981c45b12 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,9 @@ function execute(...$functionParams) { DAORegistry::getDAO('SubmissionFileDAO')->updateChapterFiles($selectedFiles, $this->getChapter()->getId()); } + // in order to be able to use the hook + parent::execute(...$functionParams); + return true; } } From f1626b67e08dce03434267ec178266b57c664141 Mon Sep 17 00:00:00 2001 From: Thiago Date: Wed, 4 Sep 2024 15:54:32 -0400 Subject: [PATCH 2/2] Call publication edit hook when chapter and representation is updated --- .../PublicationFormatGridHandler.inc.php | 12 ++++++++++++ .../grid/users/chapter/ChapterGridHandler.inc.php | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php b/controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php index 4c95898eec0..f0910c7e6cf 100644 --- a/controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php +++ b/controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php @@ -320,6 +320,10 @@ function deleteFormat($args, $request) { Services::get('publicationFormat')->deleteFormat($representation, $submission, $context); + // call publication::edit hook when format data is updated + $publication = $this->getPublication(); + $publication = Services::get('publication')->edit($publication, [], $request); + $currentUser = $request->getUser(); $notificationMgr = new NotificationManager(); $notificationMgr->createTrivialNotification($currentUser->getId(), NOTIFICATION_TYPE_SUCCESS, array('contents' => __('notification.removedPublicationFormat'))); @@ -383,6 +387,10 @@ function setApproved($args, $request) { $publicationFormatTombstoneMgr->insertTombstoneByPublicationFormat($representation, $request->getContext()); } + // call publication::edit hook when format data is updated + $publication = $this->getPublication(); + $publication = Services::get('publication')->edit($publication, [], $request); + return DAO::getDataChangedEvent($representation->getId()); } @@ -425,6 +433,10 @@ function setAvailable($args, $request) { $publicationFormatTombstoneMgr->insertTombstoneByPublicationFormat($publicationFormat, $context); } + // call publication::edit hook when format data is updated + $publication = $this->getPublication(); + $publication = Services::get('publication')->edit($publication, [], $request); + return DAO::getDataChangedEvent($publicationFormat->getId()); } diff --git a/controllers/grid/users/chapter/ChapterGridHandler.inc.php b/controllers/grid/users/chapter/ChapterGridHandler.inc.php index 8097ac269c6..b7bb0c49091 100644 --- a/controllers/grid/users/chapter/ChapterGridHandler.inc.php +++ b/controllers/grid/users/chapter/ChapterGridHandler.inc.php @@ -482,6 +482,11 @@ function deleteChapter($args, $request) { $chapterDao = DAORegistry::getDAO('ChapterDAO'); /* @var $chapterDao ChapterDAO */ $chapterDao->deleteById($chapterId); + + // call publication::edit hook when chapter data is updated + $publication = $this->getPublication(); + $publication = Services::get('publication')->edit($publication, [], $request); + return DAO::getDataChangedEvent(); }