Code Cleanups

This commit is contained in:
Thomas Günther 2024-05-31 22:47:04 +02:00
parent 837b371d9c
commit 492d5a0028
40 changed files with 3 additions and 249 deletions

View File

@ -26,17 +26,6 @@ function add_custom_admin_bar_item() {
// Überprüfen, ob der Benutzer die erforderliche Berechtigung hat
if ( current_user_can( 'show_groups' ) ) {
// Das Array mit den Eigenschaften des benutzerdefinierten Elements
$args = [
'id' => 'kompass_gruppen',
'title' => '<span class="ab-icon dashicons-groups"></span>' .
'<span class="ab-label">' .__('Groups', BDP_LV_PLUGIN_SLUG) . '</span>',
'href' => get_admin_url() . 'admin.php?page=kompass-groups',
];
// Das benutzerdefinierte Element zur Admin-Leiste hinzufügen
$wp_admin_bar->add_node( $args );
$args = [
'id' => 'kompass_events',
'title' => '<span class="ab-icon dashicons-tickets-alt"></span>' .

View File

@ -1,9 +1,6 @@
<?php
namespace Bdp\Libs;
use Bdp\Modules\EventParticipants\Controllers\MainController;
use Bdp\Modules\EventParticipants\Models\EventGroup;
class CommonModel extends \stdClass {
protected string $_tablename;
@ -34,8 +31,4 @@ class CommonModel extends \stdClass {
$compare = date_diff($today, $obj_birthday);
return $compare->y;
}
public function get_group() : CommonModel {
return EventGroup::load_by_id(MainController::KOMPASS_EVENTS_GROUPS, $this->gruppe_id);
}
}

View File

@ -1,21 +0,0 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
CREATE TABLE `%tablename%` (
`id` int NOT NULL AUTO_INCREMENT,
`gruppen_name` varchar(256) COLLATE utf8mb4_unicode_520_ci NOT NULL,
`gruppe_grufue` bigint UNSIGNED DEFAULT NULL,
PRIMARY KEY (id)
) %charset%;
ALTER TABLE `%tablename%`
ADD PRIMARY KEY (`id`);
ALTER TABLE `%tablename%`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
ALTER TABLE `%tablename%` ADD CONSTRAINT `gruppe_grufue` FOREIGN KEY (`gruppe_grufue`) REFERENCES `%prefix%users`(`ID`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

View File

@ -1,49 +0,0 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
CREATE TABLE `%tablename%` (
`id` int NOT NULL AUTO_INCREMENT,
`gruppe_id` int NOT NULL,
`vorname` varchar(128) NOT NULL,
`nachname` varchar(128) NOT NULL,
`geburtsdatum` date DEFAULT NULL,
`ansprechpartner` varchar(256) DEFAULT NULL,
`strasse` varchar(128) DEFAULT NULL,
`hausnummer` varchar(8) DEFAULT NULL,
`plz` varchar(5) DEFAULT NULL,
`ort` varchar(128) DEFAULT NULL,
`email_1` varchar(512) NOT NULL,
`email_2` varchar(512) DEFAULT NULL,
`telefon_1` varchar(16) NOT NULL,
`telefon_2` varchar(16) DEFAULT NULL,
`badeerlaubnis` enum('complete','partial','none','') NOT NULL DEFAULT 'none',
`allergien` varchar(2048) NOT NULL,
`abholung` enum('alone','parents','other','') NOT NULL DEFAULT 'parents',
`abholung_text` varchar(1024) NOT NULL DEFAULT '0',
`foto_socialmedia` tinyint NOT NULL DEFAULT '0',
`foto_print` tinyint NOT NULL DEFAULT '0',
`foto_webseite` tinyint NOT NULL DEFAULT '0',
`foto_partner` tinyint NOT NULL DEFAULT '0',
`halstuch` enum('none','woe','pfadi','rr') NOT NULL DEFAULT 'none',
`anmerkungen` varchar(2048) NOT NULL,
`aufnahmeantrag_da` tinyint NOT NULL DEFAULT '0',
`fotoerlaubnis_da` tinyint NOT NULL DEFAULT '0',
`elterninfo_da` tinyint NOT NULL DEFAULT '0',
`badeerlaubnis_da` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (id)
) %charset%;
ALTER TABLE `%tablename%`
ADD PRIMARY KEY (`id`),
ADD KEY `teili_gruppe` (`gruppe_id`);
ALTER TABLE `%tablename%`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
ALTER TABLE `%tablename%`
ADD CONSTRAINT `teili_gruppe` FOREIGN KEY (`gruppe_id`) REFERENCES `%prefix%kompass_stammesgruppen_gruppen` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

View File

@ -1,28 +0,0 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
CREATE TABLE `%tablename%` (
`id` int NOT NULL AUTO_INCREMENT,
`eventId` int NOT NULL,
`group_name` varchar(1024) NOT NULL,
`max_participants` int NOT NULL,
`amount_reduced` decimal(8,2) DEFAULT NULL,
`amount_default` decimal(8,2) DEFAULT NULL,
`amount_social` decimal(8,2) DEFAULT NULL,
PRIMARY KEY (id)
) %charset%;
ALTER TABLE `%tablename%`
ADD PRIMARY KEY (`id`),
ADD KEY `event_group` (`eventId`);
ALTER TABLE `%tablename%`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
ALTER TABLE `%tablename%`
ADD CONSTRAINT `event_group` FOREIGN KEY (`eventId`) REFERENCES `%prefix%kompass_veranstaltungen_index` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
COMMIT;

View File

@ -14,7 +14,7 @@ CREATE TABLE `%tablename%` (
`amount_social` decimal(8,2) NOT NULL,
`max_participants` INT NOT NULL,
`max_volunteers` INT NOT NULL,
`contributing_tribes` TEXT NOT NULL AFTER
`contributing_tribes` TEXT NOT NULL,
PRIMARY KEY (id)
) %charset%;

View File

@ -4,7 +4,7 @@ SET time_zone = "+00:00";
CREATE TABLE `%tablename%` (
`id` int NOT NULL AUTO_INCREMENT,
`gruppe_id` int NOT NULL,
`EVENTiD` int NOT NULL,
`teilnahme` ENUM('participant','volunteer','other','') NOT NULL,
`vorname` varchar(128) NOT NULL,
`nachname` varchar(128) NOT NULL,
@ -49,7 +49,4 @@ ALTER TABLE `%tablename%`
ALTER TABLE `%tablename%`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
ALTER TABLE `%tablename%`
ADD CONSTRAINT `event_gruppe` FOREIGN KEY (`gruppe_id`) REFERENCES `%prefix%kompass_veranstaltungen_gruppen` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;

Binary file not shown.

View File

@ -1,9 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class ArchiveEvent {
public function __construct() {
global $_REQUEST, $dbHandler;

View File

@ -1,9 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class CloseEvent {
public function __construct() {
global $_REQUEST, $dbHandler;

View File

@ -1,9 +1,6 @@
<?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;

View File

@ -1,7 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class DeleteMemberController {

View File

@ -1,8 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event as Event;
class EditEvent {
public function __construct() {
global $_GET, $_REQUEST, $dbHandler;

View File

@ -1,8 +1,6 @@
<?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 {

View File

@ -1,8 +1,6 @@
<?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 EventLocalGroupMailFormController {

View File

@ -1,8 +1,6 @@
<?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 EventMailFormController {

View File

@ -9,7 +9,6 @@ use SearchMemberRequest;
class MainController
{
public const KOMPASS_EVENTS_EVENTS = 'kompass_veranstaltungen_index';
public const KOMPASS_EVENTS_GROUPS = 'kompass_veranstaltungen_gruppen';
public const KOMPASS_EVENTS_PARTICIPANTS = 'kompass_veranstaltungen_teilis';
public static function setup()
@ -18,7 +17,7 @@ class MainController
$charset = $wpdb->get_charset_collate();
$fileReader = new FileAccess();
foreach ([self::KOMPASS_EVENTS_EVENTS, self::KOMPASS_EVENTS_GROUPS, self::KOMPASS_EVENTS_PARTICIPANTS] as $table) {
foreach ([self::KOMPASS_EVENTS_EVENTS, self::KOMPASS_EVENTS_PARTICIPANTS] as $table) {
$sqlTable = $wpdb->prefix . $table;
$sql = "SHOW TABLES LIKE '$sqlTable'";
@ -35,8 +34,6 @@ class MainController
$sqlSetup = str_replace('%charset%', $charset, $sqlSetup);
$sqlSetup = str_replace('%prefix%', $wpdb->prefix, $sqlSetup);
dbDelta( $sqlSetup );
}

View File

@ -1,7 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class MemberDetailsController {

View File

@ -1,7 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class MemberMailFormController {

View File

@ -1,7 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class MemberSummaryController {

View File

@ -1,8 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event as Event;
class NewEvent {
public function __construct() {
kompass_print_event_edit_form();

View File

@ -1,9 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class OpenEvent {
public function __construct() {
global $_REQUEST, $dbHandler;

View File

@ -1,8 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class ListEventsController {
public function __construct() {
kompass_print_events_overview();

View File

@ -3,9 +3,6 @@
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Reqeust\AnwesenheitRequest;
use Bdp\Modules\EventParticipants\Reqeust\EatingRequest;
class PrintParticipantListDrinkingPdfController {

View File

@ -3,9 +3,6 @@
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Reqeust\AnwesenheitRequest;
use Bdp\Modules\EventParticipants\Reqeust\EatingRequest;
class PrintParticipantListDrinkingAlcoholicPdfController {

View File

@ -3,10 +3,6 @@
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Reqeust\AnwesenheitRequest;
use Bdp\Modules\EventParticipants\Reqeust\BathRequest;
use Bdp\Modules\EventParticipants\Reqeust\EatingRequest;
class PrintParticipantListKitchenAllergiesPdfController {

View File

@ -3,10 +3,7 @@
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Reqeust\AnwesenheitRequest;
use Bdp\Modules\EventParticipants\Reqeust\BathRequest;
use Bdp\Modules\EventParticipants\Reqeust\EatingRequest;
class PrintParticipantListMedicalPdfController {

View File

@ -4,8 +4,6 @@ namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
use Bdp\Modules\EventParticipants\Reqeust\EatingRequest;
class PrintParticipantListPhotoPdfController {

View File

@ -4,8 +4,6 @@ namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Reqeust\AnwesenheitRequest;
use Bdp\Modules\EventParticipants\Reqeust\EatingRequest;
class PrintParticipantListSignupPdfController {

View File

@ -2,9 +2,7 @@
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Libs\FileAccess;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
use function Bdp\Modules\EventParticipants\Views\registrationForm;
class ParticipationSignupController

View File

@ -2,7 +2,6 @@
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Libs\FileAccess;
use function Bdp\Modules\EventParticipants\Views\registrationForm;
class EventSignupPageController

View File

@ -1,9 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class UpdateEvent {
public function __construct() {
global $_POST, $_REQUEST, $dbHandler;

View File

@ -1,7 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class UpdateMemberAmountController {

View File

@ -1,9 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Controllers;
use Bdp\Modules\EventParticipants\Models\EventGroup;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
class UpdateMemberDetailsController {
public function __construct() {
global $_POST, $_REQUEST, $dbHandler;

View File

@ -1,57 +0,0 @@
<?php
namespace Bdp\Modules\EventParticipants\Models;
use Bdp\Libs\CommonModel;
class EventGroup extends CommonModel {
public static function loadById(int $group_id) {
global $dbHandler;
$data = $dbHandler->readFromDb('kompass_veranstaltungen_gruppen', ['id' => $group_id]);
$class = new EventGroup();
foreach (get_object_vars($data[0]) as $key => $value) {
$class->$key = $value;
}
foreach (EventParticipant::list_for_group($group_id) as $participant_id) {
$class->participants[] = EventParticipant::loadById($participant_id);
}
return $class;
}
public static function list_simple_for_event(int $event_id) : array {
global $dbHandler;
$data = $dbHandler->readFromDb('kompass_veranstaltungen_gruppen', ['eventId' => $event_id]);
$return = [];
foreach ($data as $group) {
$group_class = new EventGroup();
foreach (get_object_vars($group) as $key => $value) {
$group_class->$key = $value;
}
$return[] = $group_class;
}
return $return;
}
public static function list_for_event(int $event_id) : array {
global $dbHandler;
$data = $dbHandler->readFromDb('kompass_veranstaltungen_teilis', ['eventId' => $event_id]);
$return = [];
foreach ($data as $group) {
$return[] = $group->id;
}
return $return;
}
public function __construct() {
$this->_tablename = 'kompass_veranstaltungen_gruppen';
$this->participants = [];
}
}

View File

@ -22,10 +22,6 @@ class EventParticipant extends CommonModel {
return $return;
}
public function get_group() : CommonModel {
return EventGroup::load_by_id(MainController::KOMPASS_EVENTS_GROUPS, $this->gruppe_id);
}
public function __construct() {
$this->_tablename = 'kompass_veranstaltungen_teilis';
}

View File

@ -3,7 +3,6 @@ namespace Bdp\Modules\EventParticipants\Reqeust;
use Bdp\Libs\CommonModel;
use Bdp\Modules\EventParticipants\Models\Event;
use Carbon\Carbon;
class AnwesenheitRequest {

View File

@ -1,7 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Reqeust;
use Bdp\Libs\CommonModel;
class BathRequest {

View File

@ -1,9 +1,6 @@
<?php
namespace Bdp\Modules\EventParticipants\Reqeust;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Models\EventParticipant;
use Carbon\Carbon;
class EatingRequest {

View File

@ -1,10 +1,7 @@
<?php
namespace Bdp\Modules\EventParticipants\Views;
use Bdp\Libs\FileAccess;
use Bdp\Modules\EventParticipants\Controllers\MainController as GruppenController;
use Bdp\Modules\EventParticipants\Models\Event;
use Bdp\Modules\EventParticipants\Models\EventGroup;
function registrationForm(int $eventId, string $targetPage) : string
{