Base setup for displaying groups and listing members
This commit is contained in:
parent
c85d93e06f
commit
abc3a2a0a0
@ -198,6 +198,7 @@ ul#adminmenu a.wp-has-current-submenu::after, ul#adminmenu > li.current > a.curr
|
||||
}
|
||||
|
||||
@media screen and (max-width: 782px) {
|
||||
|
||||
#adminmenu > li.menu-top:hover, #adminmenu > li.opensub > a.menu-top, #adminmenu > li > a.menu-top:focus {
|
||||
background-color: #fafafa;
|
||||
color: #1d4899 !important;
|
||||
@ -234,6 +235,13 @@ ul#adminmenu a.wp-has-current-submenu::after, ul#adminmenu > li.current > a.curr
|
||||
background-color: #fafafa !important;
|
||||
width: 285px !important;
|
||||
}
|
||||
|
||||
#wp-admin-bar-comments {
|
||||
display: none !important;
|
||||
}
|
||||
#wp-admin-bar-kompass_gruppen {
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
|
||||
#adminmenu div.wp-menu-name {
|
||||
|
@ -12,6 +12,7 @@
|
||||
* Text Domain: bdp-kompass
|
||||
*/
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenMain;
|
||||
use Bdp\Modules\KompassSettings\Controllers\SettingsPage as KomnpassSettings;
|
||||
use Bdp\Modules\LimitLoginAttempts\Controllers\OptionsPage as OptionsPageAlias;
|
||||
use Bdp\Modules\Security\Security;
|
||||
@ -28,6 +29,7 @@ function bdp_plugin_init() {
|
||||
bdp_kompass_load_plugin_textdomain();
|
||||
Security::ProhibitBots();
|
||||
Security::SetPageFilters();
|
||||
GruppenMain::setup();
|
||||
|
||||
if (null == get_option('kompass_already_installed', null)) {
|
||||
Seo::setup();
|
||||
@ -44,6 +46,7 @@ add_action('admin_menu', function () {
|
||||
bdp_kompass_load_plugin_textdomain();
|
||||
new OptionsPageAlias();
|
||||
new KomnpassSettings();
|
||||
new GruppenMain();
|
||||
});
|
||||
|
||||
|
||||
|
9
components/partials/telephon-link.php
Normal file
9
components/partials/telephon-link.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
function kompass_print_telephone_link(string $telephonnumber)
|
||||
{
|
||||
$numberInternational = $telephonnumber;
|
||||
if (str_starts_with($numberInternational, '0')) {
|
||||
$numberInternational = '+49' . substr($numberInternational,1);
|
||||
}
|
||||
echo '<a href="tel:' . $numberInternational . '">' . $telephonnumber . '</a>';
|
||||
}
|
46
includes/DatabaseHandler.php
Normal file
46
includes/DatabaseHandler.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Bdp\Libs;
|
||||
|
||||
class DatabaseHandler {
|
||||
public function readFromDb(string $table, array $conditions = []) : array {
|
||||
global $wpdb;
|
||||
$sql = 'SELECT * FROM ' . $wpdb->prefix . $table . $this->parseConditions($conditions);
|
||||
return $this->getResults( $sql );
|
||||
}
|
||||
|
||||
public function readSqlFromDb(string $tableName, string $preparedSql) : array
|
||||
{
|
||||
global $wpdb;
|
||||
$sql = str_replace('%tablename%', $wpdb->prefix . $tableName, $preparedSql );
|
||||
return $this->getResults($sql);
|
||||
}
|
||||
|
||||
public function countSqlRows(string $tableName, array $conditions = []) : int
|
||||
{
|
||||
global $wpdb;
|
||||
$sql = 'SELECT COUNT(*) as count_data FROM ' . $wpdb->prefix . $tableName . $this->parseConditions($conditions);
|
||||
$res = $this->getResults( $sql );
|
||||
$res = $res[0];
|
||||
return (int)$res->count_data;
|
||||
}
|
||||
|
||||
private function getResults(string $sql) : array
|
||||
{
|
||||
global $wpdb;
|
||||
return $wpdb->get_results($sql, OBJECT );
|
||||
}
|
||||
|
||||
private function parseConditions(array $conditionArray) : string
|
||||
{
|
||||
global $wpdb;
|
||||
$_tmpArr = [];
|
||||
foreach ($conditionArray as $key => $value) {
|
||||
$_tmpArr[] = '`' . $key .'` = "' . $wpdb->_real_escape($value) . '"';
|
||||
}
|
||||
|
||||
$returnString = implode(' AND ', $_tmpArr);
|
||||
return $returnString !== '' ? (' WHERE ' . $returnString) : '';
|
||||
}
|
||||
}
|
@ -20,6 +20,26 @@ if (isset($_POST['save_kompass_balist_list_type'])) {
|
||||
updateBlockOrAllowList($_POST);
|
||||
}
|
||||
|
||||
function add_custom_admin_bar_item() {
|
||||
global $wp_admin_bar;
|
||||
|
||||
// Ü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' => 'admin.php?page=kompass-groups',
|
||||
|
||||
add_action('wp_head', 'kompass_seo_add_verfications');
|
||||
];
|
||||
|
||||
// Das benutzerdefinierte Element zur Admin-Leiste hinzufügen
|
||||
$wp_admin_bar->add_node( $args );
|
||||
}
|
||||
}
|
||||
|
||||
// Die Funktion aufrufen, um das benutzerdefinierte Element zur Admin-Leiste hinzuzufügen
|
||||
add_action( 'admin_bar_menu', 'add_custom_admin_bar_item', 50 );
|
||||
|
||||
add_action('wp_head', 'kompass_seo_add_verifications' );
|
@ -60,24 +60,17 @@ function bdp_add_menu_mein_lv() {
|
||||
add_menu_page(
|
||||
'Mein BdP',
|
||||
'BdP',
|
||||
'manage_options',
|
||||
'show_bdp',
|
||||
$mainSlug,
|
||||
'',
|
||||
BDP_LV_PLUGIN_URL . '/icon.png',
|
||||
3
|
||||
);
|
||||
|
||||
/*add_submenu_page($mainSlug,
|
||||
'calendar_settings',
|
||||
'Kalender-Einstellungen',
|
||||
'manage_options',
|
||||
$moduleLoad . 'calendar'
|
||||
);*/
|
||||
|
||||
add_submenu_page($mainSlug,
|
||||
'calendar_settings',
|
||||
'Über',
|
||||
'manage_options',
|
||||
'Über',
|
||||
'show_bdp',
|
||||
$moduleLoad . 'about'
|
||||
);
|
||||
}
|
||||
|
@ -6,3 +6,4 @@ require_once (ABSPATH . '/wp-includes/pluggable.php');
|
||||
require_once (ABSPATH . '/wp-includes/capabilities.php');
|
||||
require_once (ABSPATH . '/wp-admin/includes/template.php');
|
||||
require_once (ABSPATH . '/wp-admin/includes/file.php');
|
||||
require_once( ABSPATH . '/wp-admin/includes/upgrade.php' );
|
@ -43,6 +43,7 @@ function kompass_get_capa_stafue() : array
|
||||
function kompass_get_capa_aktionsleitung() : array
|
||||
{
|
||||
return [
|
||||
'show_bdp' => true,
|
||||
'create_event_teilis' => true,
|
||||
'edit_event_teilis' => true,
|
||||
'delete_event_teilis' => true,
|
||||
@ -53,6 +54,8 @@ function kompass_get_capa_aktionsleitung() : array
|
||||
function kompass_get_capa_grufue() : array
|
||||
{
|
||||
return [
|
||||
'show_bdp' => true,
|
||||
'show_groups' => true,
|
||||
'create_teilis' => true,
|
||||
'edit_teilis' => true,
|
||||
'send_mails' => true
|
||||
|
@ -1,9 +1,7 @@
|
||||
<?php
|
||||
if ( ! defined( 'WP_PLUGIN_DIR' ) ) { // Abspath to wp-content/plugins
|
||||
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // Full path, no trailing slash.
|
||||
}
|
||||
|
||||
use Bdp\Modules\LimitLoginAttempts\Controllers\LoginHandler;
|
||||
use Bdp\Libs\DatabaseHandler;
|
||||
|
||||
|
||||
|
||||
require_once dirname(__FILE__) . '/pre_requires.php';
|
||||
@ -13,6 +11,7 @@ require_once dirname(__FILE__) . '/update.class.php';
|
||||
|
||||
require_once BDP_LV_PLUGIN_DIR . 'includes/FileAccess.class.php';
|
||||
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');
|
||||
@ -27,6 +26,8 @@ require_once (BDP_LV_PLUGIN_DIR . '/includes/frontend-functions.php');
|
||||
require_once (BDP_LV_PLUGIN_DIR . '/modules/calendar/Views/settings-form.php');
|
||||
require_once (BDP_LV_PLUGIN_DIR . '/modules/security/security.php');
|
||||
|
||||
|
||||
$dbHandler = new DatabaseHandler();
|
||||
function kompass_admin_init()
|
||||
{
|
||||
kompass_settings_validators();
|
||||
|
@ -27,7 +27,7 @@ foreach (glob($directoryPath . '*.php') as $file) {
|
||||
|
||||
|
||||
|
||||
$modules = ['KompassSettings', 'LimitLoginAttempts', 'PasswordStrength', 'seo'];
|
||||
$modules = ['KompassSettings', 'LimitLoginAttempts', 'PasswordStrength', 'seo', 'Gruppen'];
|
||||
$subdirs = ['includes', 'Controllers', 'Views'];
|
||||
|
||||
foreach ($modules as $curModule) {
|
||||
|
21
lib/database/kompass_stammesgruppen_gruppen.sql
Normal file
21
lib/database/kompass_stammesgruppen_gruppen.sql
Normal file
@ -0,0 +1,21 @@
|
||||
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;
|
48
lib/database/kompass_stammesgruppen_teilis.sql
Normal file
48
lib/database/kompass_stammesgruppen_teilis.sql
Normal file
@ -0,0 +1,48 @@
|
||||
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,
|
||||
`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,
|
||||
`allergien` varchar(2048) NOT NULL,
|
||||
`abholung` enum('alone','parents','other','') NOT NULL,
|
||||
`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;
|
86
modules/Gruppen/Controllers/MainController.php
Normal file
86
modules/Gruppen/Controllers/MainController.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class MainController
|
||||
{
|
||||
public const KOMPASS_STAMMESGRUPPEN_GRUPPEN = 'kompass_stammesgruppen_gruppen';
|
||||
public const KOMPASS_STAMMESGRUPPEN_TEILIS = 'kompass_stammesgruppen_teilis';
|
||||
|
||||
public static function setup()
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$charset = $wpdb->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':
|
||||
$this->searchMember();
|
||||
break;
|
||||
|
||||
default:
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
} else {
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
}
|
||||
|
||||
private function searchMember()
|
||||
{
|
||||
global $dbHandler;
|
||||
$members = $dbHandler->readSqlFromDb(self::KOMPASS_STAMMESGRUPPEN_TEILIS,
|
||||
'SELECT * FROM %tablename% WHERE CONCAT(`vorname`, " " , `nachname`) LIKE "%' . $_POST['member_name'] . '%"');
|
||||
$this->printMembers($members);
|
||||
}
|
||||
|
||||
private function printMembers(array $memberList)
|
||||
{
|
||||
if (count($memberList) === 0) {
|
||||
exit;
|
||||
}
|
||||
kompass_print_gruppen_members($memberList);
|
||||
}
|
||||
|
||||
}
|
42
modules/Gruppen/Views/GruppenOverview.php
Normal file
42
modules/Gruppen/Views/GruppenOverview.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenController;
|
||||
|
||||
function kompass_print_gruppen_overview()
|
||||
{
|
||||
global $dbHandler;
|
||||
?>
|
||||
|
||||
<form method="post" action="admin.php?page=kompass-groups">
|
||||
<p style="width: 100%; text-align: right">
|
||||
<input type="hidden" name="action" value="searchmember">
|
||||
<input type="text" name="member_name" style="width: 500px;"
|
||||
placeholder="<?=__('Search for member', BDP_LV_PLUGIN_SLUG); ?>" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
|
||||
<table class="wp-list-table widefat fixed striped table-view-list" id="myTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="manage-column column-name"><?= __('Group Name', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
<th scope="col" class="manage-column column-name"><?= __('Number Members', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
<th style="width: 100px;" class="manage-column column-name"><?= __('Actions', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
foreach ($dbHandler->readFromDb( GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN) as $currentGruppe) {
|
||||
echo '<tr>';
|
||||
echo '<td>' . $currentGruppe->gruppen_name .'</td>';
|
||||
echo '<td>' . $dbHandler->countSqlRows(GruppenController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $currentGruppe->id]) .'</td>';
|
||||
echo '<td><a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">' .
|
||||
__('Show Members', BDP_LV_PLUGIN_SLUG) . '</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
65
modules/Gruppen/Views/PrintMembers.php
Normal file
65
modules/Gruppen/Views/PrintMembers.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
function kompass_print_gruppen_members(array $memberList)
|
||||
{
|
||||
?>
|
||||
<p style="width: 100%; text-align: right">
|
||||
<input type="text" id="searchInput"
|
||||
onkeyup="searchTable('myTable', this)"
|
||||
placeholder="<?=__('Filter member', BDP_LV_PLUGIN_SLUG); ?>">
|
||||
</p>
|
||||
<table class="wp-list-table widefat fixed striped table-view-list" id="myTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="manage-column column-name"><?= __('Name', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
<th style="width: 100px;" class="manage-column column-name"><?= __('Actions', BDP_LV_PLUGIN_SLUG); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($memberList as $curMember) {
|
||||
?>
|
||||
<tr>
|
||||
<td> <?= $curMember->vorname . ' ' . $curMember->nachname ?>
|
||||
<br />
|
||||
<?php kompass_gruppen_printTelephonNumbers($curMember); ?>
|
||||
<br />
|
||||
<?= __('Allergies:', BDP_LV_PLUGIN_SLUG) . ' ' .
|
||||
($curMember->allergien != '' ? $curMember->allergien : '---'); ?>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
|
||||
<?= __('Show details', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<br />
|
||||
|
||||
<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
|
||||
<?= __('Send E-Mail', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<br />
|
||||
|
||||
<?php
|
||||
if ( current_user_can( 'delete_teilis' ) ) {
|
||||
?>
|
||||
<a href="admin.php?page=bdp-kompass-limit-login-attempts&action=removeFromList">
|
||||
<?= __('Delete', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
}
|
||||
|
||||
function kompass_gruppen_printTelephonNumbers(stdClass $curMember)
|
||||
{
|
||||
kompass_print_telephone_link($curMember->telefon_1);
|
||||
if ($curMember->telefon_2 != '') {
|
||||
echo ' // ';
|
||||
kompass_print_telephone_link( $curMember->telefon_2 );
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
function kompass_seo_add_verfications() {
|
||||
function kompass_seo_add_verifications() {
|
||||
$googleVerification = get_option('kompass_seo_google_verification', '');
|
||||
if ('' !== $googleVerification) {
|
||||
echo '<meta name="google-site-verification" content="' . $googleVerification . '" />' . "\n";
|
||||
|
Loading…
Reference in New Issue
Block a user