Skip to content

Commit 775efce

Browse files
authored
Merge pull request #11083 from touhidurabir/i10214_stable_3_5_0
#10214 Editorial reminder issue update
2 parents 92c8eb3 + 845429d commit 775efce

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

classes/submission/reviewRound/ReviewRound.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ public function determineStatus()
259259
break;
260260

261261
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_AWAITING_RESPONSE:
262+
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_REQUEST_RESEND:
262263
case ReviewAssignment::REVIEW_ASSIGNMENT_STATUS_ACCEPTED:
263264
$anyIncompletedReview = true;
264265
break;

jobs/email/EditorialReminder.php

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616

1717
namespace PKP\jobs\email;
1818

19-
use APP\core\Application;
2019
use APP\facades\Repo;
2120
use APP\notification\NotificationManager;
2221
use APP\submission\Submission;
22+
use Carbon\Carbon;
2323
use Illuminate\Support\Facades\Mail;
24+
use PKP\security\Role;
2425
use PKP\context\Context;
2526
use PKP\db\DAORegistry;
2627
use PKP\facades\Locale;
@@ -51,14 +52,24 @@ public function __construct(int $editorId, int $contextId)
5152
*/
5253
public function handle(): void
5354
{
54-
if (!$this->isSubscribed()) {
55-
return;
56-
}
57-
5855
/** @var Context $context */
5956
$context = app()->get('context')->get($this->contextId);
6057
$editor = Repo::user()->get($this->editorId);
6158

59+
// Context or user was removed since job was created, or the user was disabled
60+
if (!$context || !$editor) {
61+
return;
62+
}
63+
64+
// If the user has been removed form manager or editor role since the job was created
65+
if (!$editor->hasRole([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR], $context->getId())) {
66+
return;
67+
}
68+
69+
if (!$this->isSubscribed()) {
70+
return;
71+
}
72+
6273
// Don't use the request locale because this job is
6374
// run during a scheduled task
6475
$requestLocale = Locale::getLocale();
@@ -89,31 +100,43 @@ public function handle(): void
89100
/** @var ReviewRoundDAO $reviewRoundDao */
90101
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');
91102
$reviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $submission->getData('stageId'));
103+
$status = $reviewRound->determineStatus();
92104

93-
if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_PENDING_REVIEWERS) {
105+
if ($status === ReviewRound::REVIEW_ROUND_STATUS_PENDING_REVIEWERS) {
94106
$outstanding[$submissionId] = __('editor.submission.roundStatus.pendingReviewers');
95107
continue;
96108
}
97109

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

103-
if ($reviewRound->getStatus() === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_OVERDUE) {
125+
if ($status === ReviewRound::REVIEW_ROUND_STATUS_REVIEWS_OVERDUE) {
104126
$outstanding[$submissionId] = __('editor.submission.roundStatus.reviewOverdue');
105127
continue;
106128
}
107129

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

114136
if (in_array($submission->getData('stageId'), [WORKFLOW_STAGE_ID_EDITING, WORKFLOW_STAGE_ID_PRODUCTION])) {
115-
$lastActivityTimestamp = strtotime($submission->getData('dateLastActivity'));
116-
if ($lastActivityTimestamp < strtotime('-30 days')) {
137+
$lastActivityTimestamp = Carbon::parse($submission->getData('dateLastActivity'))->endOfDay();
138+
$comparingTimestamp = Carbon::today()->endOfDay()->subDays(30);
139+
if ($comparingTimestamp->gt($lastActivityTimestamp)) {
117140
/** @var WorkflowStageDAO $workflowStageDao */
118141
$workflowStageDao = DAORegistry::getDAO('WorkflowStageDAO');
119142
$outstanding[$submissionId] = __(
@@ -135,11 +158,6 @@ public function handle(): void
135158
return;
136159
}
137160

138-
// Context or user was removed since job was created, or the user was disabled
139-
if (!$context || !$editor) {
140-
return;
141-
}
142-
143161
$notificationManager = new NotificationManager();
144162
$notification = $notificationManager->createNotification(
145163
$this->editorId,
@@ -165,13 +183,18 @@ public function handle(): void
165183
}
166184

167185
/**
168-
* Is this editor subscribed to this email?
186+
* Is this editor subscribed to this notification type?
169187
*/
170188
protected function isSubscribed(): bool
171189
{
172190
/** @var NotificationSubscriptionSettingsDAO $notificationSubscriptionSettingsDao */
173191
$notificationSubscriptionSettingsDao = DAORegistry::getDAO('NotificationSubscriptionSettingsDAO');
174-
$blockedEmails = $notificationSubscriptionSettingsDao->getNotificationSubscriptionSettings('blocked_emailed_notification', $this->editorId, $this->contextId);
192+
$blockedEmails = $notificationSubscriptionSettingsDao->getNotificationSubscriptionSettings(
193+
NotificationSubscriptionSettingsDAO::BLOCKED_EMAIL_NOTIFICATION_KEY,
194+
$this->editorId,
195+
$this->contextId
196+
);
197+
175198
return !in_array(Notification::NOTIFICATION_TYPE_EDITORIAL_REMINDER, $blockedEmails);
176199
}
177200

0 commit comments

Comments
 (0)