41 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
namespace Bdp\Modules\EventParticipants\Controllers;
 | 
						|
 | 
						|
use Bdp\Modules\EventParticipants\Models\EventGroup;
 | 
						|
use Bdp\Modules\EventParticipants\Models\EventParticipant;
 | 
						|
 | 
						|
class CreateEvent {
 | 
						|
	public function __construct() {
 | 
						|
		global $_POST, $_REQUEST, $dbHandler;
 | 
						|
 | 
						|
        $use_data = ['event_name', 'startdatum', 'enddatum','max_participants', 'max_volunteers', 'amount_reduced', 'amount_default', 'amount_social', 'contributing_tribes'];
 | 
						|
        $post_data = [];
 | 
						|
        foreach ($_POST as $key => $value) {
 | 
						|
            if (in_array($key, $use_data)) {
 | 
						|
                $post_data[$key] = $value;
 | 
						|
            }
 | 
						|
        };
 | 
						|
 | 
						|
        $post_data['amount_reduced'] = str_replace(',', '.', $_POST['amount_reduced']);
 | 
						|
        $post_data['amount_default'] = str_replace(',', '.', $_POST['amount_default']);
 | 
						|
        $post_data['amount_social'] = str_replace(',', '.', $_POST['amount_social']);
 | 
						|
 | 
						|
        $post_data['contributing_tribes'] = str_replace( PHP_EOL, ',', $post_data['contributing_tribes'] );
 | 
						|
 | 
						|
		$new_event_id = $dbHandler->insertRows(
 | 
						|
			'kompass_veranstaltungen_index',
 | 
						|
			$post_data,
 | 
						|
		);
 | 
						|
		kompass_print_message_box(__('Event created successfull.', BDP_LV_PLUGIN_SLUG));
 | 
						|
 | 
						|
        $pageName = $post_data['event_name'] . ' - ' .__('Registration', BDP_LV_PLUGIN_SLUG);
 | 
						|
            $page_id = wp_insert_post(array(
 | 
						|
                'post_title' => $pageName,
 | 
						|
                'post_content' => '{{event-' . $new_event_id . '}}',
 | 
						|
                'post_status' => 'publish',
 | 
						|
                'post_type' => 'page',
 | 
						|
            ));
 | 
						|
 | 
						|
        new ListEventsController();
 | 
						|
	}
 | 
						|
} |