get_charset_collate();
$fileReader = new FileAccess();
foreach ([self::KOMPASS_EVENTS_EVENTS, self::KOMPASS_EVENTS_PARTICIPANTS] as $table) {
$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()
{
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 ) {
wp_admin_notice(
'Mit dem kommenden Update von BdP Kompass ist der Zugriff auf Legacy-Veranstaltungen nicht mehr möglich.
' .
'Das Update wird voraussichtlich am 06.01.2025 bereitgestellt werden.
' .
'Insofern du weiterhin Zugriff auf diese Veranstaltungen benötigst, kontaktiere den LB IT.', ['type' => 'warning']);
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' ] );
}
}
}
public function router()
{
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
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;
case 'searchmember':
$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('
', $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:
new ListEventsController();
}
} else {
new ListEventsController();
}
}
private function listMembers()
{
}
private function printMembers(array $memberList)
{
}
}