Skip to content
Permalink
Browse files

Disable subject on messages. Update emails.

  • Loading branch information...
thisismeonmounteverest committed Mar 18, 2019
1 parent f993a84 commit 622ff25aed49bdf77f3464777fbbe0649f6d1bd1
@@ -201,6 +201,7 @@ public function newMessageAction(Request $request, Member $receiver)
$em = $this->getDoctrine()->getManager();
$em->persist($message);
$em->flush();
$success = $this->sendMessageNotification(
$sender,
@@ -214,7 +215,6 @@ public function newMessageAction(Request $request, Member $receiver)
} else {
$this->addFlash('notice', 'Message has been stored into the database. Mail notification couldn\'t be sent, though.');
}
$em->flush();
return $this->redirectToRoute('members_profile', ['username' => $receiver->getUsername()]);
}
@@ -868,13 +868,11 @@ private function sendMessageNotification(Member $sender, Member $receiver, Messa
// Send mail notification with the receiver's preferred locale
$this->setTranslatorLocale($receiver);
$subject = $message->getSubject()->getSubject();
$messageBody = $message->getMessage();
$body = $this->renderView('emails/message.html.twig', [
'sender' => $sender,
'receiver' => $receiver,
'message' => $message,
'subject' => $subject,
'body' => $messageBody,
]);
return $this->sendEmail($sender, $receiver, $subject, $body);
@@ -4,6 +4,8 @@
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\NotBlank;
@@ -15,7 +17,6 @@ class MessageToMemberType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('subject', SubjectType::class)
->add('message', CkEditorType::class, [
'attr' => [
'placeholder' => 'Please enter a message.',
@@ -28,6 +29,15 @@ public function buildForm(FormBuilderInterface $builder, array $options)
],
])
;
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$message = $event->getData();
$form = $event->getForm();
if ($message) {
$form->add('subject', SubjectType::class, ['disabled' => true]);
} else {
$form->add('subject', SubjectType::class);
}
});
}
/**
@@ -8,7 +8,7 @@

{% block content %}

{{ message.text | raw }}<br>
{{ message.message | raw }}<br>
<br>
<a href="{{ url('message_reply', { 'id': message.id }) }}">{{ request.reply }}</a>
<a href="{{ url('message_reply', { 'id': message.id }) }}">{{ 'reply' | trans }}</a>
{% endblock %}
@@ -16,5 +16,5 @@
<br>
{{ message | raw }}<br>
<br>
<a href="{{ url('hosting_request_reply', { 'id': request.id }) }}">{{ request.reply }}</a>
<a href="{{ url('hosting_request_reply', { 'id': request.id }) }}">{{ 'reply' | trans }}</a>
{% endblock %}
@@ -16,5 +16,5 @@
<br>
{{ message | raw }}<br>
<br>
<a href="{{ url('hosting_request_reply', { 'id': request.id }) }}">{{ request.reply }}</a>
<a href="{{ url('hosting_request_reply', { 'id': request.id }) }}">{{ 'reply' | trans }}</a>
{% endblock %}
@@ -11,5 +11,5 @@
<br>
{{ message | raw }}<br>
<br>
<a href="{{ url('hosting_request_reply', { 'id': request.id }) }}">{{ request.reply }}</a>
<a href="{{ url('hosting_request_reply', { 'id': request.id }) }}">{{ 'reply' | trans }}</a>
{% endblock %}

0 comments on commit 622ff25

Please sign in to comment.
You can’t perform that action at this time.