Skip to content
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

pkp/pkp-lib#10367 Hooks for chapter or publication format update #1690

Open
wants to merge 2 commits into
base: stable-3_3_0
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
12 changes: 12 additions & 0 deletions controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Expand Down
5 changes: 5 additions & 0 deletions controllers/grid/users/chapter/ChapterGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
5 changes: 3 additions & 2 deletions controllers/grid/users/chapter/form/ChapterForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down
Loading