function getReviewerArchived($reviewerId, $contextId = null, $title = null, $author = null, $stageId = null, $rangeInfo = null)
{
$params = array($reviewerId, $reviewerId);
$params = array_merge($params, $this->getFetchParameters());
$params[] = $reviewerId;
if ($title) {
$params[] = 'title';
$params[] = '%' . $title . '%';
}
if ($author) {
array_push($params, $authorQuery = '%' . $author . '%', $authorQuery, $authorQuery);
}
if ($stageId) {
$params[] = (int) $stageId;
}
$result = $this->retrieveRange('SELECT s.*, ps.date_published,
' . $this->getFetchColumns() . '
FROM submissions s
LEFT JOIN published_submissions ps ON (s.submission_id = ps.submission_id)
LEFT JOIN review_assignments ra ON (s.submission_id = ra.submission_id AND ra.reviewer_id = ? AND ra.declined = true)
LEFT JOIN review_assignments ra2 ON (s.submission_id = ra2.submission_id AND ra2.reviewer_id = ? AND ra2.declined = true AND ra2.review_id > ra.review_id)
' . ($title ? ' LEFT JOIN submission_settings ss ON (s.submission_id = ss.submission_id)' : '') . '
' . ($author ? ' LEFT JOIN authors au ON (s.submission_id = au.submission_id)' : '') . $this->getFetchJoins() . ' WHERE ra2.review_id IS NULL AND ra.review_id IS NOT NULL
AND (SELECT COUNT(ra3.review_id) FROM review_assignments ra3
WHERE s.submission_id = ra3.submission_id AND ra3.reviewer_id = ? AND ra3.declined = 0) = 0
' . ($contextId ? ' AND s.context_id IN (' . join(',', array_map(array($this, '_arrayWalkIntCast'), (array) $contextId)) . ')' : '') . ($title ? ' AND (ss.setting_name = ? AND ss.setting_value LIKE ?)' : '') . ($author ? ' AND (au.first_name LIKE ? OR au.middle_name LIKE ? OR au.last_name LIKE ?)' : '') . ($stageId ? ' AND s.stage_id = ?' : ''), $params, $rangeInfo);
return new DAOResultFactory($result, $this, '_fromRow');
}