From 33287c4b404b5137557bedd198a9cdc3bb0d7b6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20G=C3=BCnther?=
Date: Wed, 31 Jul 2024 21:20:57 +0200
Subject: [PATCH] Mail settings implemented
---
bdp-kompass.php | 5 +-
includes/frontend-functions.php | 3 +-
.../Controllers/SettingsPage.php | 18 ++-
modules/Mail/Controllers/MailController.php | 10 --
.../class-mailsettingscontroller.php | 71 +++++++++
.../Controllers/class-saveregistration.php | 20 ++-
settings/views/mail-settings.php | 147 ++++++++++++++++++
7 files changed, 253 insertions(+), 21 deletions(-)
create mode 100644 modules/Mail/Controllers/class-mailsettingscontroller.php
create mode 100644 settings/views/mail-settings.php
diff --git a/bdp-kompass.php b/bdp-kompass.php
index c7ba2d2..ba9f1c6 100644
--- a/bdp-kompass.php
+++ b/bdp-kompass.php
@@ -16,6 +16,7 @@ use Bdp\Modules\EventParticipants\Controllers\MainController as EventsMain;
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\Mail\Controllers\MailSettingsController;
use Bdp\Modules\Security\Security;
use Bdp\Modules\Seo\Seo;
@@ -135,6 +136,8 @@ if (false === (bool)get_option('user_can_register', false)) {
isSMTP();
+ $phpmailer->Host = $smtp_host;
+ $phpmailer->Port = $smtp_port;
+ $phpmailer->SMTPAuth = true;
+ $phpmailer->Username = $smtp_username;
+ $phpmailer->Password = $smtp_password;
+
+ $sender = get_option('kompass_smtp_sender', null);
+ $sender_name = get_option('kompass_smtp_sender-name', null);
+
+ if (null !== $sender && null !== $sender_name)
+ $phpmailer->setFrom( $sender, $sender_name );
+ #$phpmailer->SMTPSecure = $smtp_secure;
+ } );
+ }
+
+ }
+
+ public static function settings_form() {
+ if (isset($_POST['save'])) {
+ update_option('kompass_use_smtp', false);
+
+ if (isset($_POST['use_smtp'])) update_option('kompass_use_smtp', true);
+ update_option('kompass_smtp_host', sanitize_text_field(wp_unslash($_POST['smtp-host'])));
+ update_option('kompass_smtp_port', sanitize_text_field(wp_unslash($_POST['smtp-port'])));
+ update_option('kompass_smtp_user', sanitize_text_field(wp_unslash($_POST['smtp-user'])));
+ update_option('kompass_smtp_pass', sanitize_text_field(wp_unslash($_POST['smtp-pass'])));
+ update_option('kompass_smtp_sender', sanitize_text_field(wp_unslash($_POST['smtp-sender'])));
+ update_option('kompass_smtp_sender-name', sanitize_text_field(wp_unslash($_POST['smtp-sender-name'])));
+
+ kompass_print_message_box('Die Einstellungen wurden gespeichert.');
+ }
+
+
+ require BDP_LV_PLUGIN_DIR . '/settings/views/mail-settings.php';
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/modules/Registration/Controllers/class-saveregistration.php b/modules/Registration/Controllers/class-saveregistration.php
index 6f043c7..47f8c74 100644
--- a/modules/Registration/Controllers/class-saveregistration.php
+++ b/modules/Registration/Controllers/class-saveregistration.php
@@ -36,7 +36,11 @@ class SaveRegistration {
wp_mail($user->user_email, 'Bitte bestätige deine Anmeldung', 'Hallo, bitte bestätige deine Anmeldung über den folgenden Link: ' . $activation_link);
// Notify admin
- wp_mail(get_option('admin_email'), 'New User Registration', 'A new user has registered: ' . $user->user_login . PHP_EOL . 'First name:' . $user->first_name . PHP_EOL . 'Last name:' . $user->last_name );
+ wp_mail(get_option('admin_email'), 'New User Registration', 'A new user has registered: ' . PHP_EOL .
+ 'Username: ' . $user->user_login . PHP_EOL .
+ 'First name: ' . $user->first_name . PHP_EOL .
+ 'Last name: ' . $user->last_name . PHP_EOL .
+ 'E-Mail: ' . $user->user_email);
}
public static function activate_user() {
@@ -72,5 +76,19 @@ class SaveRegistration {
Vielen Dank für deine Registrierung. Bitte überprüfen deine E-Mails, um deine Registrierung zu bestätigen.
';
}
+
+ if ((isset($_GET['action']) && $_GET['action'] === 'laostpassword') ||
+ isset($_GET['checkemail']) && $_GET['checkemail'] === 'confirm'
+ ){
+ echo '
+
Insofern der Account existiert, hast du soeben weitere Anweisungen per E-Mail erhalten.
+
';
+ }
+
+ if (isset($_GET['action']) && $_GET['action'] === 'resetpass') {
+ echo '
+
Dein Passwort wurde erfolgreich geändert.
+
';
+ }
}
}
\ No newline at end of file
diff --git a/settings/views/mail-settings.php b/settings/views/mail-settings.php
new file mode 100644
index 0000000..28da90a
--- /dev/null
+++ b/settings/views/mail-settings.php
@@ -0,0 +1,147 @@
+
+
+
+
\ No newline at end of file