Commit 6f3eb0c3 authored by David Surville's avatar David Surville
Browse files

Quelques corrections nécessaires après l'intégration de la branche...

Quelques corrections nécessaires après l'intégration de la branche release/1.3.0 dans la branche 5.x
parent 46008c2e
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -352,6 +352,13 @@ return [
        ],
    ],

    'hydrators' => [
        'factories' => [
            UserHydrator::class => UserHydratorFactory::class,
        ]
    ],


    'view_helpers' => [
        'aliases' => [
            'userRole' => UserRole::class,

data/sql/data.sql

deleted100644 → 0
+0 −42
Original line number Diff line number Diff line
INSERT INTO UNICAEN_PRIVILEGE_CATEGORIE (
    CODE,
    LIBELLE,
    NAMESPACE,
    ORDRE)
values
    ('utilisateur', 'Gestion des utilisateurs', 'UnicaenUtilisateur\Provider\Privilege' 1),
    ('role', 'Gestion des rôles', 'UnicaenUtilisateur\Provider\Privilege', 1),
    ON CONFLICT (CODE) DO
UPDATE SET
    LIBELLE=excluded.LIBELLE,
    NAMESPACE=excluded.NAMESPACE,
    ORDRE=excluded.ORDRE;

WITH d(code, lib, ordre) AS (
    SELECT 'utilisateur_afficher', 'Consulter un utilisateur', 1 UNION
    SELECT 'utilisateur_ajouter', 'Ajouter un utilisateur', 2 UNION
    SELECT 'utilisateur_changerstatus', 'Changer le statut d''un utilisateur', 3 UNION
    SELECT 'utilisateur_modifierrole', 'Modifier les rôles attribués à un utilisateur', 4
)
INSERT INTO unicaen_privilege_privilege(CATEGORIE_ID, CODE, LIBELLE, ORDRE)
SELECT cp.id, d.code, d.lib, d.ordre
FROM d
         JOIN unicaen_privilege_categorie cp ON cp.CODE = 'utilisateur'
    ON CONFLICT (CATEGORIE_ID, CODE) DO
UPDATE SET
    LIBELLE=excluded.LIBELLE,
    ORDRE=excluded.ORDRE;

WITH d(code, lib, ordre) AS (
    SELECT 'role_afficher', 'Consulter les rôles', 1 UNION
    SELECT 'role_modifier', 'Modifier un rôle', 2 UNION
    SELECT 'role_effacer', 'Supprimer un rôle', 3
)
INSERT INTO unicaen_privilege_privilege(CATEGORIE_ID, CODE, LIBELLE, ORDRE)
SELECT cp.id, d.code, d.lib, d.ordre
FROM d
         JOIN unicaen_privilege_categorie cp ON cp.CODE = 'role'
    ON CONFLICT (CATEGORIE_ID, CODE) DO
UPDATE SET
    LIBELLE=excluded.LIBELLE,
    ORDRE=excluded.ORDRE;
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
<?php

namespace UnicaenUtilisateur\Acl;

use BjyAuthorize\Acl\Role;
use Laminas\Permissions\Acl\Role\RoleInterface;

/**
@@ -72,6 +74,7 @@ class NamedRole extends Role
    public function setRoleName(string $roleName) : NamedRole
    {
        $this->roleName = $roleName;

        return $this;
    }

@@ -94,6 +97,7 @@ class NamedRole extends Role
    public function setRoleDescription(?string $roleDescription) : NamedRole
    {
        $this->roleDescription = $roleDescription;

        return $this;
    }
    
@@ -120,6 +124,7 @@ class NamedRole extends Role
    public function setSelectable(bool $selectable = true) : NamedRole
    {
        $this->selectable = $selectable;

        return $this;
    }
}
 No newline at end of file
+12 −24
Original line number Diff line number Diff line
@@ -31,13 +31,13 @@ class RoleController extends AbstractActionController
        $roles = $this->roleService->findAll();
        $roleUsers = [];

        $ip = $this->identityProviders;
        foreach($roles as $role) {
            $roleUsers[$role->getRoleId()] = $this->identityService->getRoleUsers($role);
        }

        $title = "Gestion des rôles";
        return compact('title', 'roles', 'roleUsers');

        return new ViewModel([
            'title' => "Gestion des rôles",
            'roles' => $roles,
            'identityproviders' => $this->identityProviders,
        ]);
    }

    public function exporterAction() : CsvModel
@@ -45,23 +45,10 @@ class RoleController extends AbstractActionController
        $role = $this->roleService->getRequestedRole($this);

        /** @var UserInterface[] $users */
        $users = [];
        if (!$role->isAuto()) {
            $users = $role->getUsers()->toArray();
        $users = $this->identityService->getRoleUsers($role);
        usort($users, function (UserInterface $a, UserInterface $b) {
            return $a->getDisplayName() > $b->getDisplayName();
        });
        } else {
            if ($this->identityProviders !== null) {
                foreach ($this->identityProviders as $identityProvider) {
                    if (method_exists($identityProvider, "computeUsersAutomatiques")) {
                        $users = array_merge($users, $identityProvider->computeUsersAutomatiques($role->getRoleId()));
                    }
                }
            }
        }


        $headers = [ 'Identifiant de connexion', 'Nom', 'Adresse email'];

        $records = [];
@@ -145,7 +132,6 @@ class RoleController extends AbstractActionController

    public function supprimerAction()
    {
        $role = null;
        try {
            $role = $this->roleService->getRequestedRole($this);
            $this->roleService->delete($role);
@@ -153,5 +139,7 @@ class RoleController extends AbstractActionController
        } catch (RuntimeException $e) {
            $this->flashMessenger()->addErrorMessage(sprintf("Une erreur est survenu lors de la suppression du rôle <strong>%s</strong>.", $role->getLibelle()));
        }

        exit;
    }
}
 No newline at end of file
+8 −3
Original line number Diff line number Diff line
@@ -2,14 +2,19 @@

namespace UnicaenUtilisateur\Controller;

use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenUtilisateur\Form\Role\RoleForm;
use UnicaenUtilisateur\Provider\Identity\IdentityService;
use UnicaenUtilisateur\Service\Role\RoleService;

class RoleControllerFactory {

class RoleControllerFactory implements FactoryInterface
{
    /**
     * Create controller
     *
     * @param ContainerInterface $container
     * @param string $requestedName
     * @param array|null $options
@@ -17,7 +22,7 @@ class RoleControllerFactory {
     * @throws ContainerExceptionInterface
     * @throws NotFoundExceptionInterface
     */
    public function __invoke(ContainerInterface $container, string $requestedName, array $options = null)
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null)
    {
        /**
         * @var IdentityService $identityService
Loading