diff --git a/config/routes.yaml b/config/routes.yaml index ef2fbcc91505cbd7cc9d1b1e78e9716ec146c6ae..a48601c8979f1fc68f1630451aa271224980b1b3 100755 --- a/config/routes.yaml +++ b/config/routes.yaml @@ -87,6 +87,12 @@ gogo_element_send_mail: requirements: methods: POST +gogo_element_send_edit_link: + path: /interact/sendEditLink/{elementId} + defaults: { _controller: App\Controller\ElementInteractionController::sendEditLinkAction } + requirements: + methods: GET + gogo_element_stamp: path: /interact/stamp defaults: { _controller: App\Controller\ElementInteractionController::stampAction } diff --git a/src/Controller/ElementInteractionController.php b/src/Controller/ElementInteractionController.php index be21b280ddbc79ff12b668097c935de9152f3ef3..a8a5b0348b38d9b6e73f0a12e39907111ab6713d 100755 --- a/src/Controller/ElementInteractionController.php +++ b/src/Controller/ElementInteractionController.php @@ -137,16 +137,29 @@ class ElementInteractionController extends Controller $senderMail = $request->get('userEmail'); // TODO make it configurable - $mailSubject = $t->trans('action.element.sendMail.mailSubject', ['%instance%' => $this->getParameter('instance_name')]); - $mailContent = $t->trans('action.element.sendMail.mailContent', ['%element%' => $element->getName(), + $emailSubject = $t->trans('action.element.sendMail.emailSubject', ['%instance%' => $this->getParameter('instance_name')]); + $emailContent = $t->trans('action.element.sendMail.emailContent', ['%element%' => $element->getName(), '%sender%' => $senderMail, '%subject%' => $request->get('subject'), '%content%' => $request->get('content') ]); - $mailService->sendMail($element->getEmail(), $mailSubject, $mailContent); + $mailService->sendMail($element->getEmail(), $emailSubject, $emailContent); return $this->returnResponse(true, $t->trans('action.element.sendMail.done')); } + public function sendEditLinkAction($elementId, DocumentManager $dm, MailService $mailService, TranslatorInterface $t) + { + $element = $dm->get('Element')->find($elementId); + $emailSubject = $t->trans('action.element.sendMail.emailSubject', ['%instance%' => $this->getParameter('instance_name')]); + $emailContent = $t->trans('action.element.sendEditLink.emailContent'); + $emailContent = $mailService->replaceMailsVariables($emailContent, $element, '', 'edit-link', null); + + $mailService->sendMail($element->getEmail(), $emailSubject, $emailContent); + + $this->addFlash('success', $t->trans('action.element.sendEditLink.done', ['%email%' => $element->getEmail()])); + return $this->redirectToRoute('gogo_homepage'); + } + public function stampAction(Request $request, DocumentManager $dm, TranslatorInterface $t) { // CHECK REQUEST IS VALID diff --git a/src/Services/MailService.php b/src/Services/MailService.php index 16aeebf9ec015cce5fb1b5bd6bd5e1fb33c16993..4ccdf93c88b49fba3dc221be5ad037473ac3b578 100755 --- a/src/Services/MailService.php +++ b/src/Services/MailService.php @@ -161,7 +161,7 @@ class MailService return $mailConfig; } - private function replaceMailsVariables($string, $element = null, $customMessage, $mailType, $option) + public function replaceMailsVariables($string, $element = null, $customMessage, $mailType, $option) { if (null !== $element && $element) { if ($element instanceof Element) { diff --git a/templates/element-form/form.html.twig b/templates/element-form/form.html.twig index edb3166560535669dc528da9a78e1664c15d8166..205b583335914041633679b513314d55b51a9d41 100755 --- a/templates/element-form/form.html.twig +++ b/templates/element-form/form.html.twig @@ -1,6 +1,7 @@ {{ form_start(form, {'id': 'formElement'}) }} -<div id="element-form-content" class="{{ editMode ? 'edit' : 'new' }} {{ isOwner ? 'by-owner' : ''}} {{ isAllowedDirectModeration ? 'by-admin' : '' }}"> +<div id="element-form-content" class="{{ editMode ? 'edit' : 'new' }} {{ isOwner ? 'by-owner' : ''}} {{ isAllowedDirectModeration ? 'by-admin' : '' }}" + data-element-id="{{ element.id }}"> <section> {% include "element-form/form-renderer.html.twig" %} </section> diff --git a/translations/messages+intl-icu.fr.yaml b/translations/messages+intl-icu.fr.yaml index 9375fb69ce24fb78059650994dc672ff9d40d21f..3038590b80746765fea9af81c02b8f4cfe1a3717 100755 --- a/translations/messages+intl-icu.fr.yaml +++ b/translations/messages+intl-icu.fr.yaml @@ -248,13 +248,18 @@ action: done: "L'élément a bien été modéré" sendMail: uncomplete: "Les paramètres sont incomplets" - mailSubject: 'Message reçu depuis la plateforme {instance}' - mailContent: '<p>Bonjour <i>{element}</i>,</p> + emailSubject: 'Message reçu depuis la plateforme {instance}' + emailContent: '<p>Bonjour <i>{element}</i>,</p> <p>Vous avez reçu un message de la part de <a href="mailto:{sender}">{sender}</a></br> </p> <p><b>Titre du message</b></p><p> {subject}</p> <p><b>Contenu</b></p><p>{content}</p>' done: "L'email a bien été envoyé" + sendEditLink: + emailContent: >- + <p>Bonjour <i>'{{ element '}}</i>,</p> + <p><a href="'{{ directEditElementUniqueUrl '}}">Cliquez ici</a> pour modifier votre fiche</p> + done: Un lien d'édition a bien été envoyé à {email} stamp: unallowed: "Vous n'êtes pas autorisé à utiliser cette étiquette" uncomplete: "Les paramètres sont incomplets"