From ecfce10e3b2b210556f456e8fe0da0b9d70bd052 Mon Sep 17 00:00:00 2001 From: afornerot Date: Thu, 18 Mar 2021 16:18:24 +0100 Subject: [PATCH] ajustement sur le formulaire d'inscription (ref #220) --- .../CoreBundle/Controller/MailController.php | 2 +- .../Controller/RegistrationController.php | 2 +- .../CoreBundle/Controller/UserController.php | 2 +- .../Controller/WhitelistController.php | 19 +++++++++++ .../CoreBundle/Form/RegistrationType.php | 2 +- .../CoreBundle/Resources/config/routing.yml | 4 +++ .../views/Registration/edit.html.twig | 34 ++++++++++++++++++- 7 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php index d472bb2e..4935e014 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/MailController.php @@ -34,7 +34,7 @@ class MailController extends Controller // Sujet $url = $this->generateUrl('cadoles_core_registration',[], UrlGeneratorInterface::ABSOLUTE_URL)."?group=".$group->getId(); - $message = "Bonjour,

En tant que responsable du projet '".$group->getLabel()."', je vous ai invité à rejoindre cette communauté de travail

"; + $message = "Bonjour,

En tant que responsable du groupe '".$group->getLabel()."', je vous ai invité à rejoindre cette communauté de travail

"; $message.= "Merci de bien vouloir tout d’abord vous inscrire sur ".$this->get('session')->get('appname')." en suivant le lien suivant
"; $message.= "$url

"; $message.= "Une fois le processus d'inscription complété, vous serez automatiquement rattaché à notre groupe de travail

"; diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php index 3825d821..2418ca02 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/RegistrationController.php @@ -873,7 +873,7 @@ class RegistrationController extends Controller $niveau01=strtolower($data->getNiveau01()->getLabel()); if(stripos($niveau01,"autre")===0) { if(!$data->getNiveau01other()) { - $form->addError(new FormError("Merci d'indiquer votre ".$this->getParameter("labelniveau01"))); + $form->addError(new FormError("Merci de compléter le champ 'Autre ".$this->getParameter("labelniveau01")."'")); } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php index 9437e255..ede07371 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/UserController.php @@ -1483,7 +1483,7 @@ class UserController extends Controller $niveau01=strtolower($data->getNiveau01()->getLabel()); if(stripos($niveau01,"autre")===0) { if(!$data->getNiveau01other()) { - $form->addError(new FormError("Merci d'indiquer votre ".$this->getParameter("labelniveau01"))); + $form->addError(new FormError("Merci de compléter le champ 'Autre ".$this->getParameter("labelniveau01")."'")); } } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/WhitelistController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/WhitelistController.php index 01d4e715..a49466f9 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/WhitelistController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/WhitelistController.php @@ -207,6 +207,25 @@ class WhitelistController extends Controller ]); } + public function ajaxiswhitelistAction(Request $request) + { + // S'assurer que c'est un appel ajax + if (!$request->isXmlHttpRequest()) { + return new JsonResponse(array('message' => 'Interdit'), 400); + } + $email=$request->request->get('email'); + $email=explode("@",$email); + $domaine=end($email); + + // Rechercher le mail dans la liste blanche + $em = $this->getDoctrine()->getManager(); + $whitelist=$em->getRepository($this->labelentity)->findOneBy(["label"=>$domaine]); + if($whitelist) + return new Response("OK", 200); + else + return new Response("KO", 200); + } + protected function getDatas() { $em = $this->getDoctrine()->getManager(); diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php index f13517bb..ad8aead0 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Form/RegistrationType.php @@ -96,7 +96,7 @@ class RegistrationType extends AbstractType $builder->add('niveau01other', TextType::class, array( - "label" =>"Autre ".$session->get('labelniveau01'), + "label" =>"Autre ".$session->get('labelniveau01'). " *", "disabled" => ($options["mode"]=="delete"?true:false), "required" => false, "attr" => array("class" => "form-control", "style" => "margin-bottom:15px") diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml index 51f5576b..78a13514 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml @@ -194,6 +194,10 @@ cadoles_core_ajax_item_list: path: /ajax/item/list defaults: { _controller: CadolesCoreBundle:Ajax:itemlist } +cadoles_core_ajax_iswhitelist: + path: /ajax/iswhitelist + defaults: { _controller: CadolesCoreBundle:Whitelist:ajaxiswhitelist } + #== Home Config ========================================================================================================== cadoles_core_config: path: /config/home diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/edit.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/edit.html.twig index 636c666d..0e79038c 100755 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/edit.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/Registration/edit.html.twig @@ -107,7 +107,14 @@
{% if form.firstname is defined %} {{ form_row(form.firstname) }} {% endif %} {{ form_row(form.lastname) }} - {% if form.email is defined %} {{ form_row(form.email) }} {% endif %} + {% if form.email is defined %} + {{ form_row(form.email) }} + + {% endif %} {% if form.visible is defined %} {{ form_row(form.visible) }} {% endif %}
@@ -213,6 +220,29 @@ }); }); + $(document.body).on("focusout","#registration_email",function(){ + $.ajax({ + method: "POST", + url: "{{ path('cadoles_core_ajax_iswhitelist') }}", + data: { + email:$("#registration_email").val(), + }, + success: function(data) { + if(data=="KO") { + $("#registration_motivation").attr("required","required"); + $(".alert-email").show(); + $("label[for='registration_motivation']").text("Motivation *"); + } + else { + $("#registration_motivation").removeAttr("required"); + $(".alert-email").hide(); + $("label[for='registration_motivation']").text("Motivation"); + } + } + }); + + }); + function hideshow() { if($("#registration_birthcountry").val()==269) $("#blockcity").show(); @@ -224,10 +254,12 @@ niveau01=$("#registration_niveau01 option:selected").text().toLowerCase(); if(niveau01.startsWith("autre")) { $("#niveau01other").show(); + $("#registration_niveau01other").attr("required","required"); } else { $("#registration_niveau01other").val(""); $("#niveau01other").hide(); + $("#registration_niveau01other").removeAttr("required"); } }