Commit 4ae32dea authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

(DONE) Réduire le panel '''Attribution des rôles suivants '''

parent 510da366
Loading
Loading
Loading
Loading
Loading
+1 −10
Changes for module/Application/src/Application/Controller/UtilisateurController.php: 1 added line, 10 removed lines.
Original line number Diff line number Diff line
@@ -100,16 +100,7 @@ class UtilisateurController extends \UnicaenAuth\Controller\UtilisateurControlle
            ->setItemCountPerPage((int)$maxi)
            ->setCurrentPageNumber((int)$page);

        $qb = $this->roleService->getRepository()->createQueryBuilder('r');
        $qb ->join('r.source', 's', Join::WITH, 's.importable = 0')
            ->andWhere('r.attributionAutomatique = 0')
            ->andWhere($qb->expr()->notIn('r.roleId', [
                Role::ROLE_ID_ECOLE_DOCT,
                Role::ROLE_ID_UNITE_RECH,
            ]))
            ->andWhere('1 = pasHistorise(r)')
            ->orderBy('r.roleId');
        $rolesStatiques = $qb->getQuery()->getResult();
        $rolesStatiques = $this->roleService->getRoleModeleByStructures();

        $qb = $this->roleService->getRepository()->createQueryBuilder('r')
            ->andWhere('r.attributionAutomatique = 1')
+14 −0
Changes for module/Application/src/Application/Service/Role/RoleService.php: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ use Application\Entity\Db\Utilisateur;
use Application\Service\BaseService;
use Application\Entity\Db\Structure;
use Doctrine\ORM\Query\Expr\Join;
use MongoDB\BSON\Type;
use UnicaenImport\Entity\Db\Source;
use ZfcUser\Entity\UserInterface;

@@ -120,6 +121,19 @@ class RoleService extends BaseService
        return $roles;
    }

    public function getRoleModeleByStructures() {
        $roleModele = [];
        $structures = $this->entityManager->getRepository(TypeStructure::class)->findAll();

        /** @var TypeStructure $structure */
        foreach ($structures as $structure) {
            $roles = $this->getRoleModeleByStructureType($structure->getId());
            $roleModele[$structure->getLibelle()] = $roles;
        }

        return $roleModele;
    }

    /**
     * @param UniteRecherche|EcoleDoctorale|Etablissement $structure
     * @throws \Doctrine\ORM\OptimisticLockException
+19 −6
Changes for module/Application/view/application/utilisateur/index.phtml: 19 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -32,12 +32,25 @@ $select = (new Select("roles"))

<div class="alert alert-info alert-md">
    <span class="glyphicon glyphicon-info-sign"></span>
    <?php echo $this->translate("Sur cette page vous pouvez attribuer les rôles suivants :"); ?>
    <ul>
    <?php foreach ($roles as $r): ?>
        <li><?php echo $this->translate($r->getRoleId()) ?></li>
    <?php endforeach ?>
    </ul>
    <?php echo $this->translate("Sur cette page vous pouvez attribuer les rôles dépendant de structures."); ?>

    <ol>
    <?php foreach($roles as $structure => $roleModeles){
        echo "<li>" .$structure ."</li>";
        echo "<ul>";
       foreach ($roleModeles as $roleModele) {
           echo "<li>".$roleModele->getLibelle() . "</li>";
       }
       echo "</ul>";
    }
    ?>
    </ol>

<!--    <ul>-->
<!--    --><?php //foreach ($roles as $r): ?>
<!--        <li>--><?php //echo $this->translate($r->getRoleId()) ?><!--</li>-->
<!--    --><?php //endforeach ?>
<!--    </ul>-->
</div>

<div class="row">