Commit b60b18ec authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Tâche #25962

Corriger le bug de choix de composante dans la liste des rôles
parent 8289f56a
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
<?php

namespace Application;

return [
    'console' => [
        'router' => [
@@ -29,11 +27,11 @@ return [
    ],

    'controllers'        => [
        'factory' => [
            'UnicaenAuth\Controller\Utilisateur' => Controller\Factory\UtilisateurControllerFactory::class,
        'factories' => [
            'UnicaenAuth\Controller\Utilisateur' => Application\Controller\Factory\UtilisateurControllerFactory::class,
        ],
        'invokables' => [
            'Application\Controller\Utilisateur' => Controller\UtilisateurController::class,
            'Application\Controller\Utilisateur' => Application\Controller\UtilisateurController::class,
        ],
    ],
];
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
<?php

namespace Application\Controller;
namespace Application\Controller\Factory;

use Application\Controller\UtilisateurController;
use Interop\Container\ContainerInterface;
use UnicaenApp\Mapper\Ldap\People as LdapPeopleMapper;
use UnicaenAuth\Options\ModuleOptions;
+8 −7
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface

        $intervenant = $this->getServiceContext()->getIntervenant();
        $utilisateur = $this->getServiceContext()->getUtilisateur();
        $structure   = $this->getServiceContext()->getStructure(false);

        // chargement des rôles métiers

@@ -144,8 +145,8 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface
            $role->setPerimetre($dbRole->getPerimetre());

            // Si le rôle est de périmètre établissement, alors il se peut que l'on veuille zoomer sur une composante en particulier...
            if ($this->structureSelectionnee && $dbRole->getPerimetre()->isEtablissement()) {
                $role->setStructure($this->structureSelectionnee);
            if ($dbRole->getPerimetre()->isEtablissement() && $structure) {
                $role->setStructure($structure);
            }

            $roles[$roleId] = $role;
@@ -153,17 +154,17 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface
            $affectations = $dbRole->getAffectation();
            foreach ($affectations as $affectation) {
                /* @var $affectation Affectation */
                if ($structure = $affectation->getStructure()) {
                    $affRoleId = $roleId . '-' . $structure->getSourceCode();
                if ($affStructure = $affectation->getStructure()) {
                    $affRoleId = $roleId . '-' . $affStructure->getSourceCode();
                    if (!isset($roles[$affRoleId]) && $dbRole->estNonHistorise()) {
                        $affRoleLibelle = $dbRole->getLibelle() . ' (' . $structure->getLibelleCourt() . ')';
                        $affRoleLibelle = $dbRole->getLibelle() . ' (' . $affStructure->getLibelleCourt() . ')';
                        $affRole        = new \Application\Acl\Role($affRoleId, $roleId, $affRoleLibelle);
                        if (isset($rolesPrivileges[$roleId])) {
                            $affRole->initPrivileges($rolesPrivileges[$roleId]);
                        }
                        $affRole->setDbRole($dbRole);
                        $affRole->setPerimetre($dbRole->getPerimetre());
                        $affRole->setStructure($structure);
                        $affRole->setStructure($affStructure);
                        $roles[$affRoleId] = $affRole;
                    }
                }
+1 −2
Original line number Diff line number Diff line
@@ -38,8 +38,7 @@ class RoleProviderFactory
            ->setEntityManager($em)
            ->setServiceStatutIntervenant($container->get(StatutIntervenantService::class))
            ->setServiceContext($container->get(ContextService::class))
            ->setPrivilegeProvider($container->get('UnicaenAuth\Privilege\PrivilegeProvider'))
            ->setStructureSelectionnee($this->getServiceContext()->getStructure(true));
            ->setPrivilegeProvider($container->get('UnicaenAuth\Privilege\PrivilegeProvider'));

        return $roleProvider;
    }
+13 −15
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ class ContextService extends AbstractService

    /**
     *
     * @return RoleService
     * @return Role
     */
    public function getSelectedIdentityRole()
    {
@@ -398,23 +398,21 @@ class ContextService extends AbstractService
     *
     * @return Structure
     */
    public function getStructure($initializing = false)
    public function getStructure($checkInRole = true)
    {
        if (!$this->structure) {
            $sc = $this->getSessionContainer();
            if (!$sc->offsetExists('structure')) {
                if ($initializing) {
                    $sc->structure = null;
                } else {
        if ($checkInRole) {
            $role = $this->getSelectedIdentityRole();
            if ($role && $role->getStructure()) {
                        $sc->structure = $role->getStructure()->getId();
                    } else {
                        $sc->structure = null;
                return $role->getStructure();
            }
        }

        if (!$this->structure) {
            $sc          = $this->getSessionContainer();
            $structureId = $sc->structure;
            if ($structureId) {
                $this->structure = $this->getServiceStructure()->get($structureId);
            }
            $this->structure = $this->getServiceStructure()->get($sc->structure);
        }

        return $this->structure;
Loading