From e9740e86b511693e4ce981130caf29c45c0a451c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20G=C3=BCnther?=
Date: Sun, 24 Mar 2024 19:52:32 +0100
Subject: [PATCH] =?UTF-8?q?Grundfunktionalit=C3=A4t=20zum=20Senden=20von?=
=?UTF-8?q?=20E-Mails?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
bdp-kompass.php | 2 +
includes/action_caller.php | 2 +-
includes/spl.php | 24 +--
modules/Gruppen/Views/GruppenOverview.php | 7 +
modules/Mail/Controllers/MailCompose.php | 10 ++
modules/Mail/Controllers/MailController.php | 153 ++++++++++++++++++++
modules/Mail/Views/MailCompose.php | 34 +++++
7 files changed, 221 insertions(+), 11 deletions(-)
create mode 100644 modules/Mail/Controllers/MailCompose.php
create mode 100644 modules/Mail/Controllers/MailController.php
create mode 100644 modules/Mail/Views/MailCompose.php
diff --git a/bdp-kompass.php b/bdp-kompass.php
index 1b59e88..0df0497 100644
--- a/bdp-kompass.php
+++ b/bdp-kompass.php
@@ -15,6 +15,7 @@
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;
@@ -47,6 +48,7 @@ add_action('admin_menu', function () {
new OptionsPageAlias();
new KomnpassSettings();
new GruppenMain();
+ new MailController();
});
diff --git a/includes/action_caller.php b/includes/action_caller.php
index c2178a4..f5d09c4 100644
--- a/includes/action_caller.php
+++ b/includes/action_caller.php
@@ -30,7 +30,7 @@ function add_custom_admin_bar_item() {
'id' => 'kompass_gruppen',
'title' => '' .
'' .__('Groups', BDP_LV_PLUGIN_SLUG) . '',
- 'href' => 'admin.php?page=kompass-groups',
+ 'href' => get_admin_url() . 'admin.php?page=kompass-groups',
];
diff --git a/includes/spl.php b/includes/spl.php
index b3d4fe1..b23b823 100644
--- a/includes/spl.php
+++ b/includes/spl.php
@@ -25,16 +25,20 @@ foreach (glob($directoryPath . '*.php') as $file) {
require_once $file;
}
-
-
-$modules = ['KompassSettings', 'LimitLoginAttempts', 'PasswordStrength', 'seo', 'Gruppen'];
$subdirs = ['includes', 'Controllers', 'Views', 'Requests', 'Actions'];
-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 (scandir(BDP_LV_PLUGIN_DIR . 'modules/') as $curModule) {
+ if ($curModule != '.' && $curModule != '..' && is_dir(BDP_LV_PLUGIN_DIR . 'modules/' . $curModule))
+ {
+ if ($curModule == 'calendar') {
+ continue;
+ }
+
+ foreach ($subdirs as $dir) {
+ $directoryPath = BDP_LV_PLUGIN_DIR . 'modules/' . $curModule . '/' . $dir . '/';
+ foreach (glob($directoryPath . '*.php') as $file) {
+ require_once $file;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/Gruppen/Views/GruppenOverview.php b/modules/Gruppen/Views/GruppenOverview.php
index 0af502e..0e15155 100644
--- a/modules/Gruppen/Views/GruppenOverview.php
+++ b/modules/Gruppen/Views/GruppenOverview.php
@@ -59,6 +59,13 @@ function kompass_print_gruppen_overview()
';
+
+ // 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
diff --git a/modules/Mail/Controllers/MailCompose.php b/modules/Mail/Controllers/MailCompose.php
new file mode 100644
index 0000000..9f65916
--- /dev/null
+++ b/modules/Mail/Controllers/MailCompose.php
@@ -0,0 +1,10 @@
+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 'E-Mail wurde erfolgreich gesendet!
';
+ } else {
+ echo 'Fehler beim Senden der E-Mail!
';
+ }
+
+
+
+
+
+ echo $_REQUEST['mail-to'] . '
';
+ 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('
', $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)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/modules/Mail/Views/MailCompose.php b/modules/Mail/Views/MailCompose.php
new file mode 100644
index 0000000..19c8c3e
--- /dev/null
+++ b/modules/Mail/Views/MailCompose.php
@@ -0,0 +1,34 @@
+
+
+
+