Skip to content
Snippets Groups Projects
Select Git revision
  • b10b15e6e155b5a3af7f65e015bebf63f74b4562
  • master default
  • php8.2-docker-services
  • 6.x
  • laminas
  • bertrand.gauthier-master-patch-70311
  • bertrand.gauthier-master-patch-87168
  • laminas_migration
  • sqlite
  • 4.0.0
  • 3.2.1
  • 3.2.0
  • 3.1.0
  • 3.0.0
  • 1.0.1
  • 1.0.0
16 results

composer.lock

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    IndexController.php 2.88 KiB
    <?php
    
    namespace Application\Controller;
    
    use Application\Acl\Role;
    use Application\Provider\Privilege\Privileges;
    use Application\Service\Traits\AnneeServiceAwareTrait;
    use Application\Service\Traits\ContextServiceAwareTrait;
    use Application\Service\Traits\IntervenantServiceAwareTrait;
    use Application\Service\Traits\ParametresServiceAwareTrait;
    use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait;
    use Laminas\View\Model\ViewModel;
    
    /**
     *
     */
    class IndexController extends AbstractController
    {
        use ContextServiceAwareTrait;
        use AnneeServiceAwareTrait;
        use IntervenantServiceAwareTrait;
        use UserContextServiceAwareTrait;
        use ParametresServiceAwareTrait;
    
    
        /**
         *
         * @return type
         */
        public function indexAction()
        {
            $role = $this->serviceUserContext->getSelectedIdentityRole();
    
            $documentation = [
                'vacataires' => $this->getServiceParametres()->get('doc-intervenant-vacataires'),
                'permanents' => $this->getServiceParametres()->get('doc-intervenant-permanents'),
            ];
    
            $view = new ViewModel([
                'annee'                     => $this->getServiceContext()->getAnnee(),
                'documentation'             => $documentation,
                'context'                   => $this->getServiceContext(),
                'pageAccueil'               => $this->getServiceParametres()->get('page_accueil'),
                'connexionNonAutorise'      => $this->getServiceParametres()->get('connexion_non_autorise'),
                'connexionSansRoleNiStatut' => $this->getServiceParametres()->get('connexion_sans_role_ni_statut'),
            ]);
    
            if ($role && $this->isAllowed(Privileges::getResourceId(Privileges::INDICATEUR_VISUALISATION))) {
                // URL de la page affichant les indicateurs auxquels est abonné l'utilisateur
                $view->setVariable('abonnementsUrl', $this->url()->fromRoute('indicateur/abonnements'));
            }
    
            return $view;
        }
    
    
        public function changementAnneeAction()
        {
            /* Prise en compte du changement d'année!! */
            $annee = $this->params()->fromRoute('annee');
            if ($annee) {
                $annee = $this->getServiceAnnee()->get($annee);
                $this->getServiceContext()->setAnnee($annee);
    
                $role = $this->getServiceContext()->getSelectedIdentityRole();
                if ($role instanceof Role && $role->getIntervenant()) {
                    $intervenant = $this->getServiceIntervenant()->getByCode($role->getIntervenant()->getCode());
                    if ($intervenant) {
                        //Correction mauvais refresh du role lors du changement d'année
                        $this->serviceUserContext->setSelectedIdentityRole($intervenant->getStatut()->getRoleId());
                        //$this->serviceUserContext->setNextSelectedIdentityRole($intervenant->getStatut()->getRoleId());
                    }
                }
            }
    
            return [];
        }
    
    }