Basic implementation event signup
This commit is contained in:
		@@ -0,0 +1,38 @@
 | 
			
		||||
<?php
 | 
			
		||||
namespace Bdp\Modules\EventParticipants\Controllers;
 | 
			
		||||
 | 
			
		||||
use Bdp\Modules\EventParticipants\Models\Event;
 | 
			
		||||
use Bdp\Modules\EventParticipants\Models\EventGroup;
 | 
			
		||||
use Bdp\Modules\EventParticipants\Models\EventParticipant;
 | 
			
		||||
 | 
			
		||||
class EventGroupMailFormController {
 | 
			
		||||
    public function __construct() {
 | 
			
		||||
        global $_REQUEST;
 | 
			
		||||
        $group = $_REQUEST['group'];
 | 
			
		||||
        $recipients = [];
 | 
			
		||||
        foreach (EventParticipant::list_for_event($_REQUEST['event-id']) as $participant) {
 | 
			
		||||
            if ($participant->teilnahme !== $group) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $recipient = $participant->vorname . ' <' . strtolower($participant->email_1) . '>';
 | 
			
		||||
            if (!in_array($recipient, $recipients) && str_contains($participant->email_1, '@')) {
 | 
			
		||||
                $recipients[] = $recipient;
 | 
			
		||||
            }
 | 
			
		||||
            if ('' != $participant->email_2 && str_contains($participant->email_2, '@')) {
 | 
			
		||||
                $recipient = $participant->vorname . ' <' . strtolower($participant->email_2) . '>';
 | 
			
		||||
                if (!in_array($recipient, $recipients)) {
 | 
			
		||||
                    $recipients[] = $recipient;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        $recipients = array_unique($recipients);
 | 
			
		||||
        $to = implode(', ', $recipients);
 | 
			
		||||
        kompass_print_mail_compose($to, "[KoPfiLa '24] - ");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user