migrate admin_settings::testmail
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -126,7 +126,7 @@ if ($page == 'message') {
|
||||
'actions_links' => [[
|
||||
'href' => $linker->getLink(['section' => 'settings', 'page' => 'overview', 'part' => 'system', 'em' => 'system_mail_use_smtp']),
|
||||
'label' => $lng['admin']['smtpsettings'],
|
||||
'icon' => 'fa-solid fa-wrench',
|
||||
'icon' => 'fa-solid fa-gears',
|
||||
'class' => 'btn-outline-secondary'
|
||||
]],
|
||||
// alert-box
|
||||
|
||||
@@ -331,7 +331,7 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
|
||||
'href' => $linker->getLink(['section' => 'settings', 'page' => 'overview']),
|
||||
'label' => $lng['admin']['configfiles']['overview'],
|
||||
'icon' => 'fa fa-grip'
|
||||
],[
|
||||
], [
|
||||
'class' => 'btn-outline-secondary',
|
||||
'href' => $linker->getLink(['section' => 'settings', 'page' => $page, 'action' => 'export']),
|
||||
'label' => 'Download/export ' . $lng['admin']['serversettings'],
|
||||
@@ -340,12 +340,14 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
|
||||
]);
|
||||
}
|
||||
} elseif ($page == 'testmail') {
|
||||
|
||||
$note_type = 'info';
|
||||
$note_msg = $lng['admin']['smtptestnote'];
|
||||
|
||||
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
||||
$test_addr = isset($_POST['test_addr']) ? $_POST['test_addr'] : null;
|
||||
|
||||
/**
|
||||
* Initialize the mailingsystem
|
||||
*/
|
||||
// Initialize the mailingsystem
|
||||
$testmail = new \PHPMailer\PHPMailer\PHPMailer(true);
|
||||
$testmail->CharSet = "UTF-8";
|
||||
|
||||
@@ -379,10 +381,12 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
|
||||
$testmail->AddAddress($test_addr);
|
||||
$testmail->Send();
|
||||
} catch (\PHPMailer\PHPMailer\Exception $e) {
|
||||
$mailerr_msg = $e->errorMessage();
|
||||
$note_type = 'danger';
|
||||
$note_msg = $e->getMessage();
|
||||
$_mailerror = true;
|
||||
} catch (Exception $e) {
|
||||
$mailerr_msg = $e->getMessage();
|
||||
$note_type = 'danger';
|
||||
$note_msg = $e->getMessage();
|
||||
$_mailerror = true;
|
||||
}
|
||||
|
||||
@@ -396,14 +400,24 @@ if ($page == 'overview' && $userinfo['change_serversettings'] == '1') {
|
||||
}
|
||||
} else {
|
||||
// invalid sender e-mail
|
||||
$mailerr_msg = "Invalid sender e-mail address: " . Settings::Get('panel.adminmail');
|
||||
$_mailerror = true;
|
||||
$note_type = 'warning';
|
||||
$note_msg = "Invalid sender e-mail address: " . Settings::Get('panel.adminmail');
|
||||
}
|
||||
}
|
||||
|
||||
$mail_smtp_user = Settings::Get('system.mail_smtp_user');
|
||||
$mail_smtp_host = Settings::Get('system.mail_smtp_host');
|
||||
$mail_smtp_port = Settings::Get('system.mail_smtp_port');
|
||||
$mailtest_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/settings/formfield.settings_mailtest.php';
|
||||
|
||||
eval("echo \"" . \Froxlor\UI\Template::getTemplate("settings/testmail") . "\";");
|
||||
UI::view('user/form-note.html.twig', [
|
||||
'formaction' => $linker->getLink(array('section' => 'settings')),
|
||||
'formdata' => $mailtest_add_data['mailtest'],
|
||||
'actions_links' => [[
|
||||
'href' => $linker->getLink(['section' => 'settings', 'page' => 'overview', 'part' => 'system', 'em' => 'system_mail_use_smtp']),
|
||||
'label' => $lng['admin']['smtpsettings'],
|
||||
'icon' => 'fa-solid fa-gears',
|
||||
'class' => 'btn-outline-secondary'
|
||||
]],
|
||||
// alert-box
|
||||
'type' => $note_type,
|
||||
'alert_msg' => $note_msg
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use Froxlor\Settings;
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Formfields
|
||||
*
|
||||
*/
|
||||
return array(
|
||||
'mailtest' => array(
|
||||
'title' => $lng['admin']['testmail'],
|
||||
'image' => 'fa-solid fa-paper-plane',
|
||||
'sections' => array(
|
||||
'section_a' => array(
|
||||
'fields' => array(
|
||||
'smtp_user' => array(
|
||||
'label' => $lng['serversettings']['mail_smtp_user'],
|
||||
'type' => 'label',
|
||||
'value' => (empty(Settings::Get('system.mail_smtp_user')) ? $lng['panel']['unspecified'] : Settings::Get('system.mail_smtp_user'))
|
||||
),
|
||||
'smtp_host' => array(
|
||||
'label' => $lng['serversettings']['mail_smtp_host'],
|
||||
'type' => 'label',
|
||||
'value' => (empty(Settings::Get('system.mail_smtp_host')) ? $lng['panel']['unspecified'] : Settings::Get('system.mail_smtp_host'))
|
||||
),
|
||||
'smtp_port' => array(
|
||||
'label' => $lng['serversettings']['mail_smtp_port'],
|
||||
'type' => 'label',
|
||||
'value' => (empty(Settings::Get('system.mail_smtp_port')) ? $lng['panel']['unspecified'] : Settings::Get('system.mail_smtp_port'))
|
||||
),
|
||||
'smtp_auth' => array(
|
||||
'label' => $lng['serversettings']['mail_smtp_auth'],
|
||||
'type' => 'checkbox',
|
||||
'value' => 1,
|
||||
'checked' => (bool) Settings::Get('system.mail_use_smtp'),
|
||||
'disabled' => true
|
||||
),
|
||||
'smtp_tls' => array(
|
||||
'label' => $lng['serversettings']['mail_smtp_usetls'],
|
||||
'type' => 'checkbox',
|
||||
'value' => 1,
|
||||
'checked' => (bool) Settings::Get('system.mail_smtp_usetls'),
|
||||
'disabled' => true
|
||||
),
|
||||
'test_addr' => array(
|
||||
'label' => $lng['admin']['smtptestaddr'],
|
||||
'type' => 'email',
|
||||
'mandatory' => true
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -2153,3 +2153,6 @@ $lng['admin']['configfiles']['recommendednote'] = 'Recommended/required services
|
||||
$lng['admin']['configfiles']['selectrecommended'] = 'Select recommended';
|
||||
$lng['update']['description'] = 'Running database updates for your froxlor installation';
|
||||
$lng['admin']['smtpsettings'] = 'SMTP settings';
|
||||
$lng['panel']['unspecified'] = 'unspecified';
|
||||
$lng['admin']['smtptestaddr'] = 'Send test-mail to';
|
||||
$lng['admin']['smtptestnote'] = 'Note that the values below reflect your current settings and can only be adjusted there (see link in top right corner)';
|
||||
|
||||
@@ -1795,3 +1795,6 @@ $lng['admin']['configfiles']['recommendednote'] = 'Empfohlene/benötigte Dienste
|
||||
$lng['admin']['configfiles']['selectrecommended'] = 'Empfohlene wählen';
|
||||
$lng['update']['description'] = 'Aktualisierung der froxlor Datenbank';
|
||||
$lng['admin']['smtpsettings'] = 'SMTP Einstellungen';
|
||||
$lng['panel']['unspecified'] = 'keine Angabe';
|
||||
$lng['admin']['smtptestaddr'] = 'Test-Email senden an';
|
||||
$lng['admin']['smtptestnote'] = 'Bitte beachten: Die untenstehenden Werte reflektieren die aktuellen Einstellungen und können auch nur dort angepasst werden (siehe Link in der oberen rechten Ecke)';
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
{% if field.is_array is defined and field.is_array == 1 and field.values is not empty %}
|
||||
{% for subfield in field.values %}
|
||||
<div class="form-check form-switch">
|
||||
<input type="checkbox" {% if field.visible is defined and field.visible == false %} disabled {% endif %} value="{{ subfield.value }}" name="{{ id }}[]" class="form-check-input" {% if field.value is defined and subfield.value in field.value %} checked="checked" {% endif %}>
|
||||
<input type="checkbox" {% if (field.visible is defined and field.visible == false) or (field.disabled is defined and field.disabled == true) %} disabled {% endif %} value="{{ subfield.value }}" name="{{ id }}[]" class="form-check-input" {% if field.value is defined and subfield.value in field.value %} checked="checked" {% endif %}>
|
||||
<label class="form-check-label">
|
||||
{{ subfield.label|raw }}
|
||||
</label>
|
||||
@@ -74,7 +74,7 @@
|
||||
{% else %}
|
||||
<div class="form-check form-switch">
|
||||
<input type="hidden" value="0" name="{{ id }}" />
|
||||
<input type="checkbox" {% if field.visible is defined and field.visible == false %} disabled {% endif %} value="{{ field.value }}" id="{{ id }}" name="{{ id }}" class="form-check-input {% if field.valid is defined and field.valid == false %}is-invalid{% endif %}" {% if field.checked is defined and field.checked == 1 %} checked="checked" {% endif %}>
|
||||
<input type="checkbox" {% if (field.visible is defined and field.visible == false) or (field.disabled is defined and field.disabled == true) %} disabled {% endif %} value="{{ field.value }}" id="{{ id }}" name="{{ id }}" class="form-check-input {% if field.valid is defined and field.valid == false %}is-invalid{% endif %}" {% if field.checked is defined and field.checked == 1 %} checked="checked" {% endif %}>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
Reference in New Issue
Block a user