Commit e29e14a5 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '237-ubersetzungstool-email-feld-fur-ruckfragen' into 'development'

Emailfeld für Rückfragen hinzugefügt

Closes #237

See merge request !808
parents a7669b5b 7c18937d
......@@ -49,7 +49,7 @@ class LanguageController extends Controller
->with('deComplete', $deComplete);
}
public function createEditPage($from, $to, $exclude = "")
public function createEditPage($from, $to, $exclude = "", $email = "")
{
$languageFilePath = resource_path() . "/lang/";
$files = scandir($languageFilePath);
......@@ -153,7 +153,8 @@ class LanguageController extends Controller
->with('to', $to)
->with('langTexts', $langTexts)
->with('sum', $sum)
->with('new', $ex["new"]);
->with('new', $ex["new"])
->with('email', $email);
}
private function htmlEscape($t, $to)
......
......@@ -117,18 +117,23 @@ class MailController extends Controller
}
public function sendLanguageFile(Request $request, $from, $to, $exclude = "")
public function sendLanguageFile(Request $request, $from, $to, $exclude = "", $email ="")
{
$filename = $request->input('filename');
# Wir erstellen nun zunächst den Inhalt der Datei:
$data = [];
$new = 0;
$emailAddress = "";
foreach ($request->all() as $key => $value) {
if ($key === "filename" || $value === "") {
continue;
}
if($key === "email") {
$emailAddress = $value;
continue;
}
$key = base64_decode($key);
if (strpos($key, "_new_") === 0 && $value !== "") {
$new++;
......@@ -153,11 +158,13 @@ class MailController extends Controller
$output = preg_replace("/\{/si", "[", $output);
$output = preg_replace("/\}/si", "]", $output);
$output = preg_replace("/\": ([\"\[])/si", "\"\t=>\t$1", $output);
$output = "<?php\n\nreturn $output;\n";
$message = "Moin moin,\n\nein Benutzer hat eine Sprachdatei aktualisiert.\nSollten die Texte so in Ordnung sein, ersetzt, oder erstellt die Datei aus dem Anhang in folgendem Pfad:\n$filename\n\nFolgend zusätzlich der Inhalt der Datei:\n\n$output";
// echo $request->old('email');
//echo $request->input('email','test');
// die("");
# Wir haben nun eine Mail an uns geschickt, welche die entsprechende Datei beinhaltet.
# Nun müssen wir den Nutzer eigentlich nur noch zurück leiten und die Letzte bearbeitete Datei ausschließen:
$ex = [];
......@@ -179,10 +186,17 @@ class MailController extends Controller
$ex["new"] += $new;
if ($new > 0) {
Mail::to("dev@suma-ev.de")
if($emailAddress !== "") {
Mail::to("dev@suma-ev.de")
->send(new Sprachdatei($message, $output, basename($filename), $emailAddress));
}
else {
Mail::to("dev@suma-ev.de")
->send(new Sprachdatei($message, $output, basename($filename)));
}
}
$ex = base64_encode(serialize($ex));
return redirect(url('languages/edit', ['from' => $from, 'to' => $to, 'exclude' => $ex]));
return redirect(url('languages/edit', ['from' => $from, 'to' => $to, 'exclude' => $ex, 'email' => $emailAddress]));
}
}
......@@ -15,10 +15,10 @@ class Sprachdatei extends Mailable
*
* @return void
*/
public function __construct($message, $fileContent, $filename)
public function __construct($message, $fileContent, $filename, $replyAddress = "noreply@metager.de")
{
$this->subject = "MetaGer - Sprachdatei";
$this->reply = "noreply@metager.de";
$this->reply = $replyAddress;
$this->message = $message;
$this->fileContent = $fileContent;
$this->filename = $filename;
......
......@@ -55,5 +55,7 @@
<p>{{ trans('languages.hinweis.1') }}</p>
<p>{!! trans('languages.hinweis.2') !!}</p>
<p>{!! trans('languages.hinweis.3') !!}</p>
<p><b>E-Mail-Adresse für Rückfragen</b> (optional):</p>
<p><input type="email" name="email" form="submit" value="{{$email}}"/></p>
<button class="btn btn-success" type="submit" form="submit">Daten übermitteln</button>
@endsection
......@@ -158,8 +158,8 @@ Route::group(
return redirect('https://metager.de/klassik/databund');
});
Route::get('languages', 'LanguageController@createOverview');
Route::get('languages/edit/{from}/{to}/{exclude?}', 'LanguageController@createEditPage');
Route::post('languages/edit/{from}/{to}/{exclude?}', 'MailController@sendLanguageFile');
Route::get('languages/edit/{from}/{to}/{exclude?}/{email?}', 'LanguageController@createEditPage');
Route::post('languages/edit/{from}/{to}/{exclude?}/{email?}', 'MailController@sendLanguageFile');
Route::get('berlin', 'StartpageController@berlin');
Route::group(['prefix' => 'app'], function () {
......
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