2024-03-23 00:37:20 +01:00
|
|
|
<?php
|
|
|
|
|
2024-05-27 16:59:30 +02:00
|
|
|
namespace Bdp\Modules\EventParticipants\Controllers;
|
2024-03-23 00:37:20 +01:00
|
|
|
|
|
|
|
use Bdp\Libs\FileAccess;
|
2024-03-23 20:46:44 +01:00
|
|
|
use SearchMemberRequest;
|
2024-03-23 00:37:20 +01:00
|
|
|
|
2024-05-27 16:59:30 +02:00
|
|
|
|
2024-03-23 00:37:20 +01:00
|
|
|
class MainController
|
|
|
|
{
|
2024-05-27 16:59:30 +02:00
|
|
|
public const KOMPASS_EVENTS_EVENTS = 'kompass_veranstaltungen_index';
|
|
|
|
public const KOMPASS_EVENTS_PARTICIPANTS = 'kompass_veranstaltungen_teilis';
|
2024-03-23 00:37:20 +01:00
|
|
|
|
2024-05-27 16:59:30 +02:00
|
|
|
public static function setup()
|
2024-03-23 00:37:20 +01:00
|
|
|
{
|
|
|
|
global $wpdb;
|
|
|
|
|
|
|
|
$charset = $wpdb->get_charset_collate();
|
|
|
|
$fileReader = new FileAccess();
|
2024-05-31 22:47:04 +02:00
|
|
|
foreach ([self::KOMPASS_EVENTS_EVENTS, self::KOMPASS_EVENTS_PARTICIPANTS] as $table) {
|
2024-03-23 00:37:20 +01:00
|
|
|
$sqlTable = $wpdb->prefix . $table;
|
|
|
|
$sql = "SHOW TABLES LIKE '$sqlTable'";
|
|
|
|
|
|
|
|
$result = $wpdb->get_var( $sql );
|
|
|
|
if ( $result == $sqlTable ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sqlSetup = str_replace(
|
|
|
|
'%tablename%',
|
|
|
|
$sqlTable,
|
|
|
|
$fileReader->get_contents( WP_PLUGIN_DIR . '/' . BDP_LV_PLUGIN_SLUG . '/lib/database/' . $table . '.sql' ) );
|
|
|
|
|
|
|
|
$sqlSetup = str_replace('%charset%', $charset, $sqlSetup);
|
|
|
|
$sqlSetup = str_replace('%prefix%', $wpdb->prefix, $sqlSetup);
|
|
|
|
|
|
|
|
dbDelta( $sqlSetup );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public function __construct()
|
|
|
|
{
|
2024-08-10 22:13:57 +02:00
|
|
|
global $dbHandler, $wpdb;
|
|
|
|
|
|
|
|
$no_events = true;
|
|
|
|
|
|
|
|
foreach ( [ self::KOMPASS_EVENTS_EVENTS ] as $table ) {
|
|
|
|
$sqlTable = $wpdb->prefix . $table;
|
|
|
|
$sql = "SHOW TABLES LIKE '$sqlTable'";
|
|
|
|
|
|
|
|
$result = $wpdb->get_var( $sql );
|
|
|
|
if ( $result == $sqlTable ) {
|
|
|
|
|
|
|
|
$no_events = 0 === $dbHandler->countSqlRows( self::KOMPASS_EVENTS_EVENTS, [ 'archived' => false ] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !$no_events ) {
|
2024-10-31 12:53:26 +01:00
|
|
|
wp_admin_notice(
|
|
|
|
'Mit dem kommenden Update von BdP Kompass ist der Zugriff auf Legacy-Veranstaltungen nicht mehr möglich. <br />' .
|
|
|
|
'Das Update wird voraussichtlich am <strong>06.01.2025</strong> bereitgestellt werden.<br /><br />' .
|
|
|
|
'Insofern du weiterhin Zugriff auf diese Veranstaltungen benötigst, kontaktiere den LB IT.', ['type' => 'warning']);
|
2024-08-10 22:13:57 +02:00
|
|
|
|
|
|
|
add_menu_page(
|
|
|
|
__( 'Events (legacy)', BDP_LV_PLUGIN_SLUG ),
|
|
|
|
__( 'Events (legacy)', BDP_LV_PLUGIN_SLUG ),
|
|
|
|
'send_mails',
|
|
|
|
'kompass-events',
|
|
|
|
[ $this, 'router' ],
|
|
|
|
'dashicons-tickets-alt',
|
|
|
|
3
|
|
|
|
);
|
|
|
|
|
|
|
|
foreach ( $dbHandler->readFromDb( self::KOMPASS_EVENTS_EVENTS, [ 'archived' => false ] ) as $currentEvent ) {
|
|
|
|
add_submenu_page(
|
|
|
|
'kompass-events',
|
|
|
|
$currentEvent->event_name,
|
|
|
|
$currentEvent->event_name,
|
|
|
|
'show_groups',
|
|
|
|
'kompass-events&action=show-event&event-id=' . $currentEvent->id,
|
|
|
|
[ $this, 'router' ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-03-23 00:37:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-08-10 22:13:57 +02:00
|
|
|
|
2024-03-23 00:37:20 +01:00
|
|
|
public function router()
|
|
|
|
{
|
2024-03-23 20:46:44 +01:00
|
|
|
if (isset($_REQUEST['action'])) {
|
2024-03-23 00:37:20 +01:00
|
|
|
switch ($_REQUEST['action']) {
|
2024-05-27 16:59:30 +02:00
|
|
|
case 'show-event':
|
|
|
|
new ListGroupsAndMembersController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'show-participant':
|
|
|
|
if (isset($_REQUEST['save'])) {
|
|
|
|
new UpdateMemberDetailsController();
|
|
|
|
}
|
|
|
|
|
|
|
|
new MemberDetailsController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'delete-participant':
|
|
|
|
new DeleteMemberController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'update-participant-amount':
|
|
|
|
new UpdateMemberAmountController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'open-event':
|
|
|
|
new OpenEvent();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'close-event':
|
|
|
|
new CloseEvent();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'archive-event':
|
|
|
|
new ArchiveEvent();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'edit-event':
|
|
|
|
new EditEvent();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'update-event':
|
|
|
|
new UpdateEvent();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'new-event':
|
|
|
|
new NewEvent();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'create-event':
|
|
|
|
new CreateEvent();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'kompass_print_participant_mail_form':
|
|
|
|
new MemberMailFormController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'send-mail-to-all':
|
|
|
|
new EventMailFormController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'send-mail-to-group':
|
|
|
|
new EventGroupMailFormController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'send-mail-to-local-group':
|
|
|
|
new EventLocalGroupMailFormController();
|
|
|
|
break;
|
|
|
|
|
2024-03-23 00:37:20 +01:00
|
|
|
case 'searchmember':
|
2024-03-23 20:46:44 +01:00
|
|
|
$memberList = SearchMemberRequest::listByName($_POST['member_name']);
|
|
|
|
new PrintMemberListController($memberList);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'create_group_form':
|
|
|
|
new CreateGroupController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'update-group':
|
|
|
|
\UpdateGroupAction::execute(['gruppen_name' => $_REQUEST['kompass_groups_group_name']],
|
|
|
|
(int)$_REQUEST['group_id']);
|
|
|
|
|
|
|
|
new PrintGroupsController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'create-group':
|
|
|
|
$data = ['gruppen_name' => $_REQUEST['kompass_groups_group_name']];
|
|
|
|
\CreateGroupAction::execute($data);
|
|
|
|
new PrintGroupsController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'new-member':
|
|
|
|
new CreateMemberController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'create-member':
|
|
|
|
$userData = \CreateGroupMemberDataAction::execute($_REQUEST);
|
|
|
|
if (count($userData['errors']) === 0) {
|
|
|
|
$memberId = \CreateGroupMemberAction::execute( $userData['data'] );
|
|
|
|
new PrintMemberController($memberId);
|
|
|
|
} else {
|
|
|
|
kompass_print_message_box(implode('<br />', $userData['errors']), 'error');
|
|
|
|
new CreateMemberController($userData['rawData']);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
new PrintGroupsController();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'show-members':
|
|
|
|
$memberList = \ListMemberRequest::listForGroup((int)$_REQUEST['group-id']);
|
|
|
|
new PrintMemberListController($memberList);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'show-member':
|
|
|
|
new PrintMemberController((int)$_REQUEST['member-id']);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'compose-mail':
|
|
|
|
current_user_can('send_mails');
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'delete-group':
|
|
|
|
if (current_user_can('delete_groups')) {
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'edit-group':
|
|
|
|
if (current_user_can('edit_groups')) {
|
|
|
|
kompass_edit_group_form($_REQUEST['group-id']);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-05-27 16:59:30 +02:00
|
|
|
new ListEventsController();
|
2024-03-23 00:37:20 +01:00
|
|
|
}
|
|
|
|
} else {
|
2024-05-27 16:59:30 +02:00
|
|
|
|
|
|
|
new ListEventsController();
|
2024-03-23 00:37:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-23 20:46:44 +01:00
|
|
|
private function listMembers()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2024-03-23 00:37:20 +01:00
|
|
|
|
|
|
|
private function printMembers(array $memberList)
|
|
|
|
{
|
2024-03-23 20:46:44 +01:00
|
|
|
|
2024-03-23 00:37:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|