17 import(
'lib.pkp.classes.submission.reviewRound.ReviewRound');
32 function build($submissionId, $stageId, $round, $status =
null) {
34 $reviewRound = $this->
getReviewRound($submissionId, $stageId, $round);
35 if ($reviewRound)
return $reviewRound;
38 if ($stageId == WORKFLOW_STAGE_ID_INTERNAL_REVIEW ||
39 $stageId == WORKFLOW_STAGE_ID_EXTERNAL_REVIEW &&
44 $reviewRound->setSubmissionId($submissionId);
45 $reviewRound->setRound($round);
46 $reviewRound->setStageId($stageId);
47 $reviewRound->setStatus($status);
73 'INSERT INTO review_rounds
74 (submission_id, stage_id, round, status)
78 (
int)$reviewRound->getSubmissionId(),
79 (
int)$reviewRound->getStageId(),
80 (
int)$reviewRound->getRound(),
81 (
int)$reviewRound->getStatus()
96 WHERE submission_id = ? AND
100 (
int)$reviewRound->getStatus(),
101 (
int)$reviewRound->getSubmissionId(),
102 (
int)$reviewRound->getStageId(),
103 (
int)$reviewRound->getRound()
117 'SELECT * FROM review_rounds WHERE submission_id = ? AND stage_id = ? AND round = ?',
118 array((
int) $submissionId, (
int) $stageId, (
int) $round)
122 if ($result->RecordCount() != 0) {
123 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
136 'SELECT * FROM review_rounds WHERE review_round_id = ?',
141 if ($result->RecordCount() != 0) {
142 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
155 'SELECT * FROM review_rounds rr
156 INNER JOIN review_round_files rrf
157 ON rr.review_round_id = rrf.review_round_id
158 WHERE rrf.file_id = ?',
159 array((
int) $submissionFileId));
162 if ($result->RecordCount() != 0) {
163 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
176 $params = array($submissionId);
177 if ($stageId) $params[] = $stageId;
178 if ($round) $params[] = $round;
181 'SELECT * FROM review_rounds WHERE submission_id = ?' .
182 ($stageId ?
' AND stage_id = ?' :
'') .
183 ($round ?
' AND round = ?' :
'') .
184 ' ORDER BY stage_id ASC, round ASC',
198 $params = array((
int)$submissionId);
199 if ($stageId) $params[] = (int) $stageId;
201 'SELECT MAX(stage_id) as stage_id, MAX(round) as round
203 WHERE submission_id = ?' .
204 ($stageId ?
' AND stage_id = ?' :
''),
207 $returner = isset($result->fields[
'round']) ? (int)$result->fields[
'round'] : 1;
219 $params = array((
int)$submissionId);
220 if ($stageId) $params[] = (int) $stageId;
224 WHERE submission_id = ?
225 ' . ($stageId ?
' AND stage_id = ?' :
'') .
'
226 ORDER BY stage_id DESC, round DESC',
232 if ($result->RecordCount() != 0) {
233 $returner = $this->
_fromRow($result->GetRowAssoc(
false));
244 return $this->
_getInsertId(
'review_rounds',
'review_round_id');
256 assert(is_a($reviewRound,
'ReviewRound'));
257 $currentStatus = $reviewRound->getStatus();
259 if (is_null($status)) {
260 $status = $reviewRound->determineStatus();
264 if ($status != $currentStatus) {
265 $this->
update(
'UPDATE review_rounds SET status = ? WHERE review_round_id = ?',
266 array((
int)$status, (
int)$reviewRound->getId())
269 $reviewRound->setStatus($status);
280 while ($reviewRound = $reviewRounds->next()) {
299 $this->
update(
'DELETE FROM notifications WHERE assoc_type = ? AND assoc_id = ?', array((
int) ASSOC_TYPE_REVIEW_ROUND, (
int) $reviewRoundId));
300 return $this->
update(
'DELETE FROM review_rounds WHERE review_round_id = ?', array((
int) $reviewRoundId));
314 $reviewRound->setId((
int)$row[
'review_round_id']);
315 $reviewRound->setSubmissionId((
int)$row[
'submission_id']);
316 $reviewRound->setStageId((
int)$row[
'stage_id']);
317 $reviewRound->setRound((
int)$row[
'round']);
318 $reviewRound->setStatus((
int)$row[
'status']);