Commit 731ccf41 authored by Dominik Hebeler's avatar Dominik Hebeler

Kontaktformular läuft nun über unser Ticketsystem

parent e82851b9
......@@ -9,6 +9,7 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use LaravelLocalization;
use Mail;
use Validator;
class MailController extends Controller
{
......@@ -24,6 +25,23 @@ class MailController extends Controller
# Nachricht, die wir an den Nutzer weiterleiten:
$messageType = ""; # [success|error]
$returnMessage = '';
# Wir benötigen 3 Felder von dem Benutzer wenn diese nicht übermittelt wurden, oder nicht korrekt sind geben wir einen Error zurück
$validator = Validator::make(
[
'email' => $request->input('email')
],
[
'email' => 'required|email'
]
);
if($validator->fails()){
return view('kontakt.kontakt')->with('formerrors', $validator)->with('title', trans('titles.kontakt'))->with('navbarFocus', 'kontakt');
}
$name = $request->input('name', '');
$replyTo = $request->input('email', 'noreply@metager.de');
if ($replyTo === "") {
$replyTo = "noreply@metager.de";
......@@ -31,15 +49,15 @@ class MailController extends Controller
$replyTo = $request->input('email');
}
if (!$request->has('message')) {
if (!$request->has('message') || !$request->has('subject')) {
$messageType = "error";
$returnMessage = "Tut uns leid, aber leider haben wir mit Ihrer Kontaktanfrage keine Daten erhalten. Die Email wurde nicht versand";
} else {
# Wir versenden die Mail des Benutzers an uns:
$message = $request->input('message');
Mail::to("office@suma-ev.de")
->send(new Kontakt($replyTo, $message));
$subject = $request->input('subject');
Mail::to("support@suma-ev.de")
->send(new Kontakt($name, $replyTo, $subject, $message));
$returnMessage = 'Ihre Email wurde uns erfolgreich zugestellt. Vielen Dank dafür! Wir werden diese schnellstmöglich bearbeiten und uns dann ggf. wieder bei Ihnen melden.';
$messageType = "success";
......
......@@ -15,10 +15,11 @@ class Kontakt extends Mailable
*
* @return void
*/
public function __construct($from, $message)
public function __construct($name, $from, $subject, $message)
{
$this->subject = "[Ticket " . date("Y") . date("d") . date("m") . date("H") . date("i") . date("s") . "] MetaGer - Kontaktanfrage";
$this->name = $name;
$this->reply = $from;
$this->subject = $subject;
$this->message = $message;
}
......@@ -29,7 +30,7 @@ class Kontakt extends Mailable
*/
public function build()
{
return $this->from($this->reply)
return $this->from($this->reply, $this->name)
->subject($this->subject)
->text('kontakt.mail')
->with('messageText', $this->message);
......
$(document).ready(function () {
switch (getLanguage()) {
case 'de':
$('.encrypt-btn').html('Verschlüsseln und senden');
break;
case 'en':
$('.encrypt-btn').html('encrypt and send');
break;
case 'es':
// $(".encrypt-btn").html(""); TODO
break;
}
$('.contact').submit(function () {
return encrypt(this);
});
});
// based on https://github.com/encrypt-to/secure.contactform.php
/* The MIT License (MIT)
Copyright (c) 2013 Jan Wiegelmann
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
function encrypt () {
if (window.crypto && window.crypto.getRandomValues) {
var message = document.getElementById('message');
if (message.value.indexOf('-----BEGIN PGP MESSAGE-----') !== -1 && message.value.indexOf('-----END PGP MESSAGE-----') !== -1) {
// encryption done
} else {
var pub_key = openpgp.key.readArmored(document.getElementById('pubkey').innerHTML).keys[0];
var plaintext = message.value;
var ciphertext = openpgp.encryptMessage([pub_key], plaintext);
message.value = ciphertext;
return true;
}
} else {
switch (getLanguage()) {
case 'de':
alert('Fehler: Ihr Browser wird nicht unterstützt. Bitte installieren Sie einen aktuellen Browser wie z.B. Mozilla Firefox.');
break;
case 'en':
alert('Error: Your browser is not supported. Please install an up to date browser like Mozilla Firefox.');
break;
case 'es':
// alert(""); TODO
break;
}
return false;
}
}
function getLanguage () {
var metaData = document.getElementsByTagName('meta');
for (var m in metaData) {
if (metaData[m]['httpEquiv'] == 'language') {
return metaData[m]['content'];
}
}
}
......@@ -2,19 +2,14 @@
return [
'headline.1' => 'Kontakt',
'headline.2' => 'Forum',
'headline.3' => 'Bitte stellen Sie technische Fragen zuerst in unserem <a href="http://forum.suma-ev.de/" target="_blank" rel="noopener">Forum</a>',
'headline.4' => 'So können auch andere von einer Antwort profitieren.',
'form.1' => 'Sicheres Kontakformular',
'form.2' => 'Über dieses Formular können Sie uns verschlüsselt kontaktieren.
Alternativ können Sie uns natürlich auch per <a href="mailto:office@suma-ev.de">email</a> erreichen.',
'form.3' => 'Beachten Sie: Aufgrund der Vielzahl der Anfragen sind wir personell nicht immer in der Lage, alles zeitnah zu beantworten.',
'form.4' => 'Wenn Sie keine email-Adresse angeben, können wir Ihnen nicht antworten.',
'form.5' => 'Ihre e-mail-Adresse (optional)',
'form.2' => 'Über dieses Formular können Sie uns kontaktieren.
Alternativ können Sie uns natürlich auch per <a href="mailto:support@suma-ev.de">email</a> erreichen.',
'form.name' => "Name (Vorname Nachname)",
'form.5' => 'Ihre e-mail-Adresse',
'form.6' => 'Ihre Nachricht',
'form.7' => '<strong>Ihre Nachricht wird vor dem Absenden mit <a href="http://openpgpjs.org/.">OpenPGP.js</a> verschlüsselt. Dafür wird Javascript benötigt.</strong> Falls Sie Javascript deaktiviert haben, wird Ihre Eingabe unverschlüsselt gesendet.',
'form.8' => 'Verschlüsseln und senden',
'form.7' => 'Betreff',
'form.8' => 'Senden',
'mail.1' => 'Per Email',
'mail.2' => 'Sie können uns auch direkt eine email an die folgende Adresse schicken: <a href="mailto:office@suma-ev.de">office@suma-ev.de</a>',
......
......@@ -2,19 +2,13 @@
return [
'headline.1' => 'Contact',
'headline.2' => 'Forum',
'headline.3' => 'If you have a technical question, ask the community at our <a href="http://forum.suma-ev.de/" target="_blank" rel="noopener">board</a> first, please.',
'headline.4' => 'So others could benefit from an answer.',
'form.1' => 'Secure Contact Form',
'form.2' => 'Via this form you can contact us by encrypted e-mail.',
'form.2' => 'Via this form you can contact us by e-mail.',
'form.3' => 'Please note that due to a lot of requests we are personnel-wise not able to answer everything promptly.',
'form.4' => 'If you do not enter an email-adress, we can not answer you.',
'form.5' => 'Your e-mail-adress (optional)',
'form.6' => 'Your message',
'form.7' => '<strong>Before dispatch, your messgae is encrypted with <a href="http://openpgpjs.org/.">OpenPGP.js</a>. We use Javascript for this.</strong> If you have Javascript disabled, your message will be send unencrypted.',
'form.8' => 'Encrypt and send',
'form.8' => 'Send',
'mail.1' => 'By Email',
'mail.2' => 'You can also email us directly at: <a href="mailto:office@suma-ev.de">office@suma-ev.de</a>',
......
......@@ -9,7 +9,6 @@ return [
"form.1" => "Formulario de contacto seguro",
"form.2" => "Con este formulario nos puede contactar encryptado. Por supuesto como vía alterna nos puede mandar un <a href=\"mailto:office@suma-ev.de\">email</a>.",
"form.3" => "Por la cantidad de consultas que recibimos no estamos siempre contestando a tiempo.",
"form.4" => "Si no nos da su correo electrónico, no podemos contestarle.",
"form.5" => "Su dirección de correo electrónico (opcional)",
"form.6" => "Su mensaje",
'form.7' => '<strong>Su mensaje será encryptada antes de mandarla <a href="http://openpgpjs.org/.">OpenPGP.js</a> para esto necesitamos Javascript.</strong> Sino tiene activado Javascript su mensaje será enviada sin encryptación.',
......
......@@ -4,25 +4,33 @@
@section('content')
<h1>{!! trans('kontakt.headline.1') !!}</h1>
<h2>{!! trans('kontakt.headline.2') !!}</h2>
<p><span class="bold">{!! trans('kontakt.headline.3') !!}</span>
<span>{!! trans('kontakt.headline.4') !!}</span></p>
<h2>{!! trans('kontakt.form.1') !!}</h2>
<p>{!! trans('kontakt.form.2') !!}</p>
<p>{!! trans('kontakt.form.3') !!}</p>
<p class="bold">{!! trans('kontakt.form.4') !!}</p>
@if(isset($formerrors))
@foreach($formerrors->errors()->all() as $errormessage)
<div class="alert alert-danger" role="alert">{{$errormessage}}</div>
@endforeach
@endif
<form class="contact" name="contact" method="post" action="{{ LaravelLocalization::getLocalizedURL() }}">
{{ csrf_field() }}
<div class="form-group kontakt-form-group">
<input class="form-control" name="email" placeholder="{!! trans('kontakt.form.5') !!}" type="text"></div>
<input class="form-control" name="name" placeholder="{!!trans('kontakt.form.name')!!}" type="text" required @if(isset($formerrors) && Request::has('name'))value="{{Request::input('name')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
<input class="form-control" name="email" placeholder="{!! trans('kontakt.form.5') !!}" type="email" required @if(isset($formerrors) && Request::has('email'))value="{{Request::input('email')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
<input class="form-control" name="subject" placeholder="{!! trans('kontakt.form.7') !!}" type="text" required @if(isset($formerrors) && Request::has('subject'))value="{{Request::input('subject')}}"@endif>
</div>
<div class="form-group kontakt-form-group">
@if(isset($url) && $url !== "")
<label for="message">Wenn MetaGer bestimmte Webseiten nicht angezeigt hat, von denen Sie wissen, dass es sie gibt: Bitte nennen Sie deren Adresse/n (http:// ...???...). Wir werden das detailliert untersuchen.</label>
@endif
<textarea class="form-control" id="message" name="message" placeholder="{!! trans('kontakt.form.6') !!}">@if(isset($url) && $url !== "")Die Suche unter "{{ base64_decode($url) }}" ist unvollständig.@endif</textarea>
<textarea class="form-control" id="message" name="message" placeholder="{!! trans('kontakt.form.6') !!}" requireds>@if(isset($formerrors) && Request::has('message')){{Request::input('message')}}@endif</textarea>
</div>
<div class="form-group kontakt-form-group">
<p>{!! trans('kontakt.form.7') !!}</p>
<button title="" data-original-title="" class="btn btn-default encrypt-btn" type="submit">{!! trans('kontakt.form.8') !!}</button>
</div>
</form>
......@@ -96,5 +104,4 @@ geiG3j1J/CaDBZqPBaBflK0UWR5nxCsoOk7i5f3isUeXSVLTnA+K9HkQ6D/Gt5vx
<p>{!! trans('kontakt.letter.2') !!}</p>
<address>{!! trans('kontakt.letter.3') !!}</address>
<script type="text/javascript" src="{{ elixir('js/lib.js') }}"></script>
<script type="text/javascript" src="{{ elixir('js/kontakt.js') }}"></script>
@endsection
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