Skip to content

Commit

Permalink
#5885 Review remainder update issues fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidurabir committed Jan 30, 2024
1 parent dd1bfa5 commit 3333a79
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 50 deletions.
17 changes: 2 additions & 15 deletions classes/components/forms/context/PKPReviewSetupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,8 @@ public function __construct($action, $locales, $context)
]));

if (Config::getVar('general', 'scheduled_tasks')) {
// $this->addField(new FieldText('numDaysBeforeInviteReminder', [
// 'label' => __('manager.setup.reviewOptions.reminders.response'),
// 'description' => __('manager.setup.reviewOptions.reminders.response.description'),
// 'value' => $context->getData('numDaysBeforeInviteReminder'),
// 'size' => 'small',
// ]))
// ->addField(new FieldText('numDaysBeforeSubmitReminder', [
// 'label' => __('manager.setup.reviewOptions.reminders.submit'),
// 'description' => __('manager.setup.reviewOptions.reminders.submit.description'),
// 'value' => $context->getData('numDaysBeforeSubmitReminder'),
// 'size' => 'small',
// ]));

$this
->addField(new FieldHTML('reviewRequestResponseRemainder', [
->addField(new FieldHTML('reviewRequestResponseReminder', [
'label' => __('manager.setup.reviewOptions.reminders.response'),
'description' => __('manager.setup.reviewOptions.reminders.response.description'),
]))
Expand All @@ -120,7 +107,7 @@ public function __construct($action, $locales, $context)
'value' => $context->getData('numDaysAfterReviewResponseReminderDue'),
'size' => 'small',
]))
->addField(new FieldHTML('submissionReviewResponseRemainder', [
->addField(new FieldHTML('submissionReviewResponseReminder', [
'label' => __('manager.setup.reviewOptions.reminders.submit'),
'description' => __('manager.setup.reviewOptions.reminders.submit.description'),
]))
Expand Down
6 changes: 3 additions & 3 deletions classes/form/validation/FormValidatorDateCompare.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace PKP\form\validation;

use PKP\validation\ValidatorDateConparison;
use PKP\validation\ValidatorDateComparison;
use Carbon\Carbon;
use DateTimeInterface;

Expand All @@ -34,9 +34,9 @@ class FormValidatorDateCompare extends FormValidator
* @param string $type the type of check, either "required" or "optional"
* @param string $message the error message for validation failures (i18n key)
*/
public function __construct(&$form, $field, $comparingDate, $comparingRule, $type = 'optional', $message = 'email.invalid')
public function __construct(&$form, $field, $comparingDate, $comparingRule, $type = 'optional', $message = 'validator.date.comparison')
{
$validator = new ValidatorDateConparison($comparingDate, $comparingRule);
$validator = new ValidatorDateComparison($comparingDate, $comparingRule);
parent::__construct($form, $field, $type, $message, $validator);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
<?php

/**
* @file classes/migration/upgrade/v3_5_0/I5885_RenameReviewRemainderSettingsName.php
* @file classes/migration/upgrade/v3_5_0/I5885_RenameReviewReminderSettingsName.php
*
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class I5885_RenameReviewRemainderColumns
* @class I5885_RenameReviewReminderSettingsName
*
* @brief Rename the review remainder settings name
* @brief Rename the review reminder settings name
*/

namespace PKP\migration\upgrade\v3_5_0;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use PKP\migration\Migration;

abstract class I5885_RenameReviewRemainderSettingsName extends Migration
abstract class I5885_RenameReviewReminderSettingsName extends Migration
{
abstract protected function getContextSettingsTable(): string;

Expand Down
34 changes: 20 additions & 14 deletions classes/task/ReviewReminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use PKP\mail\mailables\ReviewResponseRemindAuto;
use PKP\scheduledTask\ScheduledTask;
use PKP\submission\PKPSubmission;
use PKP\jobs\email\ReviewRemainder as ReviewRemainderJob;
use PKP\jobs\email\ReviewReminder as ReviewReminderJob;

class ReviewReminder extends ScheduledTask
{
Expand Down Expand Up @@ -84,19 +84,20 @@ public function executeActions()
$dateDue = Carbon::parse($reviewAssignment->getDateDue())->startOfDay();

if ($reviewAssignment->getDateReminded() !== null) {
// we have a remainder sent previously
// we have a reminder sent previously

$dateReminded = Carbon::parse($reviewAssignment->getDateReminded())->startOfDay();

if ($reviewAssignment->getDateConfirmed() === null) {
// review request has not been responded
// previous remainder was a BEFORE REVIEW REQUEST RESPONSE remainder
// previous reminder was a BEFORE REVIEW REQUEST RESPONSE reminder

if ($dateReminded->lt($dateResponseDue) &&
if ($numDaysAfterReviewResponseReminderDue &&
$dateReminded->lt($dateResponseDue) &&
$currentDate->gte($dateResponseDue) &&
$currentDate->diffInDays($dateResponseDue) >= $numDaysAfterReviewResponseReminderDue) {

// ACTION:-> we need to sent a AFTER REVIEW REQUEST RESPONSE remainder
// ACTION:-> we need to sent a AFTER REVIEW REQUEST RESPONSE reminder
$mailable = ReviewResponseRemindAuto::class;
}
} else {
Expand All @@ -106,35 +107,35 @@ public function executeActions()
$currentDate->lt($dateDue) &&
$dateDue->diffInDays($currentDate) <= $numDaysBeforeReviewSubmitReminderDue) {

// no review submit remainder has been sent
// no review submit reminder has been sent

// ACTION:-> we need to sent a BEFORE REVIEW SUBMIT remainder
// ACTION:-> we need to sent a BEFORE REVIEW SUBMIT reminder
$mailable = ReviewRemindAuto::class;

} else if ( $numDaysAfterReviewSubmitReminderDue &&
$dateReminded->lt($dateDue) &&
$currentDate->gt($dateDue) &&
$currentDate->diffInDays($dateDue) >= $numDaysAfterReviewSubmitReminderDue) {

// ACTION:-> we need to sent a AFTER REVIEW SUBMIT remainder
// ACTION:-> we need to sent a AFTER REVIEW SUBMIT reminder
$mailable = ReviewRemindAuto::class;
}
}
} else if ($reviewAssignment->getDateConfirmed() != null) {
// the review request has been responded
// as long review request has respnded, only need to concern with BEFORE/AFTER REVIEW SUBMIT remainder
// as long review request has respnded, only need to concern with BEFORE/AFTER REVIEW SUBMIT reminder
if ($numDaysAfterReviewSubmitReminderDue &&
$currentDate->gt($dateDue) &&
$currentDate->diffInDays($dateDue) >= $numDaysAfterReviewSubmitReminderDue) {

// ACTION:-> we need to send AFTER REVIEW SUBMIT remainder
// ACTION:-> we need to send AFTER REVIEW SUBMIT reminder
$mailable = ReviewRemindAuto::class;

} else if ( $numDaysBeforeReviewSubmitReminderDue &&
$dateDue->gt($currentDate) &&
$dateDue->diffInDays($currentDate) <= $numDaysBeforeReviewSubmitReminderDue) {

// ACTION:-> we need to send BEFORE REVIEW SUBMIT remainder
// ACTION:-> we need to send BEFORE REVIEW SUBMIT reminder
$mailable = ReviewRemindAuto::class;
}
} else {
Expand All @@ -143,20 +144,25 @@ public function executeActions()
$currentDate->gt($dateResponseDue) &&
$currentDate->diffInDays($dateResponseDue) >= $numDaysAfterReviewResponseReminderDue) {

// ACTION:-> we need to send AFTER REVIEW REQUEST RESPONSE remainder
// ACTION:-> we need to send AFTER REVIEW REQUEST RESPONSE reminder
$mailable = ReviewResponseRemindAuto::class;

} else if ( $numDaysBeforeReviewResponseReminderDue &&
$dateResponseDue->gt($currentDate) &&
$dateResponseDue->diffInDays($currentDate) <= $numDaysBeforeReviewResponseReminderDue) {

// ACTION:-> we need to send BEFORE REVIEW REQUEST RESPONSE remainder
// ACTION:-> we need to send BEFORE REVIEW REQUEST RESPONSE reminder
$mailable = ReviewResponseRemindAuto::class;
}
}

if ($mailable) {
ReviewRemainderJob::dispatch($reviewAssignment->getId(), $submission->getId(), $context->getId(), $mailable);
ReviewReminderJob::dispatch(
$reviewAssignment->getId(),
$submission->getId(),
$context->getId(),
$mailable
);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

/**
* @file classes/validation/ValidatorDateConparison.php
* @file classes/validation/ValidatorDateComparison.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2000-2021 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ValidatorDateConparison
* @class ValidatorDateComparison
*
* @ingroup validation
*
Expand All @@ -23,7 +23,7 @@
use Exception;
use PKP\validation\ValidatorFactory;

class ValidatorDateConparison extends Validator
class ValidatorDateComparison extends Validator
{
public const DATE_COMPARE_RULE_EQUAL = 'equal';
public const DATE_COMPARE_RULE_GREATER = 'greater';
Expand Down Expand Up @@ -93,5 +93,5 @@ protected function getValidationApplicableRule(string $rule): mixed
}

if (!PKP_STRICT_MODE) {
class_alias('\PKP\validation\ValidatorDateConparison', '\ValidatorDateConparison');
class_alias('\PKP\validation\ValidatorDateComparison', '\ValidatorDateComparison');
}
2 changes: 1 addition & 1 deletion controllers/grid/users/reviewer/form/EditReviewForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct(ReviewAssignment $reviewAssignment, Submission $subm
$this,
'reviewDueDate',
\Carbon\Carbon::parse(Application::get()->getRequest()->getUserVar('responseDueDate')),
\PKP\validation\ValidatorDateConparison::DATE_COMPARE_RULE_GREATER_OR_EQUAL,
\PKP\validation\ValidatorDateComparison::DATE_COMPARE_RULE_GREATER_OR_EQUAL,
'optional',
'editor.review.errorAddingReviewer.dateValidationFailed'
)
Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/users/reviewer/form/ReviewerForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public function __construct($submission, $reviewRound)
new \PKP\form\validation\FormValidatorDateCompare(
$this,
'reviewDueDate',
\Carbon\Carbon::parse(Application::get()->getRequest()->getUserVar('responseDueDate')),
\PKP\validation\ValidatorDateConparison::DATE_COMPARE_RULE_GREATER_OR_EQUAL,
\Carbon\Carbon::parse($this->getData('responseDueDate')),
\PKP\validation\ValidatorDateComparison::DATE_COMPARE_RULE_GREATER_OR_EQUAL,
'optional',
'editor.review.errorAddingReviewer.dateValidationFailed'
)
Expand Down
10 changes: 5 additions & 5 deletions jobs/email/ReviewRemainder.php → jobs/email/ReviewReminder.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php

/**
* @file jobs/email/ReviewRemainder.php
* @file jobs/email/ReviewReminder.php
*
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2000-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ReviewRemainder
* @class ReviewReminder
*
* @ingroup jobs
*
* @brief Class to handle a job to send an review remainder
* @brief Class to handle a job to send an review reminder
*/

namespace PKP\jobs\email;
Expand All @@ -28,7 +28,7 @@
use PKP\jobs\BaseJob;


class ReviewRemainder extends BaseJob
class ReviewReminder extends BaseJob
{
protected int $reviewAssignmentId;
protected int $submissionId;
Expand Down Expand Up @@ -59,7 +59,7 @@ public function handle(): void

$submission = Repo::submission()->get($this->submissionId);

$contextService = Services::get("context");
$contextService = Services::get('context');
$context = $contextService->get($this->contextId);

/** @var ReviewRemindAuto|ReviewResponseRemindAuto $mailable */
Expand Down
3 changes: 3 additions & 0 deletions locale/en/common.po
Original file line number Diff line number Diff line change
Expand Up @@ -2117,6 +2117,9 @@ msgstr "This is not a valid currency."
msgid "validator.date"
msgstr "This is not a valid date."

msgid "validator.date.comparison"
msgstr "Invalid dates provided for comparison."

msgid "validator.date_format"
msgstr "This does not match the format {$format}."

Expand Down

0 comments on commit 3333a79

Please sign in to comment.