feat: all-season assignments

This commit is contained in:
Björn Fromme authored and Björn Fromme committed 2026-09-26 12:13:16 +02:00
1 parent 675cec1b69
commit cf876ed224
119 files changed
+6194 -294

No files matched your search

+22 -1
View File
@@ -50,9 +50,30 @@ class UploadVoter extends Voter
/** @var User $user */
$user = $token->getUser();
return Upload::TYPE_DOCUMENT === $upload->getType() || $user === $upload->getOwner();
if (Upload::TYPE_DOCUMENT === $upload->getType() || $user === $upload->getOwner()) {
return true;
}
// A document the office issues for one single teamer is owned by the admin who
// uploaded it, so neither rule above reaches it - and it must not be TYPE_DOCUMENT,
// since that type is the staff-wide library every teamer may read. The teamer it was
// issued to is therefore let in through their own season assignment.
return static::DOWNLOAD === $attribute && $this->isOwnSeasonDocument($upload, $user);
}
return false;
}
private function isOwnSeasonDocument(Upload $upload, User $user): bool
{
if (Upload::TYPE_SEASON_DOCUMENT_OUT !== $upload->getType()) {
return false;
}
if (null === $teamer = $upload->getSeasonAssignment()?->getTeamer()) {
return false;
}
return $teamer === $user->getTeamer();
}
}