Commit b24c1b0c authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier Committed by David Surville
Browse files

Fixing role auto

parent d73c1a3a
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -31,12 +31,13 @@ class RoleController extends AbstractActionController
        $roles = $this->roleService->findAll();
        $roleUsers = [];

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

        $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
+20 −46
Original line number Diff line number Diff line
@@ -48,38 +48,6 @@ $this->headTitle("Rôles");

    <table id="role-liste" class="table table-hover">
        <thead>
            <tr>
                <th>Rôle</th>
                <th>Rôle parent</th>
                <th>Utilisateurs</th>
                <th>Périmètres associés</th>
                <th class="col-md-1"><i title="Rôle manuel ou automatique" class="fas fa-user-cog"></i></th>
                <th>Accès extérieur</th>
                <th>Filtre Ldap</th>
                <th class="col-md-1">Action</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($roles as $role): ?>
                <?php
                    $users = $roleUsers[$role->getRoleId()];
                    $users = array_filter(
                        array_map(function ($u) {
                            /** @var UserInterface $u */
                            if($u instanceof UserInterface) {
                                return sprintf('%s ~ %s', $u->getDisplayName(), $u->getUsername());
                            }
                        }, $users)
                    );
                    sort($users);

                    $perimetres = $role->getPerimetreCategories()->toArray();
                    $perimetres = array_map(function ($p) {
                        /** @var $p PerimetreCategorieInterface */
                        return $p->getLibelle();
                    }, $perimetres);
                    sort($perimetres);
                ?>
            <tr>
                <td>
                    <?php echo $role->getLibelle(); ?>
@@ -91,10 +59,16 @@ $this->headTitle("Rôles");
                </td>
                <td>
                    <?php if ($role->isAuto()) : ?>
                            <?php if (!empty($users)) : ?>
                                <a href="#" data-toggle="popover" data-placement="left" data-html="true" data-content="<?php echo implode("<br />", $users); ?>">
                                    <i class="fas fa-user"></i> <?php echo count($users); ?>
                                </a>
                        <?php if ($identityproviders !== null) : ?>
                            <?php
                                $result = [];
                                foreach ($identityproviders as $identityprovider) {
                                    $computed = $identityprovider->computeUsersAutomatiques($role->getRoleId());
                                    if ($computed !== null) $result = array_merge($result, $computed);
                                }
                            ?>
                            <?php if($result): ?>
                                <i class="fas fa-user"></i> <?php echo count($result); ?>
                            <?php else: ?>
                                <span class="text-warning"><i class="fas fa-exclamation-triangle"></i> Aucun utilisateur associé à ce rôle automatique.</span>
                            <?php endif; ?>