Skip to content

Commit

Permalink
Also use pagination for un-screened motions
Browse files Browse the repository at this point in the history
  • Loading branch information
CatoTH committed Sep 14, 2024
1 parent 42deec4 commit 090ea56
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions views/motion/_view_prevnext.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

use app\components\UrlHelper;
use app\models\db\Motion;
use app\models\db\{Motion, User};
use app\models\settings\{PrivilegeQueryContext, Privileges};
use yii\helpers\Html;

/**
Expand All @@ -16,7 +17,16 @@

$prevMotion = null;
$nextMotion = null;
$motions = \app\components\MotionSorter::getSortedIMotionsFlat($consultation, $consultation->motions);

$invisibleStatuses = $consultation->getStatuses()->getInvisibleMotionStatuses();
if (in_array($motion->status, $invisibleStatuses) && User::havePrivilege($consultation, Privileges::PRIVILEGE_ANY, PrivilegeQueryContext::anyRestriction())) {
$motions = array_values(array_filter($consultation->motions, fn(Motion $motion) => in_array($motion->status, $invisibleStatuses)));
usort($motions, function(Motion $a, Motion $b) {
return $a->getTimestamp() <=> $b->getTimestamp();
});
} else {
$motions = \app\components\MotionSorter::getSortedIMotionsFlat($consultation, $consultation->motions);
}
foreach ($motions as $idx => $itMotion) {
if ($motion->id !== $itMotion->id) {
continue;
Expand Down

0 comments on commit 090ea56

Please sign in to comment.