Compare commits
4 Commits
c85d93e06f
...
epic-teili
Author | SHA1 | Date | |
---|---|---|---|
a66f2d2422 | |||
e9740e86b5 | |||
5e766bc2e5 | |||
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,8 +12,10 @@
|
||||
* 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\Mail\Controllers\MailController;
|
||||
use Bdp\Modules\Security\Security;
|
||||
use Bdp\Modules\Seo\Seo;
|
||||
|
||||
@ -28,6 +30,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 +47,8 @@ add_action('admin_menu', function () {
|
||||
bdp_kompass_load_plugin_textdomain();
|
||||
new OptionsPageAlias();
|
||||
new KomnpassSettings();
|
||||
new GruppenMain();
|
||||
new MailController();
|
||||
});
|
||||
|
||||
|
||||
|
24
components/partials/date-element.php
Normal file
24
components/partials/date-element.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
function _kompass_print_datebox($settingName, $settingValue, $style = '') {
|
||||
echo '<input style="' . $style . '" type="date" name="' . $settingName . '" value="' . $settingValue. '" />';
|
||||
if (defined('WP_DEBUG') && WP_DEBUG == true) {
|
||||
echo '<br />' . $settingName;
|
||||
}
|
||||
}
|
||||
|
||||
function kompass_print_datebox(array $args) {
|
||||
if (!isset($args['setting'])) {
|
||||
wp_die('Missing argument setting at text-element ' . print_r($args, true));
|
||||
}
|
||||
$setting = get_option($args['setting'], null);
|
||||
$setting = $setting ?? ( $args['value'] ?? '' );
|
||||
|
||||
$style = isset($args['style']) ? $args['style'] : '';
|
||||
|
||||
$value = esc_attr($setting);
|
||||
|
||||
if ($value === null && isset($args['value'])) {
|
||||
$value = $args['value'];
|
||||
}
|
||||
_kompass_print_datebox($args['setting'], $value, $style);
|
||||
}
|
18
components/partials/form-start.php
Normal file
18
components/partials/form-start.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
function kompass_prepare_form($params = [])
|
||||
{
|
||||
if (isset($params['page'])) {
|
||||
echo ' <form method="post" action="admin.php?page=' .$params['page'] . '">';
|
||||
}
|
||||
|
||||
echo '<input type="hidden" name="update_options" value="true" />';
|
||||
foreach ($params as $key => $value) {
|
||||
echo '<input type="hidden" name="' . $key . '" value="' . $value . '">';
|
||||
}
|
||||
}
|
||||
|
||||
function kompass_close_form(string $buttonText)
|
||||
{
|
||||
submit_button($buttonText,'button');
|
||||
echo '</form>';
|
||||
}
|
8
components/partials/message-box.php
Normal file
8
components/partials/message-box.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
function kompass_print_message_box(string $message, string $type = 'success')
|
||||
{
|
||||
echo '<div class="notice notice-' . $type .'" style="padding: 5px 10px;">';
|
||||
echo $message;
|
||||
echo '</div>';
|
||||
|
||||
}
|
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>';
|
||||
}
|
@ -1,13 +1,18 @@
|
||||
<?php
|
||||
function kompass_print_textbox($settingName, $settingValue, $style = '') {
|
||||
function _kompass_print_textbox($settingName, $settingValue, $style = '') {
|
||||
echo '<input style="' . $style . '" type="text" name="' . $settingName . '" value="' . $settingValue. '" />';
|
||||
if (defined('WP_DEBUG') && WP_DEBUG == true) {
|
||||
echo '<br />' . $settingName;
|
||||
}
|
||||
}
|
||||
|
||||
function _kompass_limit_logins_settings_callback(array $args) {
|
||||
function kompass_print_textbox(array $args) {
|
||||
if (!isset($args['setting'])) {
|
||||
wp_die('Missing argument setting at text-element ' . print_r($args, true));
|
||||
}
|
||||
$setting = get_option($args['setting'], null);
|
||||
$setting = $setting ?? ( $args['value'] ?? '' );
|
||||
|
||||
$style = isset($args['style']) ? $args['style'] : '';
|
||||
|
||||
$value = esc_attr($setting);
|
||||
@ -15,5 +20,8 @@ function _kompass_limit_logins_settings_callback(array $args) {
|
||||
$value = (int)$value / (int)$args['unit_division'];
|
||||
}
|
||||
|
||||
kompass_print_textbox($args['setting'], $value, $style);
|
||||
if ($value === null && isset($args['value'])) {
|
||||
$value = $args['value'];
|
||||
}
|
||||
_kompass_print_textbox($args['setting'], $value, $style);
|
||||
}
|
||||
|
61
includes/DatabaseHandler.php
Normal file
61
includes/DatabaseHandler.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?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 insertRows(string $tableName, array $newData) : int
|
||||
{
|
||||
global $wpdb;
|
||||
$tableName = $wpdb->prefix . $tableName;
|
||||
$wpdb->insert( $tableName, $newData );
|
||||
return $wpdb->insert_id;
|
||||
}
|
||||
|
||||
public function updateRows(string $tableName, array $newData, $conditions = [])
|
||||
{
|
||||
global $wpdb;
|
||||
$tableName = $wpdb->prefix . $tableName;
|
||||
$wpdb->update( $tableName, $newData, $conditions );
|
||||
}
|
||||
|
||||
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' => get_admin_url() . '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();
|
||||
|
@ -25,16 +25,20 @@ foreach (glob($directoryPath . '*.php') as $file) {
|
||||
require_once $file;
|
||||
}
|
||||
|
||||
$subdirs = ['includes', 'Controllers', 'Views', 'Requests', 'Actions'];
|
||||
|
||||
foreach (scandir(BDP_LV_PLUGIN_DIR . 'modules/') as $curModule) {
|
||||
if ($curModule != '.' && $curModule != '..' && is_dir(BDP_LV_PLUGIN_DIR . 'modules/' . $curModule))
|
||||
{
|
||||
if ($curModule == 'calendar') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$modules = ['KompassSettings', 'LimitLoginAttempts', 'PasswordStrength', 'seo'];
|
||||
$subdirs = ['includes', 'Controllers', 'Views'];
|
||||
|
||||
foreach ($modules as $curModule) {
|
||||
foreach ($subdirs as $dir) {
|
||||
$directoryPath = BDP_LV_PLUGIN_DIR . 'modules/' . $curModule . '/' . $dir . '/';
|
||||
foreach (glob($directoryPath . '*.php') as $file) {
|
||||
require_once $file;
|
||||
}
|
||||
}
|
||||
foreach ($subdirs as $dir) {
|
||||
$directoryPath = BDP_LV_PLUGIN_DIR . 'modules/' . $curModule . '/' . $dir . '/';
|
||||
foreach (glob($directoryPath . '*.php') as $file) {
|
||||
require_once $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
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;
|
49
lib/database/kompass_stammesgruppen_teilis.sql
Normal file
49
lib/database/kompass_stammesgruppen_teilis.sql
Normal file
@ -0,0 +1,49 @@
|
||||
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;
|
18
modules/Gruppen/Actions/CreateGroupAction.php
Normal file
18
modules/Gruppen/Actions/CreateGroupAction.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class CreateGroupAction
|
||||
{
|
||||
public static function execute(array $newData)
|
||||
{
|
||||
global $dbHandler;
|
||||
if (!current_user_can('create_groups')) {
|
||||
kompass_print_message_box(__('You are not allowed to create a group', BDP_LV_PLUGIN_SLUG), 'error');
|
||||
}
|
||||
|
||||
global $dbHandler;
|
||||
$dbHandler->insertRows(MainController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, $newData);
|
||||
kompass_print_message_box(__('The group was created.', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
}
|
21
modules/Gruppen/Actions/CreateGroupMemberAction.php
Normal file
21
modules/Gruppen/Actions/CreateGroupMemberAction.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class CreateGroupMemberAction
|
||||
{
|
||||
public static function execute(array $userData) : int
|
||||
{
|
||||
global $dbHandler;
|
||||
if (!current_user_can('create_teilis')) {
|
||||
kompass_print_message_box(__('You are not allowed to add a member', BDP_LV_PLUGIN_SLUG), 'error');
|
||||
}
|
||||
|
||||
global $dbHandler;
|
||||
|
||||
$userData['gruppe_id'] = 1;
|
||||
|
||||
kompass_print_message_box(__('The member was added.', BDP_LV_PLUGIN_SLUG));
|
||||
return $dbHandler->insertRows(MainController::KOMPASS_STAMMESGRUPPEN_TEILIS, $userData);
|
||||
}
|
||||
}
|
37
modules/Gruppen/Actions/CreateGroupMemberDataAction.php
Normal file
37
modules/Gruppen/Actions/CreateGroupMemberDataAction.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class CreateGroupMemberDataAction
|
||||
{
|
||||
public static function execute(array $userData) : array
|
||||
{
|
||||
$dataKeys = [
|
||||
'vorname' => 'kompass_group_member_firstname',
|
||||
'nachname' => 'kompass_group_member_lastname',
|
||||
'geburtsdatum' => 'kompass_group_member_birthday',
|
||||
'ansprechpartner' => 'kompass_group_member_parents',
|
||||
'email_1' => 'kompass_group_member_email_1',
|
||||
'email_2' => 'kompass_group_member_email_2',
|
||||
'telefon_1' => 'kompass_group_member_phone_1',
|
||||
'telefon_2' => 'kompass_group_member_phone_2',
|
||||
];
|
||||
|
||||
$return = ['data' => [], 'rawData' => [], 'errors' => []];
|
||||
foreach ($dataKeys as $dbKey => $formKey) {
|
||||
$value = trim($userData[$formKey]);
|
||||
$return['rawData'][$formKey] = $value;
|
||||
if ($dbKey === 'email_2' || $dbKey === 'telefon_2') {
|
||||
$return['data'][$dbKey] = $value;
|
||||
} else {
|
||||
if ( $value === '' ) {
|
||||
$return['errors'][] = sprintf(__( 'The field "%s" is required.', BDP_LV_PLUGIN_SLUG ), $dbKey);
|
||||
} else {
|
||||
$return['data'][ $dbKey ] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
19
modules/Gruppen/Actions/UpdateGroupAction.php
Normal file
19
modules/Gruppen/Actions/UpdateGroupAction.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class UpdateGroupAction
|
||||
{
|
||||
public static function execute(array $newData, int $groupId)
|
||||
{
|
||||
global $dbHandler;
|
||||
if (!current_user_can('edit_groups')) {
|
||||
kompass_print_message_box(__('You are not allowed to update a group', BDP_LV_PLUGIN_SLUG), 'error');
|
||||
}
|
||||
|
||||
global $dbHandler;
|
||||
$dbHandler->updateRows(MainController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, $newData, ['id' => $groupId]);
|
||||
|
||||
kompass_print_message_box(__('The group was updated.', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
}
|
17
modules/Gruppen/Controllers/CreateGroupController.php
Normal file
17
modules/Gruppen/Controllers/CreateGroupController.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class CreateGroupController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if (current_user_can('create_groups')) {
|
||||
kompass_create_group_form();
|
||||
} else {
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
}
|
||||
}
|
17
modules/Gruppen/Controllers/CreateMemberController.php
Normal file
17
modules/Gruppen/Controllers/CreateMemberController.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class CreateMemberController
|
||||
{
|
||||
public function __construct(array $prefilledData = [])
|
||||
{
|
||||
if (current_user_can('create_teilis')) {
|
||||
kompass_create_group_member_form($prefilledData);
|
||||
} else {
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
}
|
||||
}
|
139
modules/Gruppen/Controllers/MainController.php
Normal file
139
modules/Gruppen/Controllers/MainController.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
use SearchMemberRequest;
|
||||
|
||||
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':
|
||||
$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('<br />', $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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
13
modules/Gruppen/Controllers/PrintGroupsController.php
Normal file
13
modules/Gruppen/Controllers/PrintGroupsController.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class PrintGroupsController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
kompass_print_gruppen_overview();
|
||||
}
|
||||
}
|
15
modules/Gruppen/Controllers/PrintMemberController.php
Normal file
15
modules/Gruppen/Controllers/PrintMemberController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class PrintMemberController
|
||||
{
|
||||
public function __construct(int $memberId)
|
||||
{
|
||||
global $dbHandler;
|
||||
$member = $dbHandler->readFromDb(MainController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['id' => $memberId]);
|
||||
echo '<pre>';print_r($member);die();
|
||||
}
|
||||
}
|
16
modules/Gruppen/Controllers/PrintMemberListController.php
Normal file
16
modules/Gruppen/Controllers/PrintMemberListController.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Bdp\Modules\Gruppen\Controllers;
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
|
||||
class PrintMemberListController
|
||||
{
|
||||
public function __construct(array $memberList)
|
||||
{
|
||||
if (count($memberList) === 0) {
|
||||
exit;
|
||||
}
|
||||
kompass_print_gruppen_members($memberList);
|
||||
}
|
||||
}
|
12
modules/Gruppen/Requests/ListMemberRequest.php
Normal file
12
modules/Gruppen/Requests/ListMemberRequest.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class ListMemberRequest
|
||||
{
|
||||
public static function listForGroup(int $groupId) : array
|
||||
{
|
||||
global $dbHandler;
|
||||
return $dbHandler->readFromDb(MainController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $groupId]);
|
||||
}
|
||||
}
|
15
modules/Gruppen/Requests/SearchMemberRequest.php
Normal file
15
modules/Gruppen/Requests/SearchMemberRequest.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController;
|
||||
|
||||
class SearchMemberRequest
|
||||
{
|
||||
public static function listByName(string $name) : array
|
||||
{
|
||||
global $dbHandler;
|
||||
return $dbHandler->readSqlFromDb( MainController::KOMPASS_STAMMESGRUPPEN_TEILIS,
|
||||
'SELECT * FROM %tablename% WHERE CONCAT(`vorname`, " " , `nachname`) LIKE "%' . $name . '%"');
|
||||
|
||||
|
||||
}
|
||||
}
|
64
modules/Gruppen/Views/CreateGroupForm.php
Normal file
64
modules/Gruppen/Views/CreateGroupForm.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenController;
|
||||
|
||||
function kompass_edit_group_form(int $groupId)
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-group';
|
||||
$group = $dbHandler->readFromDb(GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, ['id' => $groupId]);
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Edit Group', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'update-group',
|
||||
'page' => 'kompass-groups',
|
||||
'group_id' => $groupId
|
||||
]
|
||||
);
|
||||
|
||||
_kompass_group_display_elements($page, $group[0]);
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-create-group');
|
||||
kompass_close_form(__('Update', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function kompass_create_group_form()
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-group';
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Create Group', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'create-group',
|
||||
'page' => 'kompass-groups'
|
||||
]
|
||||
);
|
||||
_kompass_group_display_elements($page);
|
||||
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-create-group');
|
||||
kompass_close_form(__('Create', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function _kompass_group_display_elements(string $page, stdClass $currentGroup = null)
|
||||
{
|
||||
$value = '';
|
||||
if (null !== $currentGroup) {
|
||||
$value = $currentGroup->gruppen_name;
|
||||
}
|
||||
|
||||
add_settings_field(
|
||||
'kompass_group_field_1',
|
||||
__('Group Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_groups_group_name',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
}
|
131
modules/Gruppen/Views/CreateMemberForm.php
Normal file
131
modules/Gruppen/Views/CreateMemberForm.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
use Bdp\Modules\Gruppen\Controllers\MainController as GruppenController;
|
||||
|
||||
function kompass_edit_group_member_form(int $groupId)
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-group';
|
||||
$group = $dbHandler->readFromDb(GruppenController::KOMPASS_STAMMESGRUPPEN_GRUPPEN, ['id' => $groupId]);
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Edit Group', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'update-group',
|
||||
'page' => 'kompass-groups',
|
||||
'group_id' => $groupId
|
||||
]
|
||||
);
|
||||
|
||||
_kompass_group_display_elements($page, $group[0]);
|
||||
do_settings_sections(BDP_LV_PLUGIN_SLUG . '-create-group');
|
||||
kompass_close_form(__('Update', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function kompass_create_group_member_form(array $prefilledData = [])
|
||||
{
|
||||
global $dbHandler;
|
||||
$page = BDP_LV_PLUGIN_SLUG . '-create-member';
|
||||
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Add Member', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_prepare_form',
|
||||
$page,
|
||||
[
|
||||
'action' => 'create-member',
|
||||
'page' => 'kompass-groups'
|
||||
]
|
||||
);
|
||||
_kompass_group_member_display_elements($page, $prefilledData);
|
||||
|
||||
do_settings_sections($page);
|
||||
kompass_close_form(__('Add member', BDP_LV_PLUGIN_SLUG));
|
||||
}
|
||||
|
||||
function _kompass_group_member_display_elements(string $page, array $prefilledElements = [])
|
||||
{
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_firstname'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_1',
|
||||
__('First Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_firstname',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_lastname'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_2',
|
||||
__('Last Name', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_lastname',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_birthday'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_3',
|
||||
__('Birthday', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_datebox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_birthday',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_parents'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_4',
|
||||
__('Contact person', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_parents',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_email_1'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_5',
|
||||
__('E-Mail', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_email_1',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_email_2'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_6',
|
||||
__('Alternative E-Mail', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_email_2',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_phone_1'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_7',
|
||||
__('Telephone', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_phone_1',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
|
||||
$value = $prefilledElements['kompass_group_member_phone_2'] ?? '';
|
||||
add_settings_field(
|
||||
'kompass_group_member_field_8',
|
||||
__('Alternative Telephone', BDP_LV_PLUGIN_SLUG),
|
||||
'kompass_print_textbox',
|
||||
$page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_group_member_phone_2',
|
||||
'value' => $value, 'style' => 'width: 512px']);
|
||||
}
|
95
modules/Gruppen/Views/GruppenOverview.php
Normal file
95
modules/Gruppen/Views/GruppenOverview.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?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 member', BDP_LV_PLUGIN_SLUG); ?>" />
|
||||
<input type="submit" class="button" value="<?= __('Search', 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) {
|
||||
$participantCount = $dbHandler->countSqlRows(GruppenController::KOMPASS_STAMMESGRUPPEN_TEILIS, ['gruppe_id' => $currentGruppe->id]);
|
||||
echo '<tr>';
|
||||
echo '<td>' . $currentGruppe->gruppen_name .'</td>';
|
||||
echo '<td>' . $participantCount . '</td>';
|
||||
echo '<td> ' . kompass_get_group_actions($currentGruppe->id, $participantCount ) .'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
echo '<p>';
|
||||
if ( current_user_can( 'send_mails' ) ) {
|
||||
echo '<a class="button" href="' . admin_url('admin.php?page=kompass-groups') . '&action=compose-mail&group-id=0">' .
|
||||
__( 'Mail to multiple groups', BDP_LV_PLUGIN_SLUG ) . '</a> ';
|
||||
}
|
||||
|
||||
if (current_user_can('create_teilis')) {
|
||||
echo '<a class="button" href="' . admin_url('admin.php?page=kompass-groups') . '&action=new-member">' .
|
||||
__( 'New Member', BDP_LV_PLUGIN_SLUG ) . '</a> ';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_teilis' ) ) {
|
||||
?>
|
||||
<a class="button" href="admin.php?page=kompass-groups&action=create_group_form">
|
||||
<?= __('Create Group', BDP_LV_PLUGIN_SLUG); ?></a>
|
||||
<?php
|
||||
}
|
||||
echo '</p>';
|
||||
|
||||
// Gutenberg-Editor einbinden
|
||||
wp_editor( '', 'gutenberg_content', array(
|
||||
'textarea_name' => 'gutenberg_content',
|
||||
// 'media_buttons' => false, // Deaktivieren der Medien-Upload-Schaltfläche
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
function kompass_get_group_actions(int $groupId, int $participantCount) : string
|
||||
{
|
||||
$elements = [];
|
||||
if ($participantCount > 0) {
|
||||
$elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=show-members&group-id=' .$groupId .'">' .
|
||||
__('Show Members', BDP_LV_PLUGIN_SLUG) . '</a>';
|
||||
if (current_user_can('send_mails')) {
|
||||
$elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=compose-mail&group-id=' .$groupId .'">' .
|
||||
__( 'Mail to group', BDP_LV_PLUGIN_SLUG ) . '</a>';
|
||||
}
|
||||
} else {
|
||||
if (current_user_can('delete_groups')) {
|
||||
$elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=delete-group&group-id=' .$groupId .'">' .
|
||||
__('Delete', BDP_LV_PLUGIN_SLUG) . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if (current_user_can('edit_groups')) {
|
||||
$elements[] = '<a href="' . admin_url('admin.php?page=kompass-groups') . '&action=edit-group&group-id=' .$groupId .'">' .
|
||||
__('Edit', BDP_LV_PLUGIN_SLUG) . '</a>';
|
||||
}
|
||||
|
||||
return implode('<br />' , $elements);
|
||||
|
||||
}
|
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_url('admin.php?page=kompass-groups') . '&action=show-member&member-id=' .$curMember->id; ?>">
|
||||
<?= __('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 );
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ class SettingsPage
|
||||
switch ($tab) {
|
||||
case 'tab1':
|
||||
update_option('bdp_calendar_categories', json_encode($_POST['category']));
|
||||
update_option('bdp_calendar_source_url', $_POST['ical_url']);
|
||||
update_option('bdp_calendar_source_url', $_POST['bdp_calendar_source_url']);
|
||||
$showMessage = __('The settings were saved.', BDP_LV_PLUGIN_SLUG);
|
||||
break;
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
<?php
|
||||
|
||||
function custom_settings_section_callback() {
|
||||
echo '<input type="hidden" name="update_options" value="true" />';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -19,7 +16,7 @@ bdp_kompass_load_plugin_textdomain();
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Options', BDP_LV_PLUGIN_SLUG),
|
||||
'custom_settings_section_callback',
|
||||
'kompass_prepare_form',
|
||||
BDP_LV_PLUGIN_SLUG . '-limit-login-attempts'
|
||||
);
|
||||
|
||||
@ -34,7 +31,7 @@ $settings_page = BDP_LV_PLUGIN_SLUG . '-limit-login-attempts';
|
||||
add_settings_field(
|
||||
'kompass_lla_1',
|
||||
__('Maximum reps until lockout', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_allowed_retries']);
|
||||
@ -42,7 +39,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_lla_2',
|
||||
__('Duration of lockout (in minutes)', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_lockout_duration', 'unit_division' => 60 ]);
|
||||
@ -50,7 +47,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_lla_3',
|
||||
__('Maximum number of lockouts', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_allowed_lockouts']);
|
||||
@ -58,7 +55,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_lla_4',
|
||||
__('Long-term duration (in hours)', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_long_duration', 'unit_division' => 3600]);
|
||||
@ -98,7 +95,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_lla_9',
|
||||
__('Failed attempts until notification', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_limit_login_notify_email_after']);
|
||||
|
10
modules/Mail/Controllers/MailCompose.php
Normal file
10
modules/Mail/Controllers/MailCompose.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace Bdp\Modules\Mail\Controllers;
|
||||
|
||||
class MailCompose
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
kompass_print_mail_compose();
|
||||
}
|
||||
}
|
153
modules/Mail/Controllers/MailController.php
Normal file
153
modules/Mail/Controllers/MailController.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
namespace Bdp\Modules\Mail\Controllers;
|
||||
|
||||
|
||||
use Bdp\Libs\FileAccess;
|
||||
use SearchMemberRequest;
|
||||
|
||||
class MailController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
add_menu_page(
|
||||
__('E-Mail', BDP_LV_PLUGIN_SLUG),
|
||||
__('E-Mail', BDP_LV_PLUGIN_SLUG),
|
||||
'send_mails',
|
||||
'kompass-mail',
|
||||
[$this, 'router'],
|
||||
'dashicons-email',
|
||||
4
|
||||
);
|
||||
|
||||
/*$mailCompose = new MailCompose();
|
||||
add_submenu_page(
|
||||
'kompass-mail',
|
||||
__('Templates', BDP_LV_PLUGIN_SLUG),
|
||||
__('Templates', BDP_LV_PLUGIN_SLUG),
|
||||
'send_mails',
|
||||
'kompass-mail-compose',
|
||||
[$mailCompose, '__construct'],
|
||||
1);*/
|
||||
}
|
||||
|
||||
public function router()
|
||||
{
|
||||
if (isset($_REQUEST['action'])) {
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'send-email':
|
||||
// SMTP-Konfiguration
|
||||
$smtp_host = 'bdp.mein-verein.online'; // SMTP-Host
|
||||
$smtp_port = 25; // SMTP-Port
|
||||
$smtp_username = 'noreply@mareike.sachsen.pfadfinden.de'; // SMTP-Benutzername
|
||||
$smtp_password = 'fwJ_wxbW9G45'; // SMTP-Passwort
|
||||
$smtp_secure = 'tls'; // Verschlüsselung (tls oder ssl)
|
||||
|
||||
// Einstellungen für wp_mail ändern
|
||||
add_action( 'phpmailer_init', function( $phpmailer ) use ( $smtp_host, $smtp_port, $smtp_username, $smtp_password, $smtp_secure ) {
|
||||
$phpmailer->isSMTP();
|
||||
$phpmailer->Host = $smtp_host;
|
||||
$phpmailer->Port = $smtp_port;
|
||||
$phpmailer->SMTPAuth = true;
|
||||
$phpmailer->Username = $smtp_username;
|
||||
$phpmailer->Password = $smtp_password;
|
||||
$phpmailer->setFrom('info@pfadfinden-halle.de', 'Pfadfinden - Halle');
|
||||
#$phpmailer->SMTPSecure = $smtp_secure;
|
||||
} );
|
||||
|
||||
// Senden Sie die E-Mail
|
||||
$sent = wp_mail($_REQUEST['mail-to'],$_REQUEST['mail-subject'],$_REQUEST['mail-text'],
|
||||
['Reply-To: ' . $_REQUEST['mail-from'], 'Content-Type: text/html; charset=UTF-8']);
|
||||
|
||||
// Überprüfen, ob die E-Mail erfolgreich gesendet wurde
|
||||
if ( $sent ) {
|
||||
echo '<p>E-Mail wurde erfolgreich gesendet!</p>';
|
||||
} else {
|
||||
echo '<p>Fehler beim Senden der E-Mail!</p>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
echo $_REQUEST['mail-to'] . '<br />';
|
||||
echo $_REQUEST['mail-text'];
|
||||
|
||||
echo 'mail gesendet';
|
||||
|
||||
break;
|
||||
|
||||
case 'create_group_form':
|
||||
new \Bdp\Modules\Gruppen\Controllers\CreateGroupController();
|
||||
break;
|
||||
|
||||
case 'update-group':
|
||||
\UpdateGroupAction::execute(['gruppen_name' => $_REQUEST['kompass_groups_group_name']],
|
||||
(int)$_REQUEST['group_id']);
|
||||
|
||||
new \Bdp\Modules\Gruppen\Controllers\PrintGroupsController();
|
||||
break;
|
||||
|
||||
case 'create-group':
|
||||
$data = ['gruppen_name' => $_REQUEST['kompass_groups_group_name']];
|
||||
\CreateGroupAction::execute($data);
|
||||
new \Bdp\Modules\Gruppen\Controllers\PrintGroupsController();
|
||||
break;
|
||||
|
||||
case 'new-member':
|
||||
new \Bdp\Modules\Gruppen\Controllers\CreateMemberController();
|
||||
break;
|
||||
|
||||
case 'create-member':
|
||||
$userData = \CreateGroupMemberDataAction::execute($_REQUEST);
|
||||
if (count($userData['errors']) === 0) {
|
||||
$memberId = \CreateGroupMemberAction::execute( $userData['data'] );
|
||||
new \Bdp\Modules\Gruppen\Controllers\PrintMemberController($memberId);
|
||||
} else {
|
||||
kompass_print_message_box(implode('<br />', $userData['errors']), 'error');
|
||||
new \Bdp\Modules\Gruppen\Controllers\CreateMemberController($userData['rawData']);
|
||||
exit;
|
||||
}
|
||||
new \Bdp\Modules\Gruppen\Controllers\PrintGroupsController();
|
||||
break;
|
||||
|
||||
case 'show-members':
|
||||
$memberList = \ListMemberRequest::listForGroup((int)$_REQUEST['group-id']);
|
||||
new \Bdp\Modules\Gruppen\Controllers\PrintMemberListController($memberList);
|
||||
break;
|
||||
|
||||
case 'show-member':
|
||||
new \Bdp\Modules\Gruppen\Controllers\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:
|
||||
}
|
||||
} else {
|
||||
new MailCompose();
|
||||
}
|
||||
}
|
||||
|
||||
private function listMembers()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private function printMembers(array $memberList)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
34
modules/Mail/Views/MailCompose.php
Normal file
34
modules/Mail/Views/MailCompose.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
function kompass_print_mail_compose()
|
||||
{
|
||||
global $dbHandler;
|
||||
?>
|
||||
|
||||
<form method="post" action="admin.php?page=kompass-mail" style="width: 80%; margin: auto">
|
||||
|
||||
<table style="width: 100%">
|
||||
<input type="hidden" name="action" value="send-email" />
|
||||
<tr>
|
||||
<td><?= __('From: ', BDP_LV_PLUGIN_SLUG); ?></td>
|
||||
<td><input type="text" name="mail-from" style="width: 100%"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= __('To: ', BDP_LV_PLUGIN_SLUG); ?></td>
|
||||
<td><input type="text" name="mail-to" style="width: 100%"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= __('Subject: ', BDP_LV_PLUGIN_SLUG); ?></td>
|
||||
<td><input type="text" name="mail-subject" style="width: 100%"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
wp_editor( '', 'gutenberg_content', array(
|
||||
'textarea_name' => 'mail-text',
|
||||
// 'media_buttons' => false, // Deaktivieren der Medien-Upload-Schaltfläche
|
||||
) );
|
||||
submit_button(__('Send email', BDP_LV_PLUGIN_SLUG));
|
||||
?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('Calendar settings', BDP_LV_PLUGIN_SLUG),
|
||||
'custom_settings_section_callback',
|
||||
'kompass_prepare_form',
|
||||
BDP_LV_PLUGIN_SLUG . '-calendar-settings'
|
||||
);
|
||||
|
||||
@ -12,7 +12,7 @@ $seo_settings_page = BDP_LV_PLUGIN_SLUG . '-calendar-settings';
|
||||
add_settings_field(
|
||||
'kompass_cal_1',
|
||||
__('Calendar URL', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$seo_settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'bdp_calendar_source_url', 'style' => 'width: 1024px']);
|
||||
|
@ -4,7 +4,7 @@
|
||||
add_settings_section(
|
||||
'custom_settings_section',
|
||||
__('SEO-Options', BDP_LV_PLUGIN_SLUG),
|
||||
'custom_settings_section_callback',
|
||||
'kompass_prepare_form',
|
||||
BDP_LV_PLUGIN_SLUG . '-seo-settings'
|
||||
);
|
||||
|
||||
@ -13,7 +13,7 @@ $seo_settings_page = BDP_LV_PLUGIN_SLUG . '-seo-settings';
|
||||
add_settings_field(
|
||||
'kompass_seo_1',
|
||||
__('Google Site verification', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$seo_settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_seo_google_verification', 'style' => 'width: 500px']);
|
||||
@ -22,7 +22,7 @@ add_settings_field(
|
||||
add_settings_field(
|
||||
'kompass_seo_2',
|
||||
__('Bing Site verification', BDP_LV_PLUGIN_SLUG),
|
||||
'_kompass_limit_logins_settings_callback',
|
||||
'kompass_print_textbox',
|
||||
$seo_settings_page,
|
||||
'custom_settings_section',
|
||||
['setting' => 'kompass_seo_bing_verification', 'style' => 'width: 500px']);
|
@ -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";
|
||||
|
Reference in New Issue
Block a user