fix: traiter le deuxième lot de tickets

Refs #1 #2 #3 #13 #17
This commit is contained in:
Alexandre NOEL 2026-09-07 23:55:59 +02:00
commit 220c0ece82
18 changed files with 95 additions and 22 deletions

View file

@ -46,6 +46,14 @@ final class SettingsController
echo h(t('settings.invalid_email'));
return;
}
if (!Ids::validRna($values['association_rna'])) {
header('Location: /settings/general?error=' . rawurlencode(t('settings.invalid_rna')));
exit();
}
if (!Ids::validSiret($values['association_siret'])) {
header('Location: /settings/general?error=' . rawurlencode(t('settings.invalid_siret')));
exit();
}
$values['quarantine_days'] = (string) max(1, min(90, (int) ($_POST['quarantine_days'] ?? 15)));
$values['backup_retention'] = (string) max(1, min(50, (int) ($_POST['backup_retention'] ?? 10)));
$values['app_language'] = isset(I18n::LOCALES[(string) ($_POST['app_language'] ?? 'fr')])
@ -230,6 +238,7 @@ final class SettingsController
$color = (string) ($row['color'] ?? '#6c757d');
if (
$name === '' ||
mb_strlen($name) > 100 ||
!in_array($type, ['collective', 'boxes'], true) ||
!in_array($status, ['refuge', 'soin', 'quarantaine'], true) ||
!preg_match('/^#[0-9a-fA-F]{6}$/', $color)
@ -253,6 +262,9 @@ final class SettingsController
$new = (array) ($_POST['new_room'] ?? []);
$newName = trim((string) ($new['name'] ?? ''));
if ($newName !== '') {
if (mb_strlen($newName) > 100) {
throw new RuntimeException(t('rooms.name_too_long'));
}
$code = ShelterRoomService::normalizeCode((string) ($new['code'] ?? $newName));
if (strlen($code) < 2) {
throw new RuntimeException(t('rooms.invalid'));
@ -297,6 +309,9 @@ final class SettingsController
$known = $existing->fetchAll(PDO::FETCH_ASSOC);
$kept = [];
foreach ($names as $index => $name) {
if (mb_strlen($name) > 100) {
throw new RuntimeException(t('rooms.box_name_too_long'));
}
$position = ($index + 1) * 10;
if (isset($known[$index])) {
$id = (int) $known[$index]['id'];