Skip to content

Commit 948c207

Browse files
committed
#9453 Matching the correct decline email and get review comments data
1 parent 0b4fc5f commit 948c207

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

api/v1/reviews/PKPReviewController.php

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,20 @@ public function getHistory(Request $illuminateRequest): JsonResponse
120120
$publicationTitle = $submission->getCurrentPublication()->getLocalizedTitle();
121121

122122
$declineEmail = null;
123-
if (!$reviewAssignment->getDeclined()) {
123+
if ($reviewAssignment->getDeclined()) {
124124
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
125125
$emailLogs = $submissionEmailLogDao->getBySenderId($submissionId, SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_DECLINE, $reviewerId)->toArray();
126-
// TODO: look for the right email log with the right round number.
127-
if ($emailLogs) {
128-
$emailLog = $emailLogs[0];
129-
$declineEmail = [
130-
'subject' => $emailLog->getData('subject'),
131-
'body' => $emailLog->getData('body'),
132-
];
126+
foreach ($emailLogs as $emailLog) {
127+
$dateSent = substr($emailLog->getData('dateSent'), 0, 10);
128+
$dateConfirmed = substr($reviewAssignment->getData('dateConfirmed'), 0, 10);
129+
// Compare the dates to get the decline email associated to the current round.
130+
if ($dateSent === $dateConfirmed) {
131+
$declineEmail = [
132+
'subject' => $emailLog->getData('subject'),
133+
'body' => $emailLog->getData('body'),
134+
];
135+
break;
136+
}
133137
}
134138
}
135139

@@ -138,10 +142,17 @@ public function getHistory(Request $illuminateRequest): JsonResponse
138142

139143
$reviewAssignmentId = $reviewAssignment->getId();
140144
$submissionCommentDao = DAORegistry::getDAO('SubmissionCommentDAO');
141-
$comments = $submissionCommentDao->getReviewerCommentsByReviewerId($submissionId, $reviewerId, $reviewAssignmentId, true)->toArray();
142-
$privateComments = $submissionCommentDao->getReviewerCommentsByReviewerId($submissionId, $reviewerId, $reviewAssignmentId, false)->toArray();
143-
144-
// TODO: get the comments data...
145+
$allSubmissionComments = $submissionCommentDao->getReviewerCommentsByReviewerId($submissionId, $reviewerId, $reviewAssignmentId)->toArray();
146+
$viewableComments = [];
147+
$privateComments = [];
148+
foreach ($allSubmissionComments as $submissionComment) {
149+
$comments = $submissionComment->getData('comments');
150+
if ($submissionComment->getData('viewable')) {
151+
$viewableComments[] = $comments;
152+
} else {
153+
$privateComments[] = $comments;
154+
}
155+
}
145156

146157
$lastReviewAssignment = Repo::reviewAssignment()->getCollector()
147158
->filterByContextIds([$contextId])
@@ -157,7 +168,7 @@ public function getHistory(Request $illuminateRequest): JsonResponse
157168
'declineEmail' => $declineEmail,
158169
'reviewAssignment' => $reviewAssignmentProps,
159170
'recommendation' => $recommendation,
160-
'comments' => $comments,
171+
'comments' => $viewableComments,
161172
'privateComments' => $privateComments,
162173
'displayFiles' => $displayFiles,
163174
];

0 commit comments

Comments
 (0)