diff --git a/CHANGELOG.md b/CHANGELOG.md index ca640f82764b28937a6371e9a0b448c350455a75..b315803abc0d31546d3986134d5b4c33a19958d9 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ dans le détail des services. * Procédures d'installation et de mise à jour intégrées directement au projet dans Gitlab. * Certains dossiers intervenants pouvaient être validés plusieurs fois. Un mécanisme contrôle désormais que le dossier n'est pas déjà validé avant de valider à nouveau. +* Le contrôle de cohérence des données personnelles prend maintenant en compte le cas des français nés dans un ex-département français d'Algérie. ## Nouveautés diff --git a/code/test1.php b/code/test1.php index 8b6668b40d327ef3738fd50e852faab0151da1a7..cd8e8152adff1e1152fd04ccfb63b3c327b20c8f 100755 --- a/code/test1.php +++ b/code/test1.php @@ -7,10 +7,9 @@ * @var $sl \Zend\ServiceManager\ServiceLocatorInterface */ -$command = 'unoconv -f pdf -o /app/test.pdf /app/test.odt'; -//$command = 'systemctl list-units'; -//$command = 'ls'; +$sp = $sl->get(\Application\Service\PaysService::class); -exec($command, $output, $return); -var_dump($output); -var_dump($return); \ No newline at end of file + +$france = $sp->getIdByLibelle('Algérie'); + +var_dump($france); \ No newline at end of file diff --git a/module/Application/src/Application/Form/Intervenant/DossierFieldset.php b/module/Application/src/Application/Form/Intervenant/DossierFieldset.php index b6929188b5a1e2c6d628a1fe977edd9a396cf556..cce18f96a87daf4e6434425063f3cf40bec4c240 100755 --- a/module/Application/src/Application/Form/Intervenant/DossierFieldset.php +++ b/module/Application/src/Application/Form/Intervenant/DossierFieldset.php @@ -3,8 +3,6 @@ namespace Application\Form\Intervenant; use Application\Entity\Db\Dossier as Dossier; -use Application\Entity\Db\Pays as PaysEntity; -use Application\Entity\Db\Pays; use Application\Entity\Db\StatutIntervenant; use Application\Form\AbstractFieldset; use Application\Service\Traits\CiviliteServiceAwareTrait; @@ -370,7 +368,7 @@ class DossierFieldset extends AbstractFieldset 'departementNaissance' => [ 'required' => $departementRequired, 'validators' => [ - new DepartementNaissanceValidator(['france_id' => self::$franceId]), + new DepartementNaissanceValidator(), ], ], 'villeNaissance' => [ diff --git a/module/Application/src/Application/Service/PaysService.php b/module/Application/src/Application/Service/PaysService.php index d7100f41ab0e12268d4c24bee7950002fe567282..f2a99700de958edd477f74cc761ea0f5147d2ad9 100755 --- a/module/Application/src/Application/Service/PaysService.php +++ b/module/Application/src/Application/Service/PaysService.php @@ -5,12 +5,17 @@ namespace Application\Service; use Application\Entity\Db\Pays; use Application\Service\Traits\ParametresServiceAwareTrait; use Doctrine\ORM\QueryBuilder; +use UnicaenApp\Util; /** * Description of Pays */ class PaysService extends AbstractEntityService { + CONST PAYS_FRANCE = 'france '; + CONST PAYS_ALGERIE = 'algerie'; + + use ParametresServiceAwareTrait; @@ -40,13 +45,19 @@ class PaysService extends AbstractEntityService /** - * @return Pays + * @return int|null */ - public function getFrance(): Pays + public function getIdByLibelle(string $libelle) { - $franceId = $this->getServiceParametres()->get('pays_france'); + $sql = 'SELECT id FROM pays WHERE ose_divers.str_reduce(libelle_court) = :pays'; + + $res = $this->getEntityManager()->getConnection()->fetchAll($sql, ['pays' => Util::reduce($libelle)]); + + if (isset($res[0]['ID'])){ + return (int)$res[0]['ID']; + } - return $this->get($franceId); + return null; } @@ -58,7 +69,7 @@ class PaysService extends AbstractEntityService */ public function isFrance(Pays $pays): bool { - return $pays == $this->getFrance(); + return $pays->getId() == $this->getIdByLibelle(self::PAYS_FRANCE); } diff --git a/module/Application/src/Application/Validator/DepartementNaissanceValidator.php b/module/Application/src/Application/Validator/DepartementNaissanceValidator.php index 8105a33c86c50f921e201cf49d15647e5f782392..74fbb140a69b1643359c9bffad6fbc569d3feea7 100755 --- a/module/Application/src/Application/Validator/DepartementNaissanceValidator.php +++ b/module/Application/src/Application/Validator/DepartementNaissanceValidator.php @@ -2,11 +2,13 @@ namespace Application\Validator; -use LogicException; +use Application\Service\Traits\PaysServiceAwareTrait; use Zend\Validator\AbstractValidator; class DepartementNaissanceValidator extends AbstractValidator { + use PaysServiceAwareTrait; + const MSG_NOT_REQUIRED = 'msgNotRequired'; const MSG_REQUIRED = 'msgRequired'; @@ -20,12 +22,8 @@ class DepartementNaissanceValidator extends AbstractValidator public function __construct($options = null) { parent::__construct($options); - - if (!isset($options['france_id'])) { - throw new LogicException("Paramètre 'france_id' introuvable."); - } - - $this->franceId = $options['france_id']; + + $this->franceId = $this->getServicePays()->getIdByLibelle($this->getServicePays()::PAYS_FRANCE); } public function isValid($value, $context = null) diff --git a/module/Application/src/Application/Validator/NumeroINSEEValidator.php b/module/Application/src/Application/Validator/NumeroINSEEValidator.php index 098ee2fdda30d260d2d8377121d5e0d792db3cc1..105db5e8c4e004979f4660a3655098f011aedab4 100755 --- a/module/Application/src/Application/Validator/NumeroINSEEValidator.php +++ b/module/Application/src/Application/Validator/NumeroINSEEValidator.php @@ -4,6 +4,7 @@ namespace Application\Validator; use Application\Service\Traits\CiviliteServiceAwareTrait; use Application\Service\Traits\DepartementServiceAwareTrait; +use Application\Service\Traits\PaysServiceAwareTrait; use LogicException; use UnicaenApp\Validator\NumeroINSEE; @@ -21,12 +22,21 @@ class NumeroINSEEValidator extends NumeroINSEE { use DepartementServiceAwareTrait; use CiviliteServiceAwareTrait; + use PaysServiceAwareTrait; const MSG_CIVILITE = 'msgCivilite'; const MSG_ANNEE = 'msgAnnee'; const MSG_MOIS = 'msgMois'; const MSG_DEPT = 'msgDepartement'; + /** + * @var ?int + */ + protected $algerieId; + + /** + * @var ?int + */ protected $franceId; @@ -40,11 +50,8 @@ class NumeroINSEEValidator extends NumeroINSEE self::MSG_DEPT => "Le numéro n'est pas cohérent avec le pays et l'éventuel département de naissance saisi", ]); - if (!isset($options['france_id'])) { - throw new LogicException("Paramètre 'france_id' introuvable."); - } - - $this->franceId = (int)$options['france_id']; + $this->franceId = $this->getServicePays()->getIdByLibelle('FRANCE'); + $this->algerieId = $this->getServicePays()->getIdByLibelle('ALGERIE'); if (!isset($options['serviceDepartement'])) { throw new LogicException("Service Département non fourni."); @@ -167,14 +174,21 @@ class NumeroINSEEValidator extends NumeroINSEE return true; } - $paysNaissance = (int)$context['paysNaissance']; - $estNeEnFrance = $paysNaissance === $this->franceId; + $paysNaissance = (int)$context['paysNaissance']; + $estNeEnFrance = $paysNaissance === $this->franceId; + $estNeEnAlgerie = $paysNaissance === $this->algerieId; if ($estNeEnFrance) { // on doit avoir un code département français valide if (!$this->isValidDepartementFrance($value, $context)) { return false; } + } + if ($estNeEnAlgerie) { + // on doit avoir un code département français valide + if (!$this->isValidDepartementAlgerie($value, $context)) { + return false; + } } else { // on doit avoir un code pays étranger valide if (!$this->isValidDepartementHorsFrance($value)) { @@ -280,6 +294,22 @@ class NumeroINSEEValidator extends NumeroINSEE + private function isValidDepartementAlgerie($value, $context) + { + $departement = substr($value, 5, 2); + + if (is_numeric($departement)) { + $d = (int)$departement; + if (in_array($d, [91,92,93,94,99])) { + return '0' . (string)$departement; + } + } + + return null; + } + + + /** * Teste si un numéro INSEE possède le code département de naissance associé à un pays étranger. *