Skip to content

Commit f647417

Browse files
authored
Merge pull request pkp#10332 from touhidurabir/i10214_stable_3_4_0
pkp#10214 fixed review round outstanding status determining process
2 parents f4c90fe + b500080 commit f647417

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed

classes/submission/reviewRound/ReviewRound.php

+1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ public function determineStatus()
253253
break;
254254

255255
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE:
256+
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_REQUEST_RESEND:
256257
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_ACCEPTED:
257258
$anyIncompletedReview = true;
258259
break;

jobs/email/EditorialReminder.php

+42-19
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use APP\notification\Notification;
2323
use APP\notification\NotificationManager;
2424
use APP\submission\Submission;
25+
use Carbon\Carbon;
2526
use Illuminate\Support\Facades\Mail;
2627
use PKP\context\Context;
2728
use PKP\db\DAORegistry;
@@ -32,6 +33,7 @@
3233
use PKP\notification\PKPNotification;
3334
use PKP\submission\reviewRound\ReviewRound;
3435
use PKP\submission\reviewRound\ReviewRoundDAO;
36+
use PKP\security\Role;
3537
use PKP\user\User;
3638
use PKP\workflow\WorkflowStageDAO;
3739

@@ -53,14 +55,24 @@ public function __construct(int $editorId, int $contextId)
5355
*/
5456
public function handle(): void
5557
{
56-
if (!$this->isSubscribed()) {
57-
return;
58-
}
59-
6058
/** @var Context $context */
6159
$context = Services::get('context')->get($this->contextId);
6260
$editor = Repo::user()->get($this->editorId);
6361

62+
// Context or user was removed since job was created, or the user was disabled
63+
if (!$context || !$editor) {
64+
return;
65+
}
66+
67+
// If the user has been removed form manager or editor role since the job was created
68+
if (!$editor->hasRole([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR], $context->getId())) {
69+
return;
70+
}
71+
72+
if (!$this->isSubscribed()) {
73+
return;
74+
}
75+
6476
// Don't use the request locale because this job is
6577
// run during a scheduled task
6678
$requestLocale = Locale::getLocale();
@@ -88,34 +100,45 @@ public function handle(): void
88100
}
89101

90102
if (in_array($submission->getData('stageId'), [WORKFLOW_STAGE_ID_INTERNAL_REVIEW, WORKFLOW_STAGE_ID_EXTERNAL_REVIEW])) {
91-
/** @var ReviewRoundDAO $reviewRoundDao */
92-
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
103+
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /** @var ReviewRoundDAO $reviewRoundDao */
93104
$reviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $submission->getData('stageId'));
105+
$status = $reviewRound->determineStatus();
94106

95-
if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_PENDING_REVIEWERS) {
107+
if ($status === ReviewRound::REVIEW_ROUND_STATUS_PENDING_REVIEWERS) {
96108
$outstanding[$submissionId] = __('editor.submission.roundStatus.pendingReviewers');
97109
continue;
98110
}
99111

100-
if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_COMPLETED) {
112+
if ($status === ReviewRound::REVIEW_ROUND_STATUS_PENDING_REVIEWS) {
113+
$outstanding[$submissionId] = __('editor.submission.roundStatus.pendingReviews');
114+
continue;
115+
}
116+
117+
if ($status === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_READY) {
118+
$outstanding[$submissionId] = __('editor.submission.roundStatus.reviewsReady');
119+
continue;
120+
}
121+
122+
if ($status === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_COMPLETED) {
101123
$outstanding[$submissionId] = __('editor.submission.roundStatus.reviewsCompleted');
102124
continue;
103125
}
104126

105-
if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_OVERDUE) {
127+
if ($status === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_OVERDUE) {
106128
$outstanding[$submissionId] = __('editor.submission.roundStatus.reviewOverdue');
107129
continue;
108130
}
109131

110-
if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED) {
132+
if ($status === ReviewRound::REVIEW_ROUND_STATUS_REVISIONS_SUBMITTED) {
111133
$outstanding[$submissionId] = __('editor.submission.roundStatus.revisionsSubmitted');
112134
continue;
113135
}
114136
}
115137

116138
if (in_array($submission->getData('stageId'), [WORKFLOW_STAGE_ID_EDITING, WORKFLOW_STAGE_ID_PRODUCTION])) {
117-
$lastActivityTimestamp = strtotime($submission->getData('dateLastActivity'));
118-
if ($lastActivityTimestamp < strtotime('-30 days')) {
139+
$lastActivityTimestamp = Carbon::parse($submission->getData('dateLastActivity'))->endOfDay();
140+
$comparingTimestamp = Carbon::today()->endOfDay()->subDays(30);
141+
if ($comparingTimestamp->gt($lastActivityTimestamp)) {
119142
/** @var WorkflowStageDAO $workflowStageDao */
120143
$workflowStageDao = DAORegistry::getDAO('WorkflowStageDAO');
121144
$outstanding[$submissionId] = __(
@@ -137,11 +160,6 @@ public function handle(): void
137160
return;
138161
}
139162

140-
// Context or user was removed since job was created, or the user was disabled
141-
if (!$context || !$editor) {
142-
return;
143-
}
144-
145163
$notificationManager = new NotificationManager();
146164
$notification = $notificationManager->createNotification(
147165
Application::get()->getRequest(),
@@ -168,13 +186,18 @@ public function handle(): void
168186
}
169187

170188
/**
171-
* Is this editor subscribed to this email?
189+
* Is this editor subscribed to this email notification type?
172190
*/
173191
protected function isSubscribed(): bool
174192
{
175193
/** @var NotificationSubscriptionSettingsDAO $notificationSubscriptionSettingsDao */
176194
$notificationSubscriptionSettingsDao = DAORegistry::getDAO('NotificationSubscriptionSettingsDAO');
177-
$blockedEmails = $notificationSubscriptionSettingsDao->getNotificationSubscriptionSettings('blocked_emailed_notification', $this->editorId, $this->contextId);
195+
$blockedEmails = $notificationSubscriptionSettingsDao->getNotificationSubscriptionSettings(
196+
NotificationSubscriptionSettingsDAO::BLOCKED_EMAIL_NOTIFICATION_KEY,
197+
$this->editorId,
198+
$this->contextId
199+
);
200+
178201
return !in_array(Notification::NOTIFICATION_TYPE_EDITORIAL_REMINDER, $blockedEmails);
179202
}
180203

0 commit comments

Comments
 (0)