Skip to content

Commit

Permalink
Merge branch 'pkp:main' into structured-citations
Browse files Browse the repository at this point in the history
  • Loading branch information
GaziYucel authored Oct 11, 2024
2 parents 7eb5de6 + ba75bb8 commit 5dc8799
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 16 deletions.
55 changes: 51 additions & 4 deletions controllers/grid/users/reviewer/form/ResendRequestReviewerForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -33,9 +34,10 @@

class ResendRequestReviewerForm extends ReviewerNotifyActionForm
{
use HasReviewDueDate;

/**
* Constructor
*
*/
public function __construct(ReviewAssignment $reviewAssignment, ReviewRound $reviewRound, Submission $submission)
{
Expand All @@ -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()
*
Expand All @@ -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
Expand Down
17 changes: 5 additions & 12 deletions controllers/grid/users/reviewer/form/ReviewerForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -45,6 +46,8 @@

class ReviewerForm extends Form
{
use HasReviewDueDate;

/** @var Submission The submission associated with the review assignment */
public $_submission;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
63 changes: 63 additions & 0 deletions controllers/grid/users/reviewer/form/traits/HasReviewDueDate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

/**
* @file controllers/grid/users/reviewer/form/traits/HasReviewDueDate.php
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class HasReviewDueDate
*
* @brief Helper trait to get the review submit and/or response due dates
*/

namespace PKP\controllers\grid\users\reviewer\form\traits;

use Carbon\Carbon;
use PKP\context\Context;

trait HasReviewDueDate
{
public const REVIEW_SUBMIT_DEFAULT_DUE_WEEKS = 4;
public const REVIEW_RESPONSE_DEFAULT_DUE_WEEKS = 3;

/**
* Get the review submit due dates
*/
public function getReviewSubmitDueDate(Context $context): Carbon
{
$numWeeks = (int) $context->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(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
</form>

0 comments on commit 5dc8799

Please sign in to comment.