Loading module/Application/config/others/utilisateur.config.php +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 Loading @@ -28,6 +28,7 @@ return [ 'index', 'index-bis', 'retirer-role', 'ajouter-role', ], 'privileges' => UtilisateurPrivileges::UTILISATEUR_CONSULTATION, ], Loading Loading @@ -147,6 +148,15 @@ return [ ], ], ], 'ajouter-role' => [ 'type' => Segment::class, 'options' => [ 'route' => '/ajouter-role/:individu/:role', 'defaults' => [ 'action' => 'ajouter-role', ], ], ], ], ], Loading module/Application/src/Application/Controller/Factory/UtilisateurControllerFactory.php +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 Loading @@ -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; Loading @@ -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(); Loading @@ -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; Loading module/Application/src/Application/Controller/UtilisateurController.php +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 Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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, ]); } Loading @@ -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 module/Application/src/Application/Entity/Db/Individu.php +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 Loading @@ -359,6 +359,7 @@ class Individu implements HistoriqueAwareInterface, SourceAwareInterface */ public function getDateNaissanceToString() { if ($this->dateNaissance === null) return ""; return $this->dateNaissance->format(Constants::DATE_FORMAT); } Loading module/Application/src/Application/Service/Role/RoleService.php +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 Loading @@ -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
module/Application/config/others/utilisateur.config.php +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 Loading @@ -28,6 +28,7 @@ return [ 'index', 'index-bis', 'retirer-role', 'ajouter-role', ], 'privileges' => UtilisateurPrivileges::UTILISATEUR_CONSULTATION, ], Loading Loading @@ -147,6 +148,15 @@ return [ ], ], ], 'ajouter-role' => [ 'type' => Segment::class, 'options' => [ 'route' => '/ajouter-role/:individu/:role', 'defaults' => [ 'action' => 'ajouter-role', ], ], ], ], ], Loading
module/Application/src/Application/Controller/Factory/UtilisateurControllerFactory.php +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 Loading @@ -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; Loading @@ -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(); Loading @@ -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; Loading
module/Application/src/Application/Controller/UtilisateurController.php +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 Loading @@ -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; Loading Loading @@ -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 Loading Loading @@ -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, ]); } Loading @@ -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
module/Application/src/Application/Entity/Db/Individu.php +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 Loading @@ -359,6 +359,7 @@ class Individu implements HistoriqueAwareInterface, SourceAwareInterface */ public function getDateNaissanceToString() { if ($this->dateNaissance === null) return ""; return $this->dateNaissance->format(Constants::DATE_FORMAT); } Loading
module/Application/src/Application/Service/Role/RoleService.php +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 Loading @@ -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