get_charset_collate(); $fileReader = new FileAccess(); foreach ([self::KOMPASS_STAMMESGRUPPEN_GRUPPEN, self::KOMPASS_STAMMESGRUPPEN_TEILIS] 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() { add_submenu_page( BDP_LV_PLUGIN_DIR . '/modules/index.php', __('Groups', BDP_LV_PLUGIN_SLUG), __('Groups', BDP_LV_PLUGIN_SLUG), 'show_groups', 'kompass-groups', [$this, 'router'], 1); } public function router() { if (isset($_REQUEST['action'])) { switch ($_REQUEST['action']) { 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 PrintGroupsController(); } } else { new PrintGroupsController(); } } private function listMembers() { } private function printMembers(array $memberList) { } }