Commit 0667e5b0 by Damien Moulard

Merge branch '9080-specific-registration-email' into 'develop'

specific adherent registration email for specific instance

See merge request !158
parents 3370e722 6b013113
......@@ -56,6 +56,7 @@ Copier le fichier .env.dist en .env et configurer :
- l'envoi de mail (MAILER_URL (penser à saisir MLC_NOTIF_EMAIL compatible avec le MAILER utilisé))
- la variable APP_SECRET (variable secrète que vous pouvez générer à partir de cette url : http://nux.net/secret
- s'il s'agit d'une instance TAV, mettre la variable TAV_ENV à 1 (sinon la laisser à zéro)
- en environnement TAV, TAV_INSTANCE indique l'instance spécifique (ex. montpellier, bordeaux...) pour les éléments de code nécessitant une configuration par instance (ex. mail d'inscription d'un.e adhérent.e par l'admin)
- en environnement TAV, pour activer le parcours d'inscription autonomisé qui intègre la réponse à une questionnaire d'auto-évaluation pour les points de vente, passer PRESTA_SELF_INIT_AND_EVAL à 1
- en environnement TAV, la variable AUTOMATISATION_RECONVERSION permet d'activer l'automatisation des reconversions
- en environnement TAV, la variable PRESTA_EXTRA_DATA permet d'indiquer puis d'afficher publiquement plus de données concernant les prestataires (e.g. familles de produits)
......
......@@ -13,6 +13,7 @@ parameters:
sonata.media.admin.media.class: 'App\Admin\MediaAdmin'
sonata.media.admin.gallery.class: 'App\Admin\GalleryAdmin'
tav_env: '%env(TAV_ENV)%'
tav_instance: '%env(TAV_INSTANCE)%'
presta_self_init_and_eval: '%env(PRESTA_SELF_INIT_AND_EVAL)%'
automatisation_reconversion: '%env(AUTOMATISATION_RECONVERSION)%'
presta_extra_data: '%env(PRESTA_EXTRA_DATA)%'
......
......@@ -77,6 +77,7 @@ class GlobalParameter
const GEOLOC_WITH_SUBTERRITORY = 'GEOLOC_WITH_SUBTERRITORY';
const COMPTOIR_PAYMENT_TYPES = 'COMPTOIR_PAYMENT_TYPES';
const SSA_ADH_EXTERNAL_DATA_COHORTES_LIST = 'SSA_ADH_EXTERNAL_DATA_COHORTES_LIST';
const SSA_REGISTRATION_QUIZZ_SENDER_EMAIL = 'SSA_REGISTRATION_QUIZZ_SENDER_EMAIL';
/**
* @var \Ramsey\Uuid\UuidInterface
......
......@@ -20,6 +20,7 @@ use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Csrf\TokenGenerator\TokenGeneratorInterface;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Twig\Environment;
/**
......@@ -35,9 +36,19 @@ class MLCEventListener implements EventSubscriberInterface
protected $router;
protected $userManager;
protected $tokenGenerator;
protected $container;
public function __construct(EntityManagerInterface $em, \Swift_Mailer $mailer, RouterInterface $router, ParameterBagInterface $params, Environment $templating, TranslatorInterface $translator, UserManagerInterface $userManager, TokenGeneratorInterface $tokenGenerator)
{
public function __construct(
EntityManagerInterface $em,
\Swift_Mailer $mailer,
RouterInterface $router,
ParameterBagInterface $params,
Environment $templating,
TranslatorInterface $translator,
UserManagerInterface $userManager,
TokenGeneratorInterface $tokenGenerator,
ContainerInterface $container
) {
$this->em = $em;
$this->mailer = $mailer;
$this->params = $params;
......@@ -46,6 +57,7 @@ class MLCEventListener implements EventSubscriberInterface
$this->router = $router;
$this->userManager = $userManager;
$this->tokenGenerator = $tokenGenerator;
$this->container = $container;
}
// public function setMailer(TwigSwiftMailer $maileri)
......@@ -126,12 +138,30 @@ class MLCEventListener implements EventSubscriberInterface
$this->userManager->updateUser($user);
$subject = $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NAME_SMALL) . ' : ' . $this->translator->trans('Création de votre compte');
// Define mail template to use
if (
$this->container->getParameter('tav_env')
&& $this->container->getParameter('tav_instance') == 'montpellier'
&& isset($params['type'])
&& $params['type'] == 'adherent'
) {
$template = '@kohinos/email/tav/admin_add_adherent_montpellier.html.twig';
$params = array_merge($params, [
'mlcSmallName' => $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NAME_SMALL),
'mlcUrl' => $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_URL),
'registrationQuizzSenderEmail' => $this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::SSA_REGISTRATION_QUIZZ_SENDER_EMAIL),
]);
} else {
$template = '@kohinos/email/admin_add_' . ((isset($params['type']) && in_array($params['type'], ['adherent', 'prestataire', 'caissier', 'user'])) ? $params['type'] : 'adherent') . '.html.twig';
}
$mail = (new \Swift_Message($subject))
->setFrom($this->em->getRepository(GlobalParameter::class)->val(GlobalParameter::MLC_NOTIF_EMAIL))
->setTo($user->getEmail())
->setBody(
$this->templating->render(
'@kohinos/email/admin_add_' . ((isset($params['type']) && in_array($params['type'], ['adherent', 'prestataire', 'caissier', 'user'])) ? $params['type'] : 'adherent') . '.html.twig',
$template,
array_merge($params, [
'subject' => $subject,
'user' => $user,
......
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260603082647 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql("INSERT INTO global_parameter (id, name, description, value, mandatory) VALUES (UUID(), 'SSA_REGISTRATION_QUIZZ_SENDER_EMAIL', 'Définit l\'adresse mail qui envoie un questionnaire recherche à remplir par les adhérent·e·s à l\'inscription. Requis pour le mail d\'inscription de certaines instances.', '', '0')");
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql("DELETE FROM global_parameter WHERE name='SSA_REGISTRATION_QUIZZ_SENDER_EMAIL'");
}
}
{% extends '@kohinos/email/email_layout.html.twig' %}
{% set title %}{% spaceless %}
{{ subject }}
{% endspaceless %}
{% endset %}
{% block content %}
<h2 style="font-size: 18px; color: #111111; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: bold; line-height: 1.2em; margin: 40px 0 10px;">{{ 'Valider la création de votre compte'|trans }} {{ mlcSmallName }}</h2><br/>
<p>
{{ 'Un administreur a crée votre nouveau compte'|trans }}
{{ mlcSmallName }}
{{ user.name|title }}
</p>
<p>
{{ 'Vous pouvez créer votre mot de passe de connexion en cliquant sur ce lien :'|trans }}<br/>
<a href='{{confirmationUrl}}'>{{confirmationUrl}}</a><br/>
{{ '(Pensez à mettre l’appli web en favori et à faire un raccourci de la page web' }}
<a href='{{mlcUrl}}'>{{mlcUrl}}</a><br/>
{{ 'sur l’écran d’accueil de votre téléphone)' }}
</p>
<p>
{{ 'Votre compte sera indiqué comme « Désactivé ». C’est normal il sera activé 24-48h après avoir répondu au questionnaire recherche nécessaire au début de l’expérimentation. ' }}
{% if registrationQuizzSenderEmail != '' %}
{{ 'Ce questionnaire est envoyé par' }}
{{ registrationQuizzSenderEmail }}
{{ ', si besoin vous pouvez lui adresser vos questions au sujet du questionnaire.' }}
{% endif %}
</p>
{% endblock %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment