From ec5685e5b9b939ff09871230b34fe8a8ce07c9a9 Mon Sep 17 00:00:00 2001
From: Antony Le Courtes <antony.lecourtes@unicaen.fr>
Date: Thu, 13 Feb 2025 15:30:10 +0100
Subject: [PATCH] Correction assertion pour ne pas afficher le menu candidatur
 sur le menu de l'intervenant si on est sur une instance enseignement.

---
 .../src/Assertion/OffreEmploiAssertion.php    | 22 ++++++++++++++-----
 .../src/Controller/OffreEmploiController.php  |  6 ++++-
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/module/Mission/src/Assertion/OffreEmploiAssertion.php b/module/Mission/src/Assertion/OffreEmploiAssertion.php
index adb15fa92a..444a98cddf 100755
--- a/module/Mission/src/Assertion/OffreEmploiAssertion.php
+++ b/module/Mission/src/Assertion/OffreEmploiAssertion.php
@@ -38,11 +38,10 @@ class OffreEmploiAssertion extends AbstractAssertion implements EntityManagerAwa
     {
         switch ($page['route']) {
             case 'offre-emploi':
-                $query = 'SELECT id FROM offre_emploi WHERE histo_destruction IS NULL AND validation_id IS NOT NULL';
-                $conn  = $this->getEntityManager()->getConnection();
-
-                if (false === $conn->executeQuery($query)->fetchOne()) {
-                    // Aucune offre => pas de lien
+            case 'candidature':
+                //Si il n'y a pas d'offre d'emploi alors il ne peut pas y avoir des candidatures
+                if(!$this->canHaveCandidature())
+                {
                     return false;
                 }
 
@@ -138,6 +137,9 @@ class OffreEmploiAssertion extends AbstractAssertion implements EntityManagerAwa
                     return $assert;
                 }
                 break;
+            case 'candidature':
+                return $this->canHaveCandidature();
+                break;
         }
         return true;
     }
@@ -261,6 +263,16 @@ class OffreEmploiAssertion extends AbstractAssertion implements EntityManagerAwa
         ]);
     }
 
+    protected function canHaveCandidature()
+    {
+        $query = 'SELECT id FROM offre_emploi WHERE histo_destruction IS NULL AND validation_id IS NOT NULL';
+        $conn  = $this->getEntityManager()->getConnection();
+        if (false === $conn->executeQuery($query)->fetchOne()) {
+            return false;
+        }
+        return true;
+    }
+
 
 
     protected function assertCandidatureValider (Role $role, Candidature $candidature)
diff --git a/module/Mission/src/Controller/OffreEmploiController.php b/module/Mission/src/Controller/OffreEmploiController.php
index f7d7b3b3af..a6ea621140 100755
--- a/module/Mission/src/Controller/OffreEmploiController.php
+++ b/module/Mission/src/Controller/OffreEmploiController.php
@@ -319,10 +319,14 @@ class  OffreEmploiController extends AbstractController
          * @var WorkflowEtape $etapeDonneesPersos
          */
         $intervenant                   = $this->getEvent()->getParam('intervenant');
+        $renseignerDonneesPersonnelles = false;
         $canValiderCandidature         = $this->isAllowed($intervenant, Privileges::MISSION_CANDIDATURE_VALIDER);
         $canRefuserCandidature         = $this->isAllowed($intervenant, Privileges::MISSION_CANDIDATURE_REFUSER);
         $etapeDonneesPersos            = $this->getServiceWorkflow()->getEtape(WfEtape::CODE_DONNEES_PERSO_SAISIE, $intervenant);
-        $renseignerDonneesPersonnelles = ($etapeDonneesPersos->getFranchie() == 1) ? false : true;
+        if(!empty($etapeDonneesPersos))
+        {
+            $renseignerDonneesPersonnelles = ($etapeDonneesPersos->getFranchie() == 1) ? false : true;
+        }
 
         if (!$intervenant) {
             throw new \LogicException('Intervenant introuvable');
-- 
GitLab