Commit 8ac98272 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Début du changement des unites de recherche

parent 6b6316e7
Loading
Loading
Loading
Loading
+49 −113
Changes for module/Application/config/others/unite-recherche.config.php: 49 added lines, 113 removed lines.
Original line number Diff line number Diff line
<?php

use Application\Controller\Factory\UniteRechercheControllerFactory;
use Application\Controller\UniteRechercheController;
use Application\Form\Factory\UniteRechercheFormFactory;
use Application\Form\Factory\UniteRechercheHydratorFactory;
use Application\Provider\Privilege\UniteRecherchePrivileges;
use Application\Provider\Privilege\StructurePrivileges;
use Application\Service\DomaineScientifiqueService;
use Application\Service\UniteRecherche\UniteRechercheService;
use UnicaenAuth\Guard\PrivilegeController;
use Application\View\Helper\UniteRechercheHelper;
use UnicaenAuth\Provider\Rule\PrivilegeRuleProvider;
use Zend\Mvc\Router\Http\Literal;
use Zend\Mvc\Router\Http\Segment;

return [
    'bjyauthorize'    => [
        'resource_providers' => [
            'BjyAuthorize\Provider\Resource\Config' => [
                'UniteRecherche' => [],
            ],
        ],
        'rule_providers'     => [
            PrivilegeRuleProvider::class => [
                'allow' => [
                    [
                        'privileges' => [
                            UniteRecherchePrivileges::UNITE_RECH_MODIFICATION,
                        ],
                        'resources'  => ['UniteRecherche'],
                        'assertion'  => 'Assertion\\UniteRecherche',
                    ],
                ],
            ],
        ],
        'guards' => [
            PrivilegeController::class => [
                [
                    'controller' => 'Application\Controller\UniteRecherche',
                    'controller' => UniteRechercheController::class,
                    'action'     => [
                        'index',
                        'information',
                    ],
                    'privileges' => UniteRecherchePrivileges::UNITE_RECH_CONSULTATION,
                    'privileges' => [
                        StructurePrivileges::STRUCTURE_CONSULTATION_TOUTES_STRUCTURES,
                        StructurePrivileges::STRUCTURE_CONSULTATION_SES_STRUCTURES,
                    ],
                ],
                [
                    'controller' => 'Application\Controller\UniteRecherche',
                    'controller' => UniteRechercheController::class,
                    'action'     => [
                        'ajouter',
                        'supprimer',
                        'restaurer',
                    ],
                    'privileges' => UniteRecherchePrivileges::UNITE_RECH_CREATION,
                    'privileges' => [
                        StructurePrivileges::STRUCTURE_MODIFICATION_TOUTES_STRUCTURES,
                        StructurePrivileges::STRUCTURE_MODIFICATION_SES_STRUCTURES,
                    ],
                ],
                [
                    'controller' => 'Application\Controller\UniteRecherche',
                    'controller' => UniteRechercheController::class,
                    'action'     => [
                        'modifier',
                        'ajouter-individu',
@@ -63,7 +52,10 @@ return [
                        'retirer-domaine-scientifique',
                        'principal-etablissement-rattachement',
                    ],
                    'privileges' => UniteRecherchePrivileges::UNITE_RECH_MODIFICATION,
                    'privileges' => [
                        StructurePrivileges::STRUCTURE_MODIFICATION_TOUTES_STRUCTURES,
                        StructurePrivileges::STRUCTURE_MODIFICATION_SES_STRUCTURES,
                    ],
                ],
            ],
        ],
@@ -71,14 +63,12 @@ return [
    'router'          => [
        'routes' => [
            'unite-recherche' => [
                'type'          => 'Segment',
                'type'          => Literal::class,
                'options'       => [
                    'route'    => '/[:language/]unite-recherche',
                    'route'    => '/unite-recherche',
                    'defaults' => [
                        '__NAMESPACE__' => 'Application\Controller',
                        'controller'    => 'UniteRecherche',
                        'controller'    => UniteRechercheController::class,
                        'action'        => 'index',
                        'language'      => 'fr_FR',
                    ],
                ],
                'may_terminate' => true,
@@ -86,14 +76,14 @@ return [
                    'information' => [
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/information/:uniteRecherche',
                            'route'       => '/information/:structure',
                            'defaults'    => [
                                'action' => 'information',
                            ],
                        ],
                    ],
                    'ajouter' => [
                        'type'          => 'Segment',
                        'type'          => Literal::class,
                        'options'       => [
                            'route'       => '/ajouter',
                            'defaults'    => [
@@ -102,138 +92,81 @@ return [
                        ],
                    ],
                    'supprimer' => [
                        'type'          => 'Segment',
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/:uniteRecherche/supprimer',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                            ],
                            'route'       => '/supprimer/:structure',
                            'defaults'    => [
                                'action' => 'supprimer',
                            ],
                        ],
                    ],
                    'restaurer' => [
                        'type'          => 'Segment',
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/:uniteRecherche/restaurer',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                            ],
                            'route'       => '/restaurer/:structure',
                            'defaults'    => [
                                'action' => 'restaurer',
                            ],
                        ],
                    ],
                    'modifier' => [
                        'type'          => 'Segment',
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/:uniteRecherche/modifier',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                            ],
                            'route'       => '/modifier/:structure',
                            'defaults'    => [
                                'action' => 'modifier',
                            ],
                        ],
                    ],
                    'ajouter-etablissement-rattachement' => [
                        'type'          => 'Segment',
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/:uniteRecherche/ajouter-etablissement-rattachement/:etablissement',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                                'etablissement' => '\d+',
                            ],
                            'route'       => '/ajouter-etablissement-rattachement/:structure/:etablissement',
                            'defaults'    => [
                                'action' => 'ajouter-etablissement-rattachement',
                            ],
                        ],
                    ],
                    'retirer-etablissement-rattachement' => [
                        'type'          => 'Segment',
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/:uniteRecherche/retirer-etablissement-rattachement/:etablissement',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                                'etablissement' => '\d+',
                            ],
                            'route'       => '/retirer-etablissement-rattachement/:structure/:etablissement',
                            'defaults'    => [
                                'action' => 'retirer-etablissement-rattachement',
                            ],
                        ],
                    ],
                    'principal-etablissement-rattachement' => [
                        'type'          => 'Segment',
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/:uniteRecherche/principal-etablissement-rattachement/:etablissement',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                                'etablissement' => '\d+',
                            ],
                            'route'       => '/principal-etablissement-rattachement/:structure/:etablissement',
                            'defaults'    => [
                                'action' => 'principal-etablissement-rattachement',
                            ],
                        ],
                    ],
                    'ajouter-domaine-scientifique' => [
                        'type'          => 'Segment',
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/:uniteRecherche/ajouter-domaine-scientifique/:domaineScientifique',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                                'domaineScientifique' => '\d+',
                            ],
                            'route'       => '/ajouter-domaine-scientifique/:structure/:domaineScientifique',
                            'defaults'    => [
                                'action' => 'ajouter-domaine-scientifique',
                            ],
                        ],
                    ],
                    'retirer-domaine-scientifique' => [
                        'type'          => 'Segment',
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/:uniteRecherche/retirer-domaine-scientifique/:domaineScientifique',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                                'domaineScientifique' => '\d+',
                            ],
                            'route'       => '/retirer-domaine-scientifique/:structure/:domaineScientifique',
                            'defaults'    => [
                                'action' => 'retirer-domaine-scientifique',
                            ],
                        ],
                    ],
                    'ajouter-individu' => [
                        'type'          => 'Segment',
                        'options'       => [
                            'route'       => '/:uniteRecherche/ajouter-individu',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                            ],
                            'defaults'    => [
                                'action' => 'ajouter-individu',
                            ],
                        ],
                    ],
                    'retirer-individu' => [
                        'type'          => 'Segment',
                        'options'       => [
                            'route'       => '/:uniteRecherche/retirer-individu/:edi',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                                'edi' => '\d+',
                            ],
                            'defaults'    => [
                                'action' => 'retirer-individu',
                            ],
                        ],
                    ],
                    'supprimer-logo' => [
                        'type'          => 'Segment',
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/supprimer-logo/:uniteRecherche',
                            'constraints' => [
                                'uniteRecherche' => '\d+',
                            ],
                            'route'       => '/supprimer-logo/:structure',
                            'defaults'    => [
                                'action' => 'supprimer-logo',
                            ],
@@ -252,28 +185,28 @@ return [
                            'unite-recherche' => [
                                'label'    => 'Unités de recherche',
                                'route'    => 'unite-recherche',
                                'resource' => PrivilegeController::getResourceId('Application\Controller\UniteRecherche', 'index'),
                                'resource' => PrivilegeController::getResourceId(UniteRechercheController::class, 'index'),

                                'order'    => 20,
                                'pages' => [
                                    'modification' => [
                                        'label'    => 'Modification',
                                        'route'    => 'unite-recherche/modifier',
                                        'resource' => PrivilegeController::getResourceId('Application\Controller\UniteRecherche', 'index'),
                                        'resource' => PrivilegeController::getResourceId(UniteRechercheController::class, 'index'),

                                        'withtarget' => true,
                                        'paramsInject' => [
                                            'uniteRecherche',
                                            'structure',
                                        ],
                                    ],
                                    'information' => [
                                        'label'    => 'Détails',
                                        'route'    => 'unite-recherche/information',
                                        'resource' => PrivilegeController::getResourceId('Application\Controller\UniteRecherche', 'index'),
                                        'resource' => PrivilegeController::getResourceId(UniteRechercheController::class, 'index'),

                                        'withtarget' => true,
                                        'paramsInject' => [
                                            'uniteRecherche',
                                            'structure',
                                        ],
                                    ],
                                ],
@@ -301,6 +234,9 @@ return [
        'factories' => [
            'Application\Controller\UniteRecherche' => UniteRechercheControllerFactory::class,
        ],
        'aliases' => [
            UniteRechercheController::class => 'Application\Controller\UniteRecherche',
        ]
    ],
    'form_elements'   => [
        'invokables' => [
+24 −28
Changes for module/Application/src/Application/Controller/UniteRechercheController.php: 24 added lines, 28 removed lines.
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ use Application\Entity\Db\Individu;
use Application\Entity\Db\IndividuRole;
use Application\Entity\Db\Role;
use Application\Entity\Db\Structure;
use Application\Entity\Db\StructureConcreteInterface;
use Application\Entity\Db\TypeStructure;
use Application\Entity\Db\UniteRecherche;
use Application\Form\UniteRechercheForm;
@@ -47,7 +46,7 @@ class UniteRechercheController extends AbstractController

    public function informationAction()
    {
        $id = $this->params()->fromRoute('uniteRecherche');
        $id = $this->params()->fromRoute('structure');
        $unite = $this->getUniteRechercheService()->getRepository()->findByStructureId($id);
        if ($unite === null) {
            throw new RuntimeException("Aucune unité de recherche ne possède l'identifiant renseigné.");
@@ -99,8 +98,8 @@ class UniteRechercheController extends AbstractController
    public function modifierAction()
    {
        /** @var UniteRecherche $unite */
        $uniteId = $this->params()->fromRoute("uniteRecherche");
        $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($uniteId);
        $structureId = $this->params()->fromRoute("structure");
        $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($structureId);
        $this->uniteRechercheForm->bind($unite);

        // si POST alors on revient du formulaire
@@ -116,7 +115,7 @@ class UniteRechercheController extends AbstractController
            // action d'affacement du logo
            if (isset($data['supprimer-logo'])) {
                $this->supprimerLogoUniteRecherche();
                return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $uniteId], "fragment" => $uniteId], true);
                return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $structureId], "fragment" => $structureId], true);
            }

            // action de modification
@@ -132,10 +131,10 @@ class UniteRechercheController extends AbstractController
                $this->getUniteRechercheService()->update($unite);

                $this->flashMessenger()->addSuccessMessage("Unité de recherche '$unite' modifiée avec succès");
                return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $uniteId], "fragment" => "".$uniteId], true);
                return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $structureId], "fragment" => "".$structureId], true);
            }
            $this->flashMessenger()->addErrorMessage("Echec de la mise à jour : données incorrectes saissie");
            return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $uniteId], "fragment" => "".$uniteId], true);
            return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $structureId], "fragment" => "".$structureId], true);
        }

        $etablissements = $this->getEtablissementService()->getRepository()->findAll();
@@ -200,26 +199,26 @@ class UniteRechercheController extends AbstractController

    public function supprimerAction()
    {
        $uniteId = $this->params()->fromRoute("uniteRecherche");
        $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($uniteId);
        $structureId = $this->params()->fromRoute("structure");
        $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($structureId);

        $this->getUniteRechercheService()->deleteSoftly($unite, $this->userContextService->getIdentityDb());

        $this->flashMessenger()->addSuccessMessage("Unité de recherche '$unite' supprimée avec succès");

        return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $uniteId], "fragment" => $uniteId], true);
        return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $structureId], "fragment" => $structureId], true);
    }

    public function restaurerAction()
    {
        $uniteId = $this->params()->fromRoute("uniteRecherche");
        $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($uniteId);
        $structureId = $this->params()->fromRoute("structure");
        $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($structureId);

        $this->getUniteRechercheService()->undelete($unite);

        $this->flashMessenger()->addSuccessMessage("Unité de recherche '$unite' restaurée avec succès");

        return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $uniteId], "fragment" => $uniteId], true);
        return $this->redirect()->toRoute('unite-recherche', [], ['query' => ['selected' => $structureId], "fragment" => $structureId], true);
    }

    /**
@@ -252,8 +251,8 @@ class UniteRechercheController extends AbstractController
     */
    public function supprimerLogoUniteRecherche()
    {
        $uniteId = $this->params()->fromRoute("uniteRecherche");
        $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($uniteId);
        $structureId = $this->params()->fromRoute("structure");
        $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($structureId);

        $this->getUniteRechercheService()->deleteLogo($unite);
        $filename   = UniteRechercheController::getLogoFilename($unite, true);
@@ -285,8 +284,8 @@ class UniteRechercheController extends AbstractController
        }

        if ($unite === null) {
            $uniteId = $this->params()->fromRoute("uniteRecherche");
            $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($uniteId);
            $structureId = $this->params()->fromRoute("structure");
            $unite  = $this->getUniteRechercheService()->getRepository()->findByStructureId($structureId);
        }
        $chemin     = UniteRechercheController::getLogoFilename($unite, false);
        $filename   = UniteRechercheController::getLogoFilename($unite, true);
@@ -315,8 +314,8 @@ class UniteRechercheController extends AbstractController

    public function ajouterEtablissementRattachementAction()
    {
        $uniteId = $this->params()->fromRoute("uniteRecherche");
        $unite = $this->getUniteRechercheService()->getRepository()->findByStructureId($uniteId);
        $structureId = $this->params()->fromRoute("structure");
        $unite = $this->getUniteRechercheService()->getRepository()->findByStructureId($structureId);
        $etablissementId = $this->params()->fromRoute("etablissement");

        if ($etablissementId == 0) {
@@ -336,8 +335,8 @@ class UniteRechercheController extends AbstractController

    public function retirerEtablissementRattachementAction()
    {
        $uniteId = $this->params()->fromRoute("uniteRecherche");
        $unite = $this->getUniteRechercheService()->getRepository()->findByStructureId($uniteId);
        $structureId = $this->params()->fromRoute("structure");
        $unite = $this->getUniteRechercheService()->getRepository()->findByStructureId($structureId);
        $etablissementId = $this->params()->fromRoute("etablissement");
        $etablissement = $this->getEtablissementService()->getRepository()->find($etablissementId);

@@ -347,15 +346,13 @@ class UniteRechercheController extends AbstractController
        $this->redirect()->toRoute("unite-recherche/modifier",[],[], true);
    }


    /**
     * @throws \Doctrine\ORM\NonUniqueResultException
     * @throws \Doctrine\ORM\OptimisticLockException
     */
    public function ajouterDomaineScientifiqueAction() {
        $uniteId = $this->params()->fromRoute("uniteRecherche");
        $structureId = $this->params()->fromRoute("structure");
        $domaineId = $this->params()->fromRoute("domaineScientifique");
        $unite = $this->getUniteRechercheService()->getRepository()->findByStructureId($uniteId);
        $unite = $this->getUniteRechercheService()->getRepository()->findByStructureId($structureId);
        $domaine = $this->getDomaineScientifiqueService()->getRepository()->find($domaineId);

        if ($domaine !== null && !array_search($domaine, $unite->getDomaines())) {
@@ -370,13 +367,12 @@ class UniteRechercheController extends AbstractController
    }

    /**
     * @throws \Doctrine\ORM\NonUniqueResultException
     * @throws \Doctrine\ORM\OptimisticLockException
     */
    public function retirerDomaineScientifiqueAction() {
        $uniteId = $this->params()->fromRoute("uniteRecherche");
        $structureId = $this->params()->fromRoute("structure");
        $domaineId = $this->params()->fromRoute("domaineScientifique");
        $unite = $this->getUniteRechercheService()->getRepository()->findByStructureId($uniteId);
        $unite = $this->getUniteRechercheService()->getRepository()->findByStructureId($structureId);
        $domaine = $this->getDomaineScientifiqueService()->getRepository()->find($domaineId);

        $domaine = $domaine->removeUnite($unite);
+10 −11

File changed.

Preview size limit exceeded, changes collapsed.