From c2792b241b6b5637426a156fe7a56ac0fe0e2aee Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Thu, 18 Apr 2024 17:50:12 +0600 Subject: [PATCH] pkp/pkp-lib#4789 Due date fields added for declined review request resending --- .../form/ResendRequestReviewerForm.php | 42 +++++++++++++++++-- .../grid/users/reviewer/form/ReviewerForm.php | 32 +++++++++----- .../form/resendRequestReviewerForm.tpl | 5 +++ 3 files changed, 64 insertions(+), 15 deletions(-) diff --git a/controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php b/controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php index 74772209457..29a189cb37d 100644 --- a/controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php +++ b/controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php @@ -2,8 +2,8 @@ /** * @file controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php * - * Copyright (c) 2014-2022 Simon Fraser University - * Copyright (c) 2003-2022 John Willinsky + * Copyright (c) 2014-2024 Simon Fraser University + * Copyright (c) 2003-2024 John Willinsky * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. * * @class ResendRequestReviewerForm @@ -35,7 +35,6 @@ class ResendRequestReviewerForm extends ReviewerNotifyActionForm { /** * Constructor - * */ public function __construct(ReviewAssignment $reviewAssignment, ReviewRound $reviewRound, Submission $submission) { @@ -45,21 +44,54 @@ public function __construct(ReviewAssignment $reviewAssignment, ReviewRound $rev $submission, 'controllers/grid/users/reviewer/form/resendRequestReviewerForm.tpl' ); + + // Validation checks for this form + $this->addCheck(new \PKP\form\validation\FormValidator($this, 'responseDueDate', 'required', 'editor.review.errorAddingReviewer')); + $this->addCheck(new \PKP\form\validation\FormValidator($this, 'reviewDueDate', 'required', 'editor.review.errorAddingReviewer')); } + /** + * @copydoc \PKP\controllers\grid\users\reviewer\form\ReviewerNotifyActionForm::getMailable() + */ protected function getMailable(Context $context, Submission $submission, ReviewAssignment $reviewAssignment): Mailable { return new ReviewerResendRequest($context, $submission, $reviewAssignment); } /** - * @copydoc ReviewerNotifyActionForm::getEmailKey() + * @copydoc \PKP\controllers\grid\users\reviewer\form\ReviewerNotifyActionForm::getEmailKey() */ protected function getEmailKey() { return 'REVIEW_RESEND_REQUEST'; } + /** + * @copydoc \PKP\controllers\grid\users\reviewer\form\ReviewerNotifyActionForm::initData() + */ + public function initData() + { + parent::initData(); + + [$reviewDueDate, $responseDueDate] = ReviewerForm::getDueDates(Application::get()->getRequest()->getContext()); + + $this->setData('responseDueDate', $responseDueDate); + $this->setData('reviewDueDate', $reviewDueDate); + } + + /** + * @copydoc \PKP\controllers\grid\users\reviewer\form\ReviewerNotifyActionForm::readInputData() + */ + public function readInputData() + { + parent::readInputData(); + + $this->readUserVars([ + 'responseDueDate', + 'reviewDueDate', + ]); + } + /** * @copydoc Form::execute() * @@ -84,6 +116,8 @@ public function execute(...$functionArgs) 'declined' => false, 'requestResent' => true, 'dateConfirmed' => null, + 'dateDue' => $this->getData('reviewDueDate'), // Set the review due date + 'dateResponseDue' => $this->getData('responseDueDate'), // Set the response due date ]); // Stamp the modification date diff --git a/controllers/grid/users/reviewer/form/ReviewerForm.php b/controllers/grid/users/reviewer/form/ReviewerForm.php index 031b0ccc525..2f8203551f1 100644 --- a/controllers/grid/users/reviewer/form/ReviewerForm.php +++ b/controllers/grid/users/reviewer/form/ReviewerForm.php @@ -88,6 +88,26 @@ public function __construct($submission, $reviewRound) $this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this)); } + /** + * Get the review submit and response due dates + */ + public static function getDueDates(Context $context): array + { + $numWeeks = (int) $context->getData('numWeeksPerReview'); + if ($numWeeks <= 0) { + $numWeeks = 4; + } + $reviewDueDate = strtotime('+' . $numWeeks . ' week'); + + $numWeeks = (int) $context->getData('numWeeksPerResponse'); + if ($numWeeks <= 0) { + $numWeeks = 3; + } + $responseDueDate = strtotime('+' . $numWeeks . ' week'); + + return [$reviewDueDate, $responseDueDate]; + } + // // Getters and Setters // @@ -211,17 +231,7 @@ public function initData() $reviewFormId = null; } - $numWeeks = (int) $context->getData('numWeeksPerReview'); - if ($numWeeks <= 0) { - $numWeeks = 4; - } - $reviewDueDate = strtotime('+' . $numWeeks . ' week'); - - $numWeeks = (int) $context->getData('numWeeksPerResponse'); - if ($numWeeks <= 0) { - $numWeeks = 3; - } - $responseDueDate = strtotime('+' . $numWeeks . ' week'); + [$reviewDueDate, $responseDueDate] = static::getDueDates($context); // Get the currently selected reviewer selection type to show the correct tab if we're re-displaying the form $selectionType = (int) $request->getUserVar('selectionType'); diff --git a/templates/controllers/grid/users/reviewer/form/resendRequestReviewerForm.tpl b/templates/controllers/grid/users/reviewer/form/resendRequestReviewerForm.tpl index 6aa0551f760..a1865d2a925 100644 --- a/templates/controllers/grid/users/reviewer/form/resendRequestReviewerForm.tpl +++ b/templates/controllers/grid/users/reviewer/form/resendRequestReviewerForm.tpl @@ -34,6 +34,11 @@ {fbvElement type="checkbox" id="skipEmail" name="skipEmail" label="editor.review.skipEmail"} {/fbvFormSection} + {fbvFormSection title="editor.review.importantDates"} + {fbvElement type="text" id="responseDueDate" name="responseDueDate" label="submission.task.responseDueDate" value=$responseDueDate inline=true size=$fbvStyles.size.MEDIUM class="datepicker"} + {fbvElement type="text" id="reviewDueDate" name="reviewDueDate" label="editor.review.reviewDueDate" value=$reviewDueDate inline=true size=$fbvStyles.size.MEDIUM class="datepicker"} + {/fbvFormSection} + {fbvFormButtons submitText="editor.review.resendRequestReviewer"}