Basic implementation event signup
This commit is contained in:
@ -17,11 +17,21 @@ class DatabaseHandler {
|
||||
return $this->getResults($sql);
|
||||
}
|
||||
|
||||
public function insertRows(string $tableName, array $newData) : int
|
||||
public function deleteFromDb(string $table, array $conditions = []) {
|
||||
global $wpdb;
|
||||
$table = $wpdb->prefix . $table;
|
||||
$wpdb->delete($table, $conditions);
|
||||
}
|
||||
|
||||
public function insertRows(string $tableName, array $newData) : ?int
|
||||
{
|
||||
global $wpdb;
|
||||
$tableName = $wpdb->prefix . $tableName;
|
||||
$wpdb->insert( $tableName, $newData );
|
||||
|
||||
|
||||
if (!$wpdb->insert( $tableName, $newData )) {
|
||||
return null;
|
||||
};
|
||||
return $wpdb->insert_id;
|
||||
}
|
||||
|
||||
@ -29,7 +39,7 @@ class DatabaseHandler {
|
||||
{
|
||||
global $wpdb;
|
||||
$tableName = $wpdb->prefix . $tableName;
|
||||
$wpdb->update( $tableName, $newData, $conditions );
|
||||
return $wpdb->update( $tableName, $newData, $conditions );
|
||||
}
|
||||
|
||||
public function countSqlRows(string $tableName, array $conditions = []) : int
|
||||
|
@ -36,6 +36,19 @@ function add_custom_admin_bar_item() {
|
||||
|
||||
// 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>' .
|
||||
'<span class="ab-label">' .__('Events', BDP_LV_PLUGIN_SLUG) . '</span>',
|
||||
'href' => get_admin_url() . 'admin.php?page=kompass-events',
|
||||
|
||||
];
|
||||
|
||||
// Das benutzerdefinierte Element zur Admin-Leiste hinzufügen
|
||||
$wp_admin_bar->add_node( $args );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
41
includes/class-modelcommon.php
Normal file
41
includes/class-modelcommon.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace Bdp\Libs;
|
||||
|
||||
use Bdp\Modules\EventParticipants\Controllers\MainController;
|
||||
use Bdp\Modules\EventParticipants\Models\EventGroup;
|
||||
|
||||
class CommonModel extends \stdClass {
|
||||
protected string $_tablename;
|
||||
|
||||
public static function load_by_id(string $table_name, int $object_id) {
|
||||
global $dbHandler;
|
||||
|
||||
$data = $dbHandler->readFromDb($table_name, ['id' => $object_id]);
|
||||
$class = new CommonModel();
|
||||
|
||||
foreach (get_object_vars($data[0]) as $key => $value) {
|
||||
$class->$key = $value;
|
||||
}
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
global $dbHandler;
|
||||
|
||||
}
|
||||
public function is_fullaged() : bool {
|
||||
return kompass_is_fullaged($this->geburtsdatum);
|
||||
}
|
||||
|
||||
public function get_age() {
|
||||
$obj_birthday = \DateTime::createFromFormat('Y-m-d', $this->geburtsdatum);
|
||||
$today = new \DateTime();
|
||||
$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);
|
||||
}
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\EventParticipants\Controllers\EventSignupPageController;
|
||||
use Bdp\Modules\EventParticipants\Controllers\RegisterMemberController;
|
||||
|
||||
add_action( 'plugins_loaded', 'bdp_kompass_load_plugin_textdomain' );
|
||||
|
||||
register_activation_hook(BDP_LV_STARTUP_FILE, 'bdp_plugin_install');
|
||||
@ -43,3 +46,14 @@ function _protect_wp_initial_bot_list_array()
|
||||
{
|
||||
return explode(';', 'SemrushBot;AhrefsBot;DotBot;WhatCMS;Rogerbot;trendictionbot;BLEXBot;linkfluence;magpie-crawler;MJ12bot;Mediatoolkitbot;AspiegelBot;DomainStatsBot;Cincraw;Nimbostratus;HTTrack;serpstatbot;omgili;GrapeshotCrawler;MegaIndex;PetalBot;Semanticbot;Cocolyzebot;DomCopBot;Traackr;BomboraBot;Linguee;webtechbot;DomainStatsBot;Clickagy;sqlmap;Internet-structure-research-project-bot;Seekport;AwarioSmartBot;OnalyticaBot;Buck;Riddler;SBL-BOT;DF Bot 1.0;PubMatic Crawler Bot;BVBot;Sogou;Barkrowler;Yandex');
|
||||
}
|
||||
|
||||
|
||||
add_filter('the_content', 'load_kompass_content');
|
||||
|
||||
|
||||
function load_kompass_content($content) {
|
||||
$content = Calendar::printCalendar($content);
|
||||
$content = EventSignupPageController::print_signup_page($content);
|
||||
|
||||
return $content;
|
||||
}
|
21
includes/pdfhandler.php
Normal file
21
includes/pdfhandler.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Dompdf\Dompdf;
|
||||
use Dompdf\Options;
|
||||
|
||||
function kompass_create_pdf (string $content, string $filename, string $format = 'portrait', bool $force_download = true): ?string {
|
||||
|
||||
|
||||
$dompdf = new Dompdf();
|
||||
$dompdf->setPaper('A4', $format);
|
||||
$dompdf->loadHtml($content);
|
||||
|
||||
$dompdf->render();
|
||||
|
||||
if (!$force_download) {
|
||||
return $dompdf->output();
|
||||
}
|
||||
|
||||
$dompdf->stream( $filename );
|
||||
return null;
|
||||
}
|
@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\EventParticipants\Controllers\MemberSummaryController;
|
||||
use Bdp\Modules\EventParticipants\Controllers\PrintParticipantListPdfController;
|
||||
use Bdp\Modules\EventParticipants\Controllers\RegisterMemberController;
|
||||
use Bdp\Modules\LimitLoginAttempts\Controllers\LoginHandler;
|
||||
use Bdp\Libs\DatabaseHandler;
|
||||
|
||||
|
||||
|
||||
require_once dirname(__FILE__) . '/pre_requires.php';
|
||||
require_once dirname(__FILE__) . '/environment.php';
|
||||
|
||||
require_once (BDP_LV_PLUGIN_DIR . '/lib/dompdf/autoload.php');
|
||||
require_once dirname(__FILE__) . '/pdfhandler.php';
|
||||
|
||||
require_once (BDP_LV_PLUGIN_DIR . '/includes/class-modelcommon.php');
|
||||
|
||||
require_once dirname(__FILE__) . '/spl.php';
|
||||
require_once dirname(__FILE__) . '/update.class.php';
|
||||
|
||||
@ -14,6 +23,8 @@ require_once BDP_LV_PLUGIN_DIR . 'includes/WpConfigEditor.class.php';
|
||||
require_once BDP_LV_PLUGIN_DIR . 'includes/DatabaseHandler.php';
|
||||
require_once (BDP_LV_PLUGIN_DIR . '/includes/roles.php');
|
||||
|
||||
|
||||
|
||||
require_once (BDP_LV_PLUGIN_DIR . '/includes/filters.php');
|
||||
|
||||
require_once (BDP_LV_PLUGIN_DIR . '/lib/ics-parser/Event.php');
|
||||
@ -48,6 +59,29 @@ function kompass_after_setup_theme()
|
||||
|
||||
}
|
||||
|
||||
function kompass_is_fullaged(string $birthday) : bool {
|
||||
$obj_birthday = \DateTime::createFromFormat('Y-m-d', $birthday);
|
||||
$today = new DateTime();
|
||||
$compare = date_diff($today, $obj_birthday);
|
||||
return $compare->y >= 18;
|
||||
}
|
||||
|
||||
function kompass_get_age(string $birthday) : int {
|
||||
$obj_birthday = \DateTime::createFromFormat('Y-m-d', $birthday);
|
||||
$today = new DateTime();
|
||||
$compare = date_diff($today, $obj_birthday);
|
||||
return $compare->y;
|
||||
}
|
||||
|
||||
function kompass_load_ajax_content() {
|
||||
$class = 'Bdp\\Modules\\' . $_REQUEST['module'] . '\\Controllers\\AjaxRouterController';
|
||||
if (!class_exists($class)) {
|
||||
wp_die('Invalid module call: Module=' . $_REQUEST['module']);
|
||||
}
|
||||
new $class();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$loginHandler = new LoginHandler();
|
||||
new BdpVersionChecker();
|
||||
|
@ -20,12 +20,15 @@ spl_autoload_register(function ($className) {
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$directoryPath = BDP_LV_PLUGIN_DIR . 'components/partials/';
|
||||
foreach (glob($directoryPath . '*.php') as $file) {
|
||||
require_once $file;
|
||||
}
|
||||
|
||||
$subdirs = ['includes', 'Controllers', 'Views', 'Requests', 'Actions'];
|
||||
$subdirs = ['includes', 'Controllers', 'Views', 'Requests', 'Actions', 'Models'];
|
||||
|
||||
foreach (scandir(BDP_LV_PLUGIN_DIR . 'modules/') as $curModule) {
|
||||
if ($curModule != '.' && $curModule != '..' && is_dir(BDP_LV_PLUGIN_DIR . 'modules/' . $curModule))
|
||||
@ -41,4 +44,6 @@ foreach (scandir(BDP_LV_PLUGIN_DIR . 'modules/') as $curModule) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user