function getAssignedToOthers($userId, $contextId = null, $title = null, $author = null, $editor = null, $stageId = null, $rangeInfo = null)
{
$params = $this->getFetchParameters();
$userId = (int) $userId;
array_push($params, (int) STATUS_DECLINED, $userId, (int) ROLE_ID_MANAGER, (int) ROLE_ID_SUB_EDITOR);
if ($editor) {
array_push($params, $editorQuery = '%' . $editor . '%', $editorQuery);
}
if ($contextId) {
$params[] = (int) $contextId;
}
if ($title) {
$params[] = 'title';
$params[] = '%' . $title . '%';
}
if ($author) {
array_push($params, $authorQuery = '%' . $author . '%', $authorQuery, $authorQuery);
}
if ($stageId) {
$params[] = (int) $stageId;
}
$result = $this->retrieveRange($sql = 'SELECT s.*, ps.date_published,
' . $this->getFetchColumns() . '
FROM submissions s
LEFT JOIN published_submissions ps ON (s.submission_id = ps.submission_id)
' . $this->getCompletionJoins() . '
LEFT JOIN submission_files sf ON (s.submission_id = sf.submission_id)
LEFT JOIN review_assignments ra ON (s.submission_id = ra.submission_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 s.date_submitted IS NOT NULL AND
' . $this->getCompletionConditions(false) . ' AND
AND s.status <> ?
AND (SELECT COUNT(sa.stage_assignment_id) FROM stage_assignments sa
WHERE sa.submission_id = s.submission_id AND sa.user_id = ?) = 0
AND (SELECT COUNT(sa.stage_assignment_id) FROM stage_assignments sa LEFT JOIN user_groups g ON sa.user_group_id = g.user_group_id' . ($editor ? ' LEFT JOIN users u ON (sa.user_id = u.user_id)' : '') . ' WHERE sa.submission_id = s.submission_id AND (g.role_id = ? OR g.role_id = ?)' . ($editor ? ' AND ' . $this->_getEditorSearchQuery() : '') . ') > 0' . ($contextId ? ' AND s.context_id = ?' : '') . ($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 = ?' : '') . ' GROUP BY ' . $this->getGroupByColumns(), $params, $rangeInfo);
return new DAOResultFactory($result, $this, '_fromRow');
}