Skip to content

Commit

Permalink
Fix chapter author ordering in Collector
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-stefan-weiher committed Oct 29, 2024
1 parent c1ab59e commit 1be2cfa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions classes/author/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace APP\author;

use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\JoinClause;

class Collector extends \PKP\author\Collector
{
Expand Down Expand Up @@ -41,14 +42,16 @@ public function getQueryBuilder(): Builder
{
$q = parent::getQueryBuilder();

$q->when($this->chapterIds !== null, function ($query) {
$query->whereIn('author_id', function ($query) {
return $query->select('author_id')
->from('submission_chapter_authors')
->whereIn('chapter_id', $this->chapterIds);
$q->when($this->chapterIds !== null, function (Builder $query) {
$query->join('submission_chapter_authors as sca', function (JoinClause $join) {
$join->whereIn('sca.chapter_id', $this->chapterIds)
->whereColumn('a.author_id', 'sca.author_id');
});
// Use the order specified by the submission_chapter_authors table,
// to ensure that the order of authors reflects the order from the manually sorted chapters grid
$query->orders = null;
$query->orderBy('sca.seq');
});

return $q;
}
}

0 comments on commit 1be2cfa

Please sign in to comment.