function getActiveSubmissions($contextId = null, $title = null, $author = null, $editor = null, $stageId = null, $rangeInfo = null, $orphaned = false)
{
$params = $this->getFetchParameters();
$params[] = (int) STATUS_DECLINED;
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;
}
if ($editor) {
array_push($params, (int) ROLE_ID_MANAGER, (int) ROLE_ID_SUB_EDITOR, $editorQuery = '%' . $editor . '%', $editorQuery);
}
$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)
' . $this->getCompletionJoins() . '
' . ($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)' : '') . '
' . ($editor ? ' LEFT JOIN stage_assignments sa ON (s.submission_id = sa.submission_id)
LEFT JOIN user_groups g ON (sa.user_group_id = g.user_group_id)
LEFT JOIN users u ON (sa.user_id = u.user_id)' : '') . '
' . $this->getFetchJoins() . '
WHERE (s.date_submitted IS NOT NULL
' . ($orphaned ? ' OR (s.submission_progress <> 0 AND s.submission_id NOT IN (SELECT sa2.submission_id FROM stage_assignments sa2 LEFT JOIN user_groups g2 ON (sa2.user_group_id = g2.user_group_id) WHERE g2.role_id = ' . (int) ROLE_ID_AUTHOR . '))' : '') . '
) AND ' . $this->getCompletionConditions(false) . '
AND s.status <> ?
' . ($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 = ?' : '') . '
' . ($editor ? ' AND (g.role_id = ? OR g.role_id = ?) AND' . $this->_getEditorSearchQuery() : '') . ' GROUP BY ' . $this->getGroupByColumns(), $params, $rangeInfo);
return new DAOResultFactory($result, $this, '_fromRow');
}