Commit 44d8c2b4 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Ajout recherche par role + nouveau privilege

parent bf700487
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@ return [
                    'controller' => UtilisateurController::class,
                    'action' => [
                        'index',
                        'rechercher',
                        'lister',
                        'exporter'
                    ],
@@ -87,6 +86,16 @@ return [
                        UtilisateurPrivileges::UTILISATEUR_MODIFIERROLE,
                    ],
                ],
                [
                    'controller' => UtilisateurController::class,
                    'action' => [
                        'rechercher',
                        'rechercher-with-role',
                    ],
                    'privileges' => [
                        UtilisateurPrivileges::UTILISATEUR_RECHERCHER,
                    ],
                ],
            ],
        ],
    ],
@@ -154,6 +163,16 @@ return [
                            ],
                        ],
                    ],
                    'rechercher-with-role' => [
                        'type'          => Segment::class,
                        'options'       => [
                            'route'       => '/rechercher-with-role[/:role]',
                            'defaults'    => [
                                'controller' => UtilisateurController::class,
                                'action' => 'rechercher-with-role',
                            ],
                        ],
                    ],
                    'add-role' => [
                        'type'          => Segment::class,
                        'options'       => [
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ WITH d(code, lib, ordre) AS (
    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
    SELECT 'utilisateur_rechercher', 'Recherche d''un utilisateur', 10
)
INSERT INTO unicaen_privilege_privilege(CATEGORIE_ID, CODE, LIBELLE, ORDRE)
SELECT cp.id, d.code, d.lib, d.ordre
+23 −0
Original line number Diff line number Diff line
@@ -299,6 +299,29 @@ class UtilisateurController extends AbstractActionController
        return new JsonModel($result);
    }

    public function rechercherWithRoleAction() : JsonModel
    {
        $term = $this->params()->fromQuery('term');
        $roleCode = $this->params()->fromRoute('role');

        //recherche en interne seulement//
        $users = $this->getUserService()->getUtilisateursByTermAndRoleId($term, $roleCode);

        $result = [];
        foreach ($users as $user) {
            $result[] = [
                'id' => 'app' . '||' . $user->getId(),
                'label' => $user->getDisplayName(),
                'extra' => sprintf(' <span class="text-highlight">/</span> %s <span class="text-highlight">/</span> %s %s',
                    $user->getUsername($this->usernamefield),
                    $user->getEmail() ?: "aucun email",
                    '<i title="Utilisateur existant" class="fas fa-check-circle text-success"></i>')
            ];
        }
        usort($result, function ($a, $b) { return $a['label'] > $b['label']; });
        return new JsonModel($result);
    }

    public function listerAction() : ViewModel
    {
        $users = $this->userService->findAll();
+5 −0
Original line number Diff line number Diff line
@@ -280,4 +280,9 @@ trait HistoriqueAwareTrait
        }
        return "Aucune donnée d'historisation";
    }

    public function getDate(): string
    {
        return $this->getHistoCreation()->format('d/m/Y à H:i');
    }
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ class HistoriqueListener implements EventSubscriber
     * @param LifecycleEventArgs $args
     * @throws RuntimeException Aucun utilisateur disponible pour en faire l'auteur de la création/modification
     */
    protected function updateHistorique(LifecycleEventArgs $args)
    protected function updateHistorique(LifecycleEventArgs $args): void
    {
        $entity = $args->getEntity();

Loading