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

IndividuIndex Première version fonctionnelle

parent 7271492d
Loading
Loading
Loading
Loading
+10 −0
Changes for module/Application/config/others/utilisateur.config.php: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ return [
                        'index',
                        'index-bis',
                        'retirer-role',
                        'ajouter-role',
                    ],
                    'privileges' => UtilisateurPrivileges::UTILISATEUR_CONSULTATION,
                ],
@@ -147,6 +148,15 @@ return [
                            ],
                        ],
                    ],
                    'ajouter-role' => [
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/ajouter-role/:individu/:role',
                            'defaults'    => [
                                'action' => 'ajouter-role',
                            ],
                        ],
                    ],

                ],
            ],
+12 −0
Changes for module/Application/src/Application/Controller/Factory/UtilisateurControllerFactory.php: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,8 +3,11 @@
namespace Application\Controller\Factory;

use Application\Controller\UtilisateurController;
use Application\Service\EcoleDoctorale\EcoleDoctoraleService;
use Application\Service\Etablissement\EtablissementService;
use Application\Service\Individu\IndividuServiceLocateTrait;
use Application\Service\Role\RoleService;
use Application\Service\UniteRecherche\UniteRechercheService;
use Application\Service\Utilisateur\UtilisateurService;
use Doctrine\ORM\EntityManager;
use UnicaenLdap\Service\People as LdapPeopleService;
@@ -22,11 +25,17 @@ class UtilisateurControllerFactory
         * @var RoleService $roleService
         * @var UtilisateurService $utilisateurService
         * @var LdapPeopleService $ldapPeopleService
         * @var EtablissementService $etablissementService
         * @var EcoleDoctoraleService $ecoleService
         * @var UniteRechercheService $uniteService
         * @var EntityManager $entityManager;
         */
        $roleService = $sl->get('RoleService');
        $ldapPeopleService  = $sl->get('LdapServicePeople');
        $utilisateurService = $sl->get('UtilisateurService');
        $etablissementService = $sl->get('EtablissementService');
        $ecoleService = $sl->get('EcoleDoctoraleService');
        $uniteService = $sl->get('UniteRechercheService');
        $entityManager = $sl->get('doctrine.entitymanager.orm_default');

        $controller = new UtilisateurController();
@@ -34,6 +43,9 @@ class UtilisateurControllerFactory
        $controller->setLdapPeopleService($ldapPeopleService);
        $controller->setUtilisateurService($utilisateurService);
        $controller->setIndividuService($this->locateIndividuService($sl));
        $controller->setUniteRechercheService($uniteService);
        $controller->setEcoleDoctoraleService($ecoleService);
        $controller->setEtablissementService($etablissementService);
        $controller->setEntityManager($entityManager);

        return $controller;
+26 −1
Changes for module/Application/src/Application/Controller/UtilisateurController.php: 26 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -7,8 +7,11 @@ use Application\Entity\Db\Role;
use Application\Entity\Db\Utilisateur;
use Application\Form\CreationUtilisateurForm;
use Application\RouteMatch;
use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
use Application\Service\Individu\IndividuServiceAwareTrait;
use Application\Service\Role\RoleServiceAwareTrait;
use Application\Service\UniteRecherche\UniteRechercheServiceAwareTrait;
use Application\Service\UserContextServiceAwareTrait;
use Application\Service\Utilisateur\UtilisateurServiceAwareTrait;
use Application\View\Helper\Sortable;
@@ -39,6 +42,9 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle
    use LdapPeopleServiceAwareTrait;
    use IndividuServiceAwareTrait;
    use EntityManagerAwareTrait;
    use EcoleDoctoraleServiceAwareTrait;
    use UniteRechercheServiceAwareTrait;
    use EtablissementServiceAwareTrait;

    /**
     * @return array|\Zend\Http\Response|ViewModel
@@ -362,11 +368,21 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle
            $data = $request->getPost()['individu'];
            /** @var Individu $individu */
            $individu = $this->individuService->getIndviduById($data['id']);
            $roles = $this->roleService->getRoleByIndividu($individu);
            $rolesAffectes = $this->roleService->getRoleByIndividu($individu);
        }

        $roles = $this->roleService->getRoles();
        $etablissements = $this->etablissementService->getEtablissements();
        $unites = $this->uniteRechercheService->getUnitesRecherches();
        $ecoles = $this->ecoleDoctoraleService->getEcolesDoctorales();

        return new ViewModel([
            'individu' => $individu,
            'roles' => $roles,
            'rolesAffectes' => $rolesAffectes,
            'etablissements' => $etablissements,
            'ecoles' => $ecoles,
            'unites' => $unites,
        ]);
    }

@@ -379,4 +395,13 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle

        return new ViewModel([]);
    }

    public function ajouterRoleAction()
    {
        $individuId = $this->params()->fromRoute('individu');
        $roleId = $this->params()->fromRoute('role');

        $this->roleService->addRole($individuId, $roleId);
        return new ViewModel([]);
    }
}
 No newline at end of file
+1 −0
Changes for module/Application/src/Application/Entity/Db/Individu.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -359,6 +359,7 @@ class Individu implements HistoriqueAwareInterface, SourceAwareInterface
     */
    public function getDateNaissanceToString()
    {
        if ($this->dateNaissance === null) return "";
        return $this->dateNaissance->format(Constants::DATE_FORMAT);
    }

+19 −0
Changes for module/Application/src/Application/Service/Role/RoleService.php: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -250,4 +250,23 @@ class RoleService extends BaseService
        }
    }

    public function addRole($individuId, $roleId)
    {
        $individu = $this->getEntityManager()->getRepository(Individu::class)->findOneBy(["id"=>$individuId]);
        $role = $this->getEntityManager()->getRepository(Role::class)->findOneBy(["id"=>$roleId]);

        $ir = new IndividuRole();
        $ir->setIndividu($individu);
        $ir->setRole($role);

        $this->getEntityManager()->persist($ir);
        $this->getEntityManager()->flush($ir);
    }

    public function getRoles()
    {
        $result = $this->getEntityManager()->getRepository(Role::class)->findAll();
        return $result;
    }

}
 No newline at end of file
Loading