Commit 85a0e08c authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Fix : La partie du menu consacrée au compte est de retour

On peut de nouveau se déconnecter (retour du l'option "se déconnecter")
Les rôles applicatifs sont affichés dans le menu associé au compte
Les comptes sans personnes associées ont un message le signifiant dans le menu compte
parent 36e88657
Loading
Loading
Loading
Loading
Loading
+1 −1
Changes for module/Oscar/src/Oscar/Service/OscarUserContext.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -309,7 +309,7 @@ class OscarUserContext implements UseOscarConfigurationService, UseLoggerService
    {
        $query = $this->getAuthentificationRepository()
            ->createQueryBuilder('a')
            ->select('a.id', 'a.username', 'a.email', 'a.dateLogin', "a.displayName", "p.id as IDPERSON")
            ->select('a.id', 'a.username', 'a.email', 'a.dateLogin', "a.displayName", 'a.state', "p.id as IDPERSON")
            ->leftJoin(Person::class, 'p', 'WITH', 'p.ladapLogin = a.username');

        $sort = "a." . $options['sort'];
+17 −0
Changes for module/Oscar/src/Oscar/View/Helpers/Grant.php: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,6 +24,11 @@ class Grant extends AbstractHtmlElement implements UseOscarUserContextService
        return $this->getOscarUserContextService()->getCurrentPerson() !== null;
    }

    public function authenticated()
    {
        return $this->getOscarUserContextService()->getUserContext()->getIdentity() !== null;
    }

    public function isBoss(){
        return $this->getOscarUserContextService()->isBoss();
    }
@@ -144,4 +149,16 @@ class Grant extends AbstractHtmlElement implements UseOscarUserContextService
    public function getCurrentPerson(){
        return $this->getOscarUserContextService()->getCurrentPerson();
    }

    public function getIdentity(){
        $identity = $this->getCurrentPerson();
        if( !$identity ){
            $identity = $this->getOscarUserContextService()->getUserContext()->getIdentityUsername();
        }
        return $identity;
    }

    public function getCurrentUserRoles(){
        return $this->getOscarUserContextService()->getUserContext()->getIdentityRoles();
    }
}
+47 −8
Changes for module/Oscar/view/layout/layout.phtml: 47 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -426,19 +426,58 @@ echo getenv('APPLICATION_ENV') ?: 'development' ?>">

            </ul>
            <ul class="navbar-nav navbar-right">
                <?php
                if ($this->grant()->connected()): ?>
                <?php if ($this->grant()->authenticated()): ?>
                    <?php if ($this->grant()->connected()): ?>
                    <li>
                        <p class="navbar-text navbar-right" id="notifications-area">
                            Notifications
                        </p>
                    </li>
                    <?php endif; ?>
                <p class="navbar-text">
                    <a href="<?= $this->url('user_parameters') ?>">
                        <i class="icon-cog"></i></a> |
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown"
                           aria-expanded="false">
                            <?= $this->grant()->getIdentity() ?>
                        </a>
                        <ul class="dropdown-menu dropdown-menu-lg-end" role="menu">
                            <li role="presentation" class="dropdown-header">
                                <strong>
                                    <i class="icon-user"></i>
                                    <?= $this->grant()->getIdentity() ?>
                                </strong>
                                <?php foreach ($this->grant()->getCurrentUserRoles() as $role): ?>
                                <br> - <?= $role ?>
                                <?php endforeach; ?>
                                <?php if (!$this->grant()->getCurrentPerson()): ?>
                                <div class="text-danger">
                                <i class="icon-attention-1"></i> Votre compte n'est associé à <strong>aucune personne</strong>
                                </div>
                                <?php endif; ?>
                            </li>
                            <li>
                                <a class="dropdown-item" href="<?= $this->url('user_parameters') ?>">
                                    <?= $this->translate("Paramètres") ?>
                                </a>
                            </li>
                            <li>
                                <hr class="dropdown-divider">
                            </li>
                            <li>
                                <a class="dropdown-item" href="<?= $this->url('zfcuser/logout') ?>">
                                    <?= $this->translate("Se déconnecter") ?>
                                </a>
                            </li>
                        </ul>
                    </li>

                    <?php
                    echo $this->appConnection(); ?>
                </p>
                <?php else: ?>
                    <li>
                        <a class="btn btn-success" href="<?= $this->url('zfcuser/login') ?>">
                            <i class="icon-login"></i>
                            <?= $this->oscarText("Se connecter") ?>
                        </a>
                    </li>
                <?php endif;  ?>
            </ul>
        </div>
    </div>