Fix: acc periods of which user is the referrer should not be included if when the list is filtered by center and none of the participations are part of the center

This commit is contained in:
2026-01-15 13:22:38 +01:00
parent 06c5affbe7
commit f3217d22ef
2 changed files with 17 additions and 7 deletions

View File

@@ -0,0 +1,6 @@
kind: Fixed
body: 'Fix: acc periods of which user is the referrer should not be included if when the list is filtered by center and none of the participations are part of the center'
time: 2026-01-15T13:25:38.269774735+01:00
custom:
Issue: "491"
SchemaChange: No schema change

View File

@@ -44,12 +44,10 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc
};
// add filtering on confidential accompanying period. The confidential is applyed on the current status of
// the accompanying period (we do not use the 'calc_date' here
$aclConditionsOrX = $qb->expr()->orX(
// either the current user is the refferer for the course
'acp.user = :list_acp_current_user',
);
$qb->setParameter('list_acp_current_user', $user);
// the accompanying period (we do not use the 'calc_date' here)
//
// IMPORTANT: we must NOT bypass selected centers just because the current user is the referrer.
$aclConditionsOrX = $qb->expr()->orX();
$i = 0;
foreach ($centers as $center) {
@@ -93,6 +91,12 @@ final readonly class FilterListAccompanyingPeriodHelper implements FilterListAcc
++$i;
}
$qb->andWhere($aclConditionsOrX);
// Prevent invalid/empty WHERE when no conditions were added (e.g., no centers available)
if (method_exists($aclConditionsOrX, 'getParts') && 0 === count($aclConditionsOrX->getParts())) {
// No allowed conditions => return no rows
$qb->andWhere('1 = 0');
} else {
$qb->andWhere($aclConditionsOrX);
}
}
}