kompass/modules/event-participants/Controllers/class-signup.php

89 lines
3.1 KiB
PHP
Raw Normal View History

2024-05-27 16:59:30 +02:00
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event;
2024-05-27 16:59:30 +02:00
use function Bdp\Modules\EventParticipants\Views\registrationForm;
class ParticipationSignupController
{
public static function saveRegistration(array $postedData) : string {
global $dbHandler;
$event = Event::loadById($postedData['eventId']);
2024-05-27 16:59:30 +02:00
$participation_types = ['other', 'participant', 'volunteer'];
if (isset($postedData['foto']) && is_array($postedData['foto'])) {
foreach ($postedData['foto'] as $fotoData) {
$postedData['foto_' . $fotoData] = true;
}
}
if ($postedData['badeerlaubnis'] == '') {
$postedData['badeerlaubnis'] = 'complete';
}
if (isset($postedData['zusatzbeitrag'])) {
(int)$postedData['beitrag'] += (int)$postedData['zusatzbeitrag'];
unset($postedData['zusatzbeitrag']);
}
unset($postedData['foto']);
unset($postedData['_dsgvo_accept']);
$postedData['teilnahme'] = $participation_types[$postedData['gruppe_id']];
unset($postedData['gruppe_id']);
if (null == $dbHandler->insertRows(MainController::KOMPASS_EVENTS_PARTICIPANTS, $postedData)) {
$errorPage = file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/error.webseite.php');
$errorPage = sprintf($errorPage,
$postedData['vorname'],
$event->event_email,
$event->event_name,
$event->event_email
2024-05-27 16:59:30 +02:00
);
wp_mail($event->event_email, 'Anmeldung für "' . $event->event_name . '" fehlerhaft', print_r($postedData, true));
2024-05-27 16:59:30 +02:00
return $errorPage;
}
$successMail = file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/done.email.php');
$successMail = sprintf($successMail,
$postedData['vorname'],
$event->event_name,
2024-05-27 16:59:30 +02:00
\DateTime::createFromFormat('Y-m-d', $postedData['anreise'])->format('d.m.Y'),
\DateTime::createFromFormat('Y-m-d', $postedData['abreise'])->format('d.m.Y'),
ucfirst($postedData['essgewohnheit']),
$event->event_email,
$event->event_name,
$event->event_email
2024-05-27 16:59:30 +02:00
);
$successPage = file_get_contents(dirname(__FILE__) . '/../Templates/Partials/Registration/done.webseite.php');
$successPage = sprintf($successPage,
$postedData['vorname'],
$event->event_name,
2024-05-27 16:59:30 +02:00
\DateTime::createFromFormat('Y-m-d', $postedData['anreise'])->format('d.m.Y'),
\DateTime::createFromFormat('Y-m-d', $postedData['abreise'])->format('d.m.Y'),
ucfirst($postedData['essgewohnheit']),
$event->event_email,
$event->event_name,
$event->event_email
2024-05-27 16:59:30 +02:00
);
$sent = wp_mail(
$postedData['email_1'],
'Anmeldung zu "' . $event->event_name . '"',
2024-05-27 16:59:30 +02:00
$successMail,
['Reply-To: ' . $event->event_email, 'Content-Type: text/html; charset=UTF-8']);
2024-05-27 16:59:30 +02:00
if ('' !== $postedData['email_2']) {
$sent = wp_mail(
$postedData['email_2'],
'Anmeldung zu "' . $event->event_name . '"',
2024-05-27 16:59:30 +02:00
$successMail,
['Reply-To: ' . $event->event_email, 'Content-Type: text/html; charset=UTF-8']);
2024-05-27 16:59:30 +02:00
}
return $successPage;
}
}