Base setup for displaying groups and listing members
This commit is contained in:
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) {
|
||||
|
Reference in New Issue
Block a user