diff --git a/controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php b/controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php index 74772209457..d8232e82a6a 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 @@ -21,6 +21,7 @@ use APP\notification\NotificationManager; use APP\submission\Submission; use PKP\context\Context; +use PKP\controllers\grid\users\reviewer\form\traits\HasReviewDueDate; use PKP\core\Core; use PKP\core\PKPApplication; use PKP\log\event\PKPSubmissionEventLogEntry; @@ -33,9 +34,10 @@ class ResendRequestReviewerForm extends ReviewerNotifyActionForm { + use HasReviewDueDate; + /** * Constructor - * */ public function __construct(ReviewAssignment $reviewAssignment, ReviewRound $reviewRound, Submission $submission) { @@ -45,21 +47,64 @@ 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')); + $this->addCheck( + new \PKP\form\validation\FormValidatorDateCompare( + $this, + 'reviewDueDate', + \Carbon\Carbon::parse(Application::get()->getRequest()->getUserVar('responseDueDate')), + \PKP\validation\enums\DateComparisonRule::GREATER_OR_EQUAL, + 'required', + 'editor.review.errorAddingReviewer.dateValidationFailed' + ) + ); } + /** + * @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] = $this->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 +129,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..b677a3d2d7d 100644 --- a/controllers/grid/users/reviewer/form/ReviewerForm.php +++ b/controllers/grid/users/reviewer/form/ReviewerForm.php @@ -24,6 +24,7 @@ use APP\submission\Submission; use APP\template\TemplateManager; use PKP\context\Context; +use PKP\controllers\grid\users\reviewer\form\traits\HasReviewDueDate; use PKP\controllers\grid\users\reviewer\PKPReviewerGridHandler; use PKP\core\Core; use PKP\db\DAORegistry; @@ -45,6 +46,8 @@ class ReviewerForm extends Form { + use HasReviewDueDate; + /** @var Submission The submission associated with the review assignment */ public $_submission; @@ -211,17 +214,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] = $this->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'); @@ -257,7 +250,7 @@ public function fetch($request, $template = null, $display = false) $reviewFormDao = DAORegistry::getDAO('ReviewFormDAO'); /** @var ReviewFormDAO $reviewFormDao */ $reviewFormsIterator = $reviewFormDao->getActiveByAssocId(Application::getContextAssocType(), $context->getId()); $reviewForms = []; - while ($reviewForm = $reviewFormsIterator->next()) { + while ($reviewForm = $reviewFormsIterator->next()) { /** @var \PKP\reviewForm\ReviewForm $reviewForm */ $reviewForms[$reviewForm->getId()] = $reviewForm->getLocalizedTitle(); } diff --git a/controllers/grid/users/reviewer/form/ReviewerNotifyActionForm.php b/controllers/grid/users/reviewer/form/ReviewerNotifyActionForm.php index 5b27a63240b..c4be1fd30e5 100644 --- a/controllers/grid/users/reviewer/form/ReviewerNotifyActionForm.php +++ b/controllers/grid/users/reviewer/form/ReviewerNotifyActionForm.php @@ -50,6 +50,7 @@ public function __construct($reviewAssignment, $reviewRound, $submission, $templ $this->setReviewRound($reviewRound); $this->setSubmission($submission); + $this->addCheck(new \PKP\form\validation\FormValidatorPost($this)); $this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this)); parent::__construct($template); diff --git a/controllers/grid/users/reviewer/form/traits/HasReviewDueDate.php b/controllers/grid/users/reviewer/form/traits/HasReviewDueDate.php new file mode 100644 index 00000000000..f9ed81bcf08 --- /dev/null +++ b/controllers/grid/users/reviewer/form/traits/HasReviewDueDate.php @@ -0,0 +1,63 @@ +getData('numWeeksPerReview'); + + if ($numWeeks <= 0) { + $numWeeks = static::REVIEW_SUBMIT_DEFAULT_DUE_WEEKS; + } + + return Carbon::today()->endOfDay()->addWeeks($numWeeks); + } + + /** + * Get the review response due dates + */ + public function getReviewResponseDueDate(Context $context): Carbon + { + $numWeeks = (int) $context->getData('numWeeksPerResponse'); + + if ($numWeeks <= 0) { + $numWeeks = static::REVIEW_RESPONSE_DEFAULT_DUE_WEEKS; + } + + return Carbon::today()->endOfDay()->addWeeks($numWeeks); + } + + /** + * Get the review submit and response due dates + */ + public function getDueDates(Context $context): array + { + return [ + $this->getReviewSubmitDueDate($context)->getTimestamp(), + $this->getReviewResponseDueDate($context)->getTimestamp(), + ]; + } +} 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"}