Commit 2f1dbb17 authored by Thomas Hamel's avatar Thomas Hamel
Browse files

Accès aux GEST_ED et RESP_ED pour la gestion des formations extérieures

parent 24ea9245
Loading
Loading
Loading
Loading
+12 −6
Changes for doc/release-notes/v10/10.1.0/02_formation_externe_attestation.sql: 12 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -50,9 +50,9 @@ INSERT INTO public.unicaen_privilege_privilege (categorie_id, code, libelle, ord
VALUES ((SELECT id FROM unicaen_privilege_categorie WHERE code = 'formation_formationexterne'), 'gerer-validation', 'Gérer les validations (valider/refuser/révoquer) d''une formation externe', 5);


--------------- Privilèges concernant le tableau de bord des formations pour Maison du doctorat
--------------- Privilèges concernant le tableau de bord de gestion des formations
INSERT INTO public.unicaen_privilege_privilege (categorie_id, code, libelle, ordre)
VALUES ((SELECT id FROM unicaen_privilege_categorie WHERE code = 'formation'), 'index_maison-doctorat', 'Accès à l''index maison du doctorat concernant un doctorant', 3);
VALUES ((SELECT id FROM unicaen_privilege_categorie WHERE code = 'formation'), 'index_gestion', 'Accès à l''index de gestion concernant un doctorant', 3);
----------------

INSERT INTO PROFIL_PRIVILEGE (PRIVILEGE_ID, PROFIL_ID)
@@ -77,25 +77,31 @@ from data
where not exists (select * from PROFIL_PRIVILEGE where PRIVILEGE_ID = p.id and PROFIL_ID = profil.id);

INSERT INTO PROFIL_PRIVILEGE (PRIVILEGE_ID, PROFIL_ID)
with data(categ, priv) as (select 'formation_formationexterne', 'telecharger-attestation')
with data(categ, priv) as (select 'formation_formationexterne', 'telecharger-attestation'
                           union
                           select 'formation_formationexterne', 'modifier')
select p.id as PRIVILEGE_ID, profil.id as PROFIL_ID
from data
         join PROFIL on profil.ROLE_ID in (
                                           'BDD'
                                           'BDD',
                                          'GEST_ED',
                                          'RESP_ED'
    )
         join unicaen_privilege_categorie cp on cp.CODE = data.categ
         join unicaen_privilege_privilege p on p.CATEGORIE_ID = cp.id and p.code = data.priv
where not exists (select * from PROFIL_PRIVILEGE where PRIVILEGE_ID = p.id and PROFIL_ID = profil.id);

INSERT INTO PROFIL_PRIVILEGE (PRIVILEGE_ID, PROFIL_ID)
with data(categ, priv) as (select 'formation', 'index_maison-doctorat'
with data(categ, priv) as (select 'formation', 'index_gestion'
                           union
                           select 'formation_formationexterne', 'gerer-validation')
select p.id as PRIVILEGE_ID, profil.id as PROFIL_ID
from data
         join PROFIL on profil.ROLE_ID in (
                                          'BDD',
                                          'ADMIN_TECH'
                                          'ADMIN_TECH',
                                          'GEST_ED',
                                          'RESP_ED'
    )
         join unicaen_privilege_categorie cp on cp.CODE = data.categ
         join unicaen_privilege_privilege p on p.CATEGORIE_ID = cp.id and p.code = data.priv
+10 −10
Changes for module/Formation/config/others/index.config.php: 10 added lines, 10 removed lines.
Original line number Diff line number Diff line
@@ -47,10 +47,10 @@ return [
                [
                    'controller' => IndexController::class,
                    'action' => [
                        'index-maison-doctorat',
                        'index-gestion',
                    ],
                    'privileges' => [
                        IndexPrivileges::INDEX_MAISON_DOCTORAT,
                        IndexPrivileges::INDEX_GESTION,
                    ],
                    'assertion' => IndexAssertion::class
                ],
@@ -94,17 +94,17 @@ return [
                                'class' => 'divider',
                                'separator' => true,
                            ],
                            'index-maison-doctorat' => [
                                'id' => 'index-maison-doctorat',
                            'index-gestion' => [
                                'id' => 'index-gestion',
                                'label' => 'Formation',
                                'order' => 36,
                                'route' => 'formation/index-maison-doctorat',
                                'route' => 'formation/index-gestion',
                                'withtarget' => true,
                                'paramsInject' => [
                                    'these',
                                ],
                            'icon' => 'fas fa-book-open',
                            'resource' => PrivilegeController::getResourceId(IndexController::class, 'index-maison-doctorat'),
                            'resource' => PrivilegeController::getResourceId(IndexController::class, 'index-gestion'),
                            'visible' => IndexAssertion::class,
                            ],
                        ]
@@ -151,15 +151,15 @@ return [
                            ],
                        ],
                    ],
                    'index-maison-doctorat' => [
                    'index-gestion' => [
                        'type'  => Segment::class,
                        'may_terminate' => true,
                        'options' => [
                            'route'    => '/index-maison-doctorat/:these',
                            'route'    => '/index-gestion/:these',
                            'defaults' => [
                                'controller' => IndexController::class,
                                /** @see IndexController::indexMaisonDoctoratAction() */
                                'action'     => 'index-maison-doctorat',
                                /** @see IndexController::indexGestionAction() */
                                'action'     => 'index-gestion',
                            ],
                        ],
                    ],
+5 −9
Changes for module/Formation/src/Formation/Assertion/FormationExterne/FormationExterneAssertion.php: 5 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ use Formation\Service\Formation\FormationExterne\FormationExterneServiceAwareTra
use JetBrains\PhpStorm\Pure;
use Laminas\Permissions\Acl\Assertion\AssertionInterface;
use Laminas\Permissions\Acl\Resource\ResourceInterface;
use These\Entity\Db\These;
use UnicaenApp\Service\MessageCollectorAwareInterface;

class FormationExterneAssertion extends AbstractAssertion implements  AssertionInterface,  UserContextServiceAwareInterface, MessageCollectorAwareInterface
@@ -92,20 +93,15 @@ class FormationExterneAssertion extends AbstractAssertion implements AssertionI
    }
    public function scopeValide(?FormationExterne $formationExterne): bool
    {
        $individu = $this->userContextService->getIdentityIndividu();
        $role = $this->userContextService->getSelectedIdentityRole();
        if (!$role) {
            return false;
        }

        $doctorant = $formationExterne->getDoctorant();
        switch ($role->getCode()) {
            case Role::CODE_DOCTORANT :
                $userDoctorant = $this->doctorantService->getRepository()->findOneByIndividu($individu);
                return $doctorant === $userDoctorant;
            case Role::CODE_BDD :
                return $doctorant && $doctorant->getEtablissement()->getStructure()->getCode() === $role->getStructure()->getCode();
        }
        return true;
        $theses = array_filter($doctorant->getTheses(), function (These $t) { return (in_array($t->getEtatThese(), [These::ETAT_EN_COURS, These::ETAT_SOUTENUE]) AND $t->estNonHistorise());});
        /** @var These $these */
        $these = (!empty($theses))?current($theses):null;
        return $this->userContextService->isStructureDuRoleRespecteeForThese($these);
    }
}
 No newline at end of file
+2 −24
Changes for module/Formation/src/Formation/Assertion/Index/IndexAssertion.php: 2 added lines, 24 removed lines.
Original line number Diff line number Diff line
@@ -52,11 +52,10 @@ class IndexAssertion extends AbstractAssertion implements AssertionInterface,

        try {
            switch($action) {
                case 'index-maison-doctorat' :
                case 'index-gestion' :
                    $these = $this->getRequestedThese();
                    if(!$these) return false;
                    $this->assertAppartenanceThese($these);
                    break;
                    return $this->userContextService->isStructureDuRoleRespecteeForThese($these);
                case 'index-doctorant' :
                    $doctorant = $this->getRequestedDoctorant();
                    if(!$doctorant) return true;
@@ -98,27 +97,6 @@ class IndexAssertion extends AbstractAssertion implements AssertionInterface,
            return null;
        }
    }
    private function assertAppartenanceThese(These $these)
    {
        $role = $this->userContextService->getSelectedIdentityRole();
        if (!$role) {
            return;
        }

        if ($role->isDoctorant()) {
            $doctorant = $this->userContextService->getIdentityDoctorant();
            $this->assertTrue(
                $these->getDoctorant()->getId() === $doctorant->getId(),
                "La thèse n'appartient pas au doctorant " . $doctorant
            );
        }
        elseif ($roleBDD = $this->userContextService->getSelectedRoleBDD()) {
            $this->assertTrue(
                $these->getEtablissement()->getStructure()->getId() === $roleBDD->getStructure()->getId(),
                "La thèse n'est pas rattachée à l'établissement " . $roleBDD->getStructure()->getCode()
            );
        }
    }

    public function scopeValideForDoctorant(?Doctorant $doctorant): bool
    {
+1 −1
Changes for module/Formation/src/Formation/Controller/IndexController.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ class IndexController extends AbstractController
        ]);
    }

    public function indexMaisonDoctoratAction() : ViewModel
    public function indexGestionAction() : ViewModel
    {
        $these = $this->requestedThese();
        $doctorant = $these->getDoctorant();
Loading