diff --git a/classes/submission/Collector.php b/classes/submission/Collector.php index 48c799229e..535e6cab73 100644 --- a/classes/submission/Collector.php +++ b/classes/submission/Collector.php @@ -1,4 +1,5 @@ selectRaw('NULL AS submission_id')->whereRaw('1 = 0'); + + $q->whereIn('s.submission_id', function (Builder $query) { + $context = Application::get()->getRequest()->getContext(); + + $query->when($context->isDoiTypeEnabled(Repo::doi()::TYPE_REPRESENTATION), function (Builder $q) { + $q->select('p.submission_id') + ->from('publication_galleys AS g') + ->join('dois AS d', 'g.doi_id', '=', 'd.doi_id') + ->join('publications AS p', 'g.publication_id', '=', 'p.publication_id') + ->whereLike('d.doi', "{$this->searchPhrase}%"); + }) + ->when($context->isDoiTypeEnabled(Repo::doi()::TYPE_PUBLICATION), function (Builder $q) { + $q->union(function (Builder $query) { + $query->select('p.submission_id') + ->from('publications AS p') + ->join('dois AS d', 'p.doi_id', '=', 'd.doi_id') + ->whereLike('d.doi', "{$this->searchPhrase}%"); + }); + }); + }); + } }