@@ -120,16 +120,20 @@ public function getHistory(Request $illuminateRequest): JsonResponse
120
120
$ publicationTitle = $ submission ->getCurrentPublication ()->getLocalizedTitle ();
121
121
122
122
$ declineEmail = null ;
123
- if (! $ reviewAssignment ->getDeclined ()) {
123
+ if ($ reviewAssignment ->getDeclined ()) {
124
124
$ submissionEmailLogDao = DAORegistry::getDAO ('SubmissionEmailLogDAO ' );
125
125
$ 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
+ }
133
137
}
134
138
}
135
139
@@ -138,10 +142,17 @@ public function getHistory(Request $illuminateRequest): JsonResponse
138
142
139
143
$ reviewAssignmentId = $ reviewAssignment ->getId ();
140
144
$ 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
+ }
145
156
146
157
$ lastReviewAssignment = Repo::reviewAssignment ()->getCollector ()
147
158
->filterByContextIds ([$ contextId ])
@@ -157,7 +168,7 @@ public function getHistory(Request $illuminateRequest): JsonResponse
157
168
'declineEmail ' => $ declineEmail ,
158
169
'reviewAssignment ' => $ reviewAssignmentProps ,
159
170
'recommendation ' => $ recommendation ,
160
- 'comments ' => $ comments ,
171
+ 'comments ' => $ viewableComments ,
161
172
'privateComments ' => $ privateComments ,
162
173
'displayFiles ' => $ displayFiles ,
163
174
];
0 commit comments