From 04f26a25a8cce1c0759c0d4a5aebbce8ff31f769 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Wed, 25 Dec 2024 15:14:36 +0600 Subject: [PATCH] pkp/pkp-lib#10214 Editorial reminder issue update --- .../submission/reviewRound/ReviewRound.php | 1 + jobs/email/EditorialReminder.php | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/classes/submission/reviewRound/ReviewRound.php b/classes/submission/reviewRound/ReviewRound.php index 9c58f24f30b..72f452fe34d 100644 --- a/classes/submission/reviewRound/ReviewRound.php +++ b/classes/submission/reviewRound/ReviewRound.php @@ -256,6 +256,7 @@ public function determineStatus() break; case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE: + case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_REQUEST_RESEND: case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_ACCEPTED: $anyIncompletedReview = true; break; diff --git a/jobs/email/EditorialReminder.php b/jobs/email/EditorialReminder.php index 56fc65fef3e..cd3735bab55 100644 --- a/jobs/email/EditorialReminder.php +++ b/jobs/email/EditorialReminder.php @@ -16,10 +16,10 @@ namespace PKP\jobs\email; -use APP\core\Application; use APP\facades\Repo; use APP\notification\NotificationManager; use APP\submission\Submission; +use Carbon\Carbon; use Illuminate\Support\Facades\Mail; use PKP\context\Context; use PKP\db\DAORegistry; @@ -90,30 +90,41 @@ public function handle(): void $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); $reviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $submission->getData('stageId')); - if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_PENDING_REVIEWERS) { + if ($reviewRound->determineStatus() === ReviewRound::REVIEW_ROUND_STATUS_PENDING_REVIEWERS) { $outstanding[$submissionId] = __('editor.submission.roundStatus.pendingReviewers'); continue; } - if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_COMPLETED) { + if ($reviewRound->determineStatus() === ReviewRound::REVIEW_ROUND_STATUS_PENDING_REVIEWS) { + $outstanding[$submissionId] = __('editor.submission.roundStatus.pendingReviews'); + continue; + } + + if ($reviewRound->determineStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_READY) { + $outstanding[$submissionId] = __('editor.submission.roundStatus.reviewsReady'); + continue; + } + + if ($reviewRound->determineStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_COMPLETED) { $outstanding[$submissionId] = __('editor.submission.roundStatus.reviewsCompleted'); continue; } - if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_OVERDUE) { + if ($reviewRound->determineStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_OVERDUE) { $outstanding[$submissionId] = __('editor.submission.roundStatus.reviewOverdue'); continue; } - if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED) { + if ($reviewRound->determineStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED) { $outstanding[$submissionId] = __('editor.submission.roundStatus.revisionsSubmitted'); continue; } } if (in_array($submission->getData('stageId'), [WORKFLOW_STAGE_ID_EDITING, WORKFLOW_STAGE_ID_PRODUCTION])) { - $lastActivityTimestamp = strtotime($submission->getData('dateLastActivity')); - if ($lastActivityTimestamp < strtotime('-30 days')) { + $lastActivityTimestamp = Carbon::parse($submission->getData('dateLastActivity'))->endOfDay(); + $comparingTimestamp = Carbon::today()->endOfDay()->subDays(30); + if ($comparingTimestamp->gt($lastActivityTimestamp)) { /** @var WorkflowStageDAO $workflowStageDao */ $workflowStageDao = DAORegistry::getDAO('WorkflowStageDAO'); $outstanding[$submissionId] = __( @@ -155,8 +166,11 @@ public function handle(): void ->from($context->getContactEmail(), $context->getLocalizedName(Locale::getLocale())) ->recipients([$editor]) ->subject($emailTemplate->getLocalizedData('subject')) - ->body($emailTemplate->getLocalizedData('body')) - ->allowUnsubscribe($notification); + ->body($emailTemplate->getLocalizedData('body')); + + if ($notification) { + $mailable->allowUnsubscribe($notification); + } Mail::send($mailable);