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

Afficher les rôles automatiques sur la page de listing des utilisateurs

parent e630e539
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenApp\View\Model\CsvModel;
use UnicaenPrivilege\Service\Perimetre\PerimetreServiceAwareTrait;
use UnicaenUtilisateur\Entity\Db\RoleInterface;
use UnicaenUtilisateur\Entity\Db\UserInterface;
use UnicaenUtilisateur\Exception\RuntimeException;
use UnicaenUtilisateur\Form\User\PasswordEnregistrementFormAwareTrait;
use UnicaenUtilisateur\Form\User\PasswordRecuperationFormAwareTrait;
@@ -358,11 +359,17 @@ class UtilisateurController extends AbstractActionController

    public function listerAction()
    {
        /** @var UserInterface[] $users */
        $users = $this->userService->findAll();

        foreach ($users as $user) {
            $roles[$user->getId()] = $this->identityService->getUserRoles($user);
        }

        return new ViewModel([
            'title' => "Liste des utilisateurs",
            'users' => $users,
            'roles' => $roles,
        ]);
    }

+9 −4
Original line number Diff line number Diff line
<?php

use UnicaenUtilisateur\Entity\Db\RoleInterface;
use UnicaenUtilisateur\Entity\Db\UserInterface;

/**
 * @var UserInterface[] $users
 * @var string $title
 * @var UserInterface[] $users
 * @var RoleInterface[] $roles
 */
?>

@@ -42,7 +44,7 @@ use UnicaenUtilisateur\Entity\Db\UserInterface;
                <th>Nom</th>
                <th>Email</th>
                <th>Statut</th>
                <th>Rôle (non automatique)</th>
                <th>Rôles</th>
            </tr>
        </thead>
        <tbody>
@@ -64,8 +66,11 @@ use UnicaenUtilisateur\Entity\Db\UserInterface;
                    </td>
                    <td>
                        <ul class="list-unstyled">
                            <?php foreach ($user->getRoles() as $role) : ?>
                                <li> <?php echo $role->getLibelle(); ?></li>
                            <?php foreach ($roles[$user->getId()] as $role) : ?>
                                <li>
                                    <?php echo $role->getLibelle(); ?>
                                    <?php echo $role->isAuto() ? '<i title="Rôle automatique" class="fas fa-user-cog"></i>' : ''; ?>
                                </li>
                            <?php endforeach; ?>
                        </ul>
                    </td>