Commit d1f79c49 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

[FIX] Doctorant : correction de DoctorantAssertion qui interdisait l'accès au...

[FIX] Doctorant : correction de DoctorantAssertion qui interdisait l'accès au rôle Admin tech notamment.
parent e2babad7
Loading
Loading
Loading
Loading
+1 −0
Changes for CHANGELOG.md: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ Journal des modifications
- FichierViewHelper : plus qu'un seul argument dans __invoke() donc utilisation des setters ; cosmétique pour le nom du fichier.
- Traitement d'une inscription administrative reçue : précision lorsque le dossier d'admission trouvé est lié à un doctorant.
- Doctorant : nouvelle page 'consulter' ; remplacement de liens 'tableau-de-bord' par 'consulter'. 
- [FIX] Doctorant : correction de DoctorantAssertion qui interdisait l'accès au rôle Admin tech notamment.  
- [FIX] Plantage des notifications à propos des résultats de thèse passant à Admis (iterator vide à cause d'un critère de filtrage erroné).
- [FIX] TheseEtatRule : suppression d'une vérif empêchant la validation de la thèse corrigée par le président du jury (Transition d'état impossible : S → E).
- [FIX] Ajout du critère de la Source dans la recherche d'origine de financement par code.
+15 −1
Changes for module/Doctorant/config/others/doctorant.config.php: 15 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -112,12 +112,12 @@ return [
                        DoctorantPrivileges::DOCTORANT_LISTER_TOUT,
                        DoctorantPrivileges::DOCTORANT_LISTER_SIEN,
                    ],
//                    'roles' => 'user', //////////////////////////////////////// todo provisoire !!!!!!!!!!!!
                ],
                [
                    'controller' => DoctorantController::class,
                    'action' => [
                        'tableau-de-bord',
                        'consulter',
                    ],
                    'privileges' => [
                        DoctorantPrivileges::DOCTORANT_CONSULTER_TOUS,
@@ -240,6 +240,20 @@ return [
                            ],
                        ],
                    ],
                    'consulter' => [
                        'type' => Segment::class,
                        'options' => [
                            'route' => '/consulter/:doctorant',
                            'constraints' => [
                                'doctorant' => '\d+',
                            ],
                            'defaults' => [
                                /** @see DoctorantController::consulterAction() */
                                'controller' => DoctorantController::class,
                                'action' => 'consulter',
                            ],
                        ],
                    ],
                    'modifier' => [
                        'type' => Segment::class,
                        'options' => [
+17 −11
Changes for module/Doctorant/src/Doctorant/Assertion/DoctorantAssertion.php: 17 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ use Acteur\Service\ActeurThese\ActeurTheseServiceAwareTrait;
use Application\Assertion\AbstractAssertion;
use Application\Assertion\Exception\FailedAssertionException;
use Application\Assertion\ThrowsFailedAssertionExceptionTrait;
use Application\Entity\Db\Role;
use Application\RouteMatch;
use Application\Service\UserContextServiceAwareInterface;
use Doctorant\Entity\Db\Doctorant;
@@ -55,11 +54,13 @@ class DoctorantAssertion extends AbstractAssertion
                    return true;

                default:
                    $theses = $this->theseService->getRepository()->findThesesByDoctorant($entity, These::ETATS_TOUS);
                    return !empty(
                        array_filter($theses, fn(These $t) => $this->userContextService->isStructureDuRoleRespecteeForThese($t))
                    );
                    if ($role->isStructureDependant()) {
                        $this->assertDoctorantHasTheseInStructureDuRole($entity);
                    }
                    break;
            }

            return true;
        } catch (FailedAssertionException $e) {
            if ($e->getMessage()) {
                $this->getServiceMessageCollector()->addMessage($e->getMessage(), __CLASS__);
@@ -82,12 +83,8 @@ class DoctorantAssertion extends AbstractAssertion
            switch ($privilege) {
                case DoctorantPrivileges::DOCTORANT_CONSULTER_SIEN:
                case DoctorantPrivileges::DOCTORANT_MODIFIER_SIEN:
                case DoctorantPrivileges::DOCTORANT_CONSULTER_TOUS:
                    $theses = $this->theseService->getRepository()->findThesesByDoctorant($entity, These::ETATS_TOUS);

                    return !empty(
                        array_filter($theses, fn(These $t) => $this->userContextService->isStructureDuRoleRespecteeForThese($t))
                    );
                    $this->assertDoctorantHasTheseInStructureDuRole($entity);
                    break;

                case DoctorantPrivileges::DOCTORANT_AFFICHER_EMAIL_CONTACT:
                case DoctorantPrivileges::DOCTORANT_MODIFIER_EMAIL_CONTACT: // NB : privilègie uitlisé aussi pour la modif du consentement
@@ -100,6 +97,8 @@ class DoctorantAssertion extends AbstractAssertion
                    return false;
            }

            return true;

        } catch (FailedAssertionException $e) {
            if ($e->getMessage()) {
                $this->getServiceMessageCollector()->addMessage($e->getMessage(), __CLASS__);
@@ -117,6 +116,13 @@ class DoctorantAssertion extends AbstractAssertion
        return $doctorant->getId() === $identity->getId();
    }

    private function assertDoctorantHasTheseInStructureDuRole(Doctorant $doctorant): void
    {
        $theses = $this->theseService->getRepository()->findThesesByDoctorant($doctorant, These::ETATS_TOUS);
        $theses = array_filter($theses, fn(These $t) => $this->userContextService->isStructureDuRoleRespecteeForThese($t));
        $this->assertTrue(!empty($theses));
    }

    private function getRequestedDoctorant(): ?Doctorant
    {
        if ($routeMatch = $this->getRouteMatch()) {