E-Mail-Benachrichtigungen für Mitgliedsanträge
This commit is contained in:
parent
1328354827
commit
a0e85de7bd
4 changed files with 93 additions and 7 deletions
|
|
@ -117,6 +117,35 @@ class AdminController
|
|||
'role' => $user->role,
|
||||
]);
|
||||
|
||||
$applicantEmail = trim((string) ($application->email ?: $user->email));
|
||||
|
||||
if (filter_var($applicantEmail, FILTER_VALIDATE_EMAIL)) {
|
||||
$applicantName = trim($application->vorname . ' ' . $application->nachname) ?: $user->name;
|
||||
$body = "Hallo " . $applicantName . ",\n\n"
|
||||
. "dein Mitgliedsantrag bei der Motorrad-IG wurde angenommen.\n\n"
|
||||
. "Du kannst dich hier einloggen:\n"
|
||||
. app_base_url() . "/login\n\n"
|
||||
. "Bei Fragen erreichst du uns unter motorradig@aol.com.\n\n"
|
||||
. "Viele Grüße\n"
|
||||
. "Motorrad-IG\n";
|
||||
|
||||
if (!send_mail($applicantEmail, 'Dein Mitgliedsantrag wurde angenommen', $body, 'Motorrad-IG <motorradig@aol.com>')) {
|
||||
app_log('warning', 'Annahme-E-Mail an Antragsteller fehlgeschlagen', [
|
||||
'application_id' => (int) $id,
|
||||
'email' => $applicantEmail,
|
||||
]);
|
||||
} else {
|
||||
app_log('info', 'Annahme-E-Mail an Antragsteller gesendet', [
|
||||
'application_id' => (int) $id,
|
||||
'email' => $applicantEmail,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
app_log('warning', 'Annahme-E-Mail nicht gesendet: keine gültige E-Mail-Adresse', [
|
||||
'application_id' => (int) $id,
|
||||
]);
|
||||
}
|
||||
|
||||
flash_set('status', $roleChanged
|
||||
? 'Antrag angenommen. Der Benutzer ist jetzt Mitglied.'
|
||||
: 'Antrag angenommen. Der Benutzer hatte bereits eine Mitglieds- oder höhere Rolle.');
|
||||
|
|
@ -133,6 +162,33 @@ class AdminController
|
|||
redirect('/admin/antraege');
|
||||
}
|
||||
|
||||
$applicantEmail = trim((string) $application->email);
|
||||
|
||||
if (filter_var($applicantEmail, FILTER_VALIDATE_EMAIL)) {
|
||||
$applicantName = trim($application->vorname . ' ' . $application->nachname);
|
||||
$body = "Hallo " . $applicantName . ",\n\n"
|
||||
. "dein Mitgliedsantrag bei der Motorrad-IG wurde abgelehnt bzw. gelöscht.\n\n"
|
||||
. "Bei Fragen erreichst du uns unter motorradig@aol.com.\n\n"
|
||||
. "Viele Grüße\n"
|
||||
. "Motorrad-IG\n";
|
||||
|
||||
if (!send_mail($applicantEmail, 'Dein Mitgliedsantrag wurde abgelehnt/gelöscht', $body, 'Motorrad-IG <motorradig@aol.com>')) {
|
||||
app_log('warning', 'Ablehnungs-E-Mail an Antragsteller fehlgeschlagen', [
|
||||
'application_id' => (int) $id,
|
||||
'email' => $applicantEmail,
|
||||
]);
|
||||
} else {
|
||||
app_log('info', 'Ablehnungs-E-Mail an Antragsteller gesendet', [
|
||||
'application_id' => (int) $id,
|
||||
'email' => $applicantEmail,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
app_log('warning', 'Ablehnungs-E-Mail nicht gesendet: keine gültige E-Mail-Adresse', [
|
||||
'application_id' => (int) $id,
|
||||
]);
|
||||
}
|
||||
|
||||
$dir = storage_path('img_storage/mitgliedsantrag');
|
||||
|
||||
foreach (['unterschrift_1', 'unterschrift_2'] as $field) {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ class HomeController
|
|||
'aufnahme_ab' => 'required',
|
||||
'kontoinhaber' => 'required',
|
||||
'iban' => 'required',
|
||||
'email' => 'required|email',
|
||||
]);
|
||||
|
||||
$signature1 = $this->decodeSignature((string) input('unterschrift_1'));
|
||||
|
|
@ -144,12 +145,7 @@ class HomeController
|
|||
redirect('/mitgliedsantrag');
|
||||
}
|
||||
|
||||
$baseUrl = rtrim((string) config('app.url'), '/');
|
||||
|
||||
if ($baseUrl === '' || str_contains($baseUrl, 'localhost')) {
|
||||
$baseUrl = 'https://motorrad-ig.de';
|
||||
}
|
||||
|
||||
$baseUrl = app_base_url();
|
||||
$adminUrl = $baseUrl . '/admin/antraege/' . $application->id;
|
||||
|
||||
$body = "Neuer Mitgliedsantrag über die Website\n"
|
||||
|
|
@ -186,6 +182,28 @@ class HomeController
|
|||
$email
|
||||
);
|
||||
|
||||
$applicantBody = "Hallo " . trim($vorname . ' ' . $nachname) . ",\n\n"
|
||||
. "vielen Dank für deinen Mitgliedsantrag. Wir haben deinen Antrag am "
|
||||
. date('d.m.Y H:i') . " erhalten.\n\n"
|
||||
. "Antragsnummer: " . $application->id . "\n"
|
||||
. "E-Mail: " . $email . "\n\n"
|
||||
. "Wir prüfen deinen Antrag und melden uns bei dir, sobald er bearbeitet wurde.\n\n"
|
||||
. "Viele Grüße\n"
|
||||
. "Motorrad-IG\n"
|
||||
. $baseUrl . "\n";
|
||||
|
||||
if (!send_mail($email, 'Dein Mitgliedsantrag bei der Motorrad-IG', $applicantBody, 'Motorrad-IG <motorradig@aol.com>')) {
|
||||
app_log('warning', 'Bestätigungs-E-Mail an Antragsteller fehlgeschlagen', [
|
||||
'application_id' => $application->id,
|
||||
'email' => $email,
|
||||
]);
|
||||
} else {
|
||||
app_log('info', 'Bestätigungs-E-Mail an Antragsteller gesendet', [
|
||||
'application_id' => $application->id,
|
||||
'email' => $email,
|
||||
]);
|
||||
}
|
||||
|
||||
app_log('info', 'Mitgliedsantrag gespeichert', [
|
||||
'application_id' => $application->id,
|
||||
'email' => $email,
|
||||
|
|
|
|||
|
|
@ -76,6 +76,18 @@ function e($value): string
|
|||
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
/** Basis-URL der Anwendung (ohne abschließenden Slash). */
|
||||
function app_base_url(): string
|
||||
{
|
||||
$url = rtrim((string) config('app.url'), '/');
|
||||
|
||||
if ($url === '' || str_contains($url, 'localhost')) {
|
||||
return 'https://motorrad-ig.de';
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/** Ein Request-Eingabewert (POST hat Vorrang vor GET). */
|
||||
function input(string $key, $default = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
|
||||
<div class="form-group">
|
||||
<label for="email">E-Mail</label>
|
||||
<input id="email" name="email" type="email" class="form-control <?= error('email') ? 'is-invalid' : '' ?>" value="<?= e(old('email') ?? $user?->email) ?>" autocomplete="email">
|
||||
<input id="email" name="email" type="email" class="form-control <?= error('email') ? 'is-invalid' : '' ?>" value="<?= e(old('email') ?? $user?->email) ?>" autocomplete="email" required>
|
||||
<?php if (error('email')): ?><span class="invalid-feedback"><strong><?= e(error('email')) ?></strong></span><?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue