migrated admin_messages; minor fixes in admin-listing and ipsandports::add defaults

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-03-24 13:40:43 +01:00
parent 66f97738c2
commit 25b9e5b540
14 changed files with 99 additions and 31 deletions

View File

@@ -22,9 +22,13 @@ require __DIR__ . '/lib/init.php';
use Froxlor\Database\Database; use Froxlor\Database\Database;
use Froxlor\UI\Request; use Froxlor\UI\Request;
use Froxlor\UI\Panel\UI;
$id = (int) Request::get('id'); $id = (int) Request::get('id');
$note_type = null;
$note_msg = null;
if ($page == 'message') { if ($page == 'message') {
if ($action == '') { if ($action == '') {
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed panel_message'); $log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, 'viewed panel_message');
@@ -53,7 +57,7 @@ if ($page == 'message') {
$subject = $_POST['subject']; $subject = $_POST['subject'];
$message = wordwrap($_POST['message'], 70); $message = wordwrap($_POST['message'], 70);
if (! empty($message)) { if (!empty($message)) {
$mailcounter = 0; $mailcounter = 0;
$mail->Body = $message; $mail->Body = $message;
$mail->Subject = $subject; $mail->Subject = $subject;
@@ -70,7 +74,7 @@ if ($page == 'message') {
$mail->From = $userinfo['email']; $mail->From = $userinfo['email'];
$mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name']; $mail->FromName = (isset($userinfo['firstname']) ? $userinfo['firstname'] . ' ' : '') . $userinfo['name'];
if (! $mail->Send()) { if (!$mail->Send()) {
if ($mail->ErrorInfo != '') { if ($mail->ErrorInfo != '') {
$mailerr_msg = $mail->ErrorInfo; $mailerr_msg = $mail->ErrorInfo;
} else { } else {
@@ -81,7 +85,7 @@ if ($page == 'message') {
\Froxlor\UI\Response::standard_error('errorsendingmail', $row['email']); \Froxlor\UI\Response::standard_error('errorsendingmail', $row['email']);
} }
$mailcounter ++; $mailcounter++;
$mail->ClearAddresses(); $mail->ClearAddresses();
} }
@@ -94,31 +98,39 @@ if ($page == 'message') {
\Froxlor\UI\Response::standard_error('nomessagetosend'); \Froxlor\UI\Response::standard_error('nomessagetosend');
} }
} }
} } elseif ($action == 'showsuccess') {
if ($action == 'showsuccess') {
$success = 1;
$sentitems = isset($_GET['sentitems']) ? (int) $_GET['sentitems'] : 0; $sentitems = isset($_GET['sentitems']) ? (int) $_GET['sentitems'] : 0;
if ($sentitems == 0) { if ($sentitems == 0) {
$successmessage = $lng['message']['norecipients']; $note_type = 'info';
$note_msg = $lng['message']['norecipients'];
} else { } else {
$successmessage = str_replace('%s', $sentitems, $lng['message']['success']); $note_type = 'success';
$note_msg = str_replace('%s', $sentitems, $lng['message']['success']);
} }
} else {
$success = 0;
$sentitems = 0;
$successmessage = '';
} }
$action = ''; $recipients = [];
$recipients = '';
if ($userinfo['customers_see_all'] == '1') { if ($userinfo['customers_see_all'] == '1') {
$recipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['reseller'], 0); $recipients[0] = $lng['panel']['reseller'];
} }
$recipients[1] = $lng['panel']['customer'];
$recipients .= \Froxlor\UI\HTML::makeoption($lng['panel']['customer'], 1); $messages_add_data = include_once dirname(__FILE__) . '/lib/formfields/admin/messages/formfield.messages_add.php';
eval("echo \"" . \Froxlor\UI\Template::getTemplate('message/message') . "\";");
UI::view('user/form-note.html.twig', [
'formaction' => $linker->getLink(array('section' => 'message')),
'formdata' => $messages_add_data['messages_add'],
'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',
'class' => 'btn-outline-secondary'
]],
// alert-box
'type' => $note_type,
'alert_msg' => $note_msg
]);
} }

View File

@@ -24,4 +24,9 @@ class Admin
{ {
return (bool)UI::getCurrentUser()['change_serversettings']; return (bool)UI::getCurrentUser()['change_serversettings'];
} }
public static function isNotMe(array $attributes)
{
return (UI::getCurrentUser()['adminid'] != $attributes['fields']['adminid']);
}
} }

View File

@@ -47,14 +47,14 @@ return array(
'label' => $lng['admin']['ipsandports']['create_listen_statement'], 'label' => $lng['admin']['ipsandports']['create_listen_statement'],
'type' => 'checkbox', 'type' => 'checkbox',
'value' => '1', 'value' => '1',
'checked' => true 'checked' => false
), ),
'namevirtualhost_statement' => array( 'namevirtualhost_statement' => array(
'visible' => \Froxlor\Settings::Get('system.webserver') == 'apache2' && (int) \Froxlor\Settings::Get('system.apache24') == 0, 'visible' => \Froxlor\Settings::Get('system.webserver') == 'apache2' && (int) \Froxlor\Settings::Get('system.apache24') == 0,
'label' => $lng['admin']['ipsandports']['create_namevirtualhost_statement'], 'label' => $lng['admin']['ipsandports']['create_namevirtualhost_statement'],
'type' => 'checkbox', 'type' => 'checkbox',
'value' => '1', 'value' => '1',
'checked' => true 'checked' => \Froxlor\Settings::Get('system.webserver') == 'apache2' && (int) \Froxlor\Settings::Get('system.apache24') == 0 ? true : false
), ),
'vhostcontainer' => array( 'vhostcontainer' => array(
'label' => $lng['admin']['ipsandports']['create_vhostcontainer'], 'label' => $lng['admin']['ipsandports']['create_vhostcontainer'],

View File

@@ -0,0 +1,45 @@
<?php
/**
* 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(
'messages_add' => array(
'title' => $lng['admin']['message'],
'image' => 'fa-solid fa-paper-plane',
'sections' => array(
'section_a' => array(
'fields' => array(
'recipient' => array(
'label' => $lng['admin']['recipient'],
'type' => 'select',
'select_var' => $recipients,
'selected' => 1
),
'subject' => array(
'label' => $lng['admin']['subject'],
'type' => 'text',
'value' => $lng['admin']['nosubject'],
'mandatory' => true
),
'message' => array(
'label' => $lng['admin']['text'],
'type' => 'textarea',
'mandatory' => true
)
)
)
)
)
);

View File

@@ -16,6 +16,7 @@
* *
*/ */
use Froxlor\UI\Callbacks\Admin;
use Froxlor\UI\Callbacks\ProgressBar; use Froxlor\UI\Callbacks\ProgressBar;
use Froxlor\UI\Callbacks\Style; use Froxlor\UI\Callbacks\Style;
use Froxlor\UI\Callbacks\Text; use Froxlor\UI\Callbacks\Text;
@@ -93,6 +94,7 @@ return [
'action' => 'delete', 'action' => 'delete',
'id' => ':adminid' 'id' => ':adminid'
], ],
'visible' => [Admin::class, 'isNotMe']
], ],
], ],
'format_callback' => [ 'format_callback' => [

View File

@@ -502,7 +502,7 @@ $lng['admin']['text'] = 'Zpráva';
$lng['menu']['message'] = 'Zprávy'; $lng['menu']['message'] = 'Zprávy';
$lng['error']['errorsendingmail'] = 'Zpráva uživateli "%s" selhala'; $lng['error']['errorsendingmail'] = 'Zpráva uživateli "%s" selhala';
$lng['error']['cannotreaddir'] = 'Nelze přečíst adresář "%s"'; $lng['error']['cannotreaddir'] = 'Nelze přečíst adresář "%s"';
$lng['message']['success'] = 'Zpráva úspěšně odeslána %s příjemcům,'; $lng['success']['messages_success'] = 'Zpráva úspěšně odeslána %s příjemcům,';
$lng['message']['norecipients'] = 'Email nebyl odeslán, protože databáze neobsahuje žádné příjemce'; $lng['message']['norecipients'] = 'Email nebyl odeslán, protože databáze neobsahuje žádné příjemce';
$lng['admin']['sslsettings'] = 'SSL nastavení'; $lng['admin']['sslsettings'] = 'SSL nastavení';
$lng['cronjobs']['notyetrun'] = 'Ještě nespuštěno'; $lng['cronjobs']['notyetrun'] = 'Ještě nespuštěno';

View File

@@ -601,7 +601,7 @@ $lng['admin']['text'] = 'Bericht';
$lng['menu']['message'] = 'Berichten'; $lng['menu']['message'] = 'Berichten';
$lng['error']['errorsendingmail'] = 'Het versturen van het bericht naar "%s" is mislukt'; $lng['error']['errorsendingmail'] = 'Het versturen van het bericht naar "%s" is mislukt';
$lng['error']['cannotreaddir'] = 'De map "%s" kan niet gelezen worden'; $lng['error']['cannotreaddir'] = 'De map "%s" kan niet gelezen worden';
$lng['message']['success'] = 'Bericht verzonden naar ontvangers %s'; $lng['success']['messages_success'] = 'Bericht verzonden naar ontvangers %s';
$lng['message']['norecipients'] = 'Er is geen email verstuurd omdat er geen ontvangers in de database zijn'; $lng['message']['norecipients'] = 'Er is geen email verstuurd omdat er geen ontvangers in de database zijn';
$lng['admin']['sslsettings'] = 'Instellingen voor SSL'; $lng['admin']['sslsettings'] = 'Instellingen voor SSL';
$lng['cronjobs']['notyetrun'] = 'Nog niet uitgevoerd'; $lng['cronjobs']['notyetrun'] = 'Nog niet uitgevoerd';

View File

@@ -677,7 +677,7 @@ $lng['admin']['text'] = 'Message';
$lng['menu']['message'] = 'Messages'; $lng['menu']['message'] = 'Messages';
$lng['error']['errorsendingmail'] = 'The message to "%s" failed'; $lng['error']['errorsendingmail'] = 'The message to "%s" failed';
$lng['error']['cannotreaddir'] = 'Unable to read directory "%s"'; $lng['error']['cannotreaddir'] = 'Unable to read directory "%s"';
$lng['message']['success'] = 'Successfully sent message to %s recipients'; $lng['success']['messages_success'] = 'Successfully sent message to %s recipients';
$lng['message']['norecipients'] = 'No e-mail has been sent because there are no recipients in the database'; $lng['message']['norecipients'] = 'No e-mail has been sent because there are no recipients in the database';
$lng['admin']['sslsettings'] = 'SSL settings'; $lng['admin']['sslsettings'] = 'SSL settings';
$lng['cronjobs']['notyetrun'] = 'Not yet run'; $lng['cronjobs']['notyetrun'] = 'Not yet run';
@@ -2152,3 +2152,4 @@ $lng['admin']['configfiles']['skipconfig'] = 'Don\'t (re)configure';
$lng['admin']['configfiles']['recommendednote'] = 'Recommended/required services based on current system settings'; $lng['admin']['configfiles']['recommendednote'] = 'Recommended/required services based on current system settings';
$lng['admin']['configfiles']['selectrecommended'] = 'Select recommended'; $lng['admin']['configfiles']['selectrecommended'] = 'Select recommended';
$lng['update']['description'] = 'Running database updates for your froxlor installation'; $lng['update']['description'] = 'Running database updates for your froxlor installation';
$lng['admin']['smtpsettings'] = 'SMTP settings';

View File

@@ -641,7 +641,7 @@ $lng['admin']['text'] = 'Message';
$lng['menu']['message'] = 'Messages'; $lng['menu']['message'] = 'Messages';
$lng['error']['errorsendingmail'] = 'Echec d\'envoi du message à "%s"'; $lng['error']['errorsendingmail'] = 'Echec d\'envoi du message à "%s"';
$lng['error']['cannotreaddir'] = 'Impossible de lire dossier "%s"'; $lng['error']['cannotreaddir'] = 'Impossible de lire dossier "%s"';
$lng['message']['success'] = 'Le message a été envoyé aux destinataires "%s"'; $lng['success']['messages_success'] = 'Le message a été envoyé aux destinataires "%s"';
$lng['message']['norecipients'] = 'Aucun e-mail n\'a été envoyé car il n\'existe aucun destinataire dans la base de données'; $lng['message']['norecipients'] = 'Aucun e-mail n\'a été envoyé car il n\'existe aucun destinataire dans la base de données';
$lng['admin']['sslsettings'] = 'Paramètres SSL'; $lng['admin']['sslsettings'] = 'Paramètres SSL';
$lng['cronjobs']['notyetrun'] = 'Pas encore lancé'; $lng['cronjobs']['notyetrun'] = 'Pas encore lancé';

View File

@@ -670,7 +670,7 @@ $lng['admin']['text'] = 'Nachricht';
$lng['menu']['message'] = 'Nachrichten'; $lng['menu']['message'] = 'Nachrichten';
$lng['error']['errorsendingmail'] = 'Das Versenden der Nachricht an "%s" schlug fehl.'; $lng['error']['errorsendingmail'] = 'Das Versenden der Nachricht an "%s" schlug fehl.';
$lng['error']['cannotreaddir'] = 'Der Ordner "%s" kann nicht gelesen werden'; $lng['error']['cannotreaddir'] = 'Der Ordner "%s" kann nicht gelesen werden';
$lng['message']['success'] = 'Nachricht erfolgreich an "%s" Empfänger gesendet'; $lng['success']['messages_success'] = 'Nachricht erfolgreich an "%s" Empfänger gesendet';
$lng['message']['norecipients'] = 'Es wurde keine E-Mail versendet, da sich keine Empfänger in der Datenbank befinden'; $lng['message']['norecipients'] = 'Es wurde keine E-Mail versendet, da sich keine Empfänger in der Datenbank befinden';
$lng['admin']['sslsettings'] = 'SSL-Einstellungen'; $lng['admin']['sslsettings'] = 'SSL-Einstellungen';
$lng['cronjobs']['notyetrun'] = 'Bisher nicht gestartet'; $lng['cronjobs']['notyetrun'] = 'Bisher nicht gestartet';
@@ -1794,3 +1794,4 @@ $lng['admin']['configfiles']['skipconfig'] = 'Nicht (erneut) konfigurieren';
$lng['admin']['configfiles']['recommendednote'] = 'Empfohlene/benötigte Dienste ahand der aktuellen Systemeinstellungen'; $lng['admin']['configfiles']['recommendednote'] = 'Empfohlene/benötigte Dienste ahand der aktuellen Systemeinstellungen';
$lng['admin']['configfiles']['selectrecommended'] = 'Empfohlene wählen'; $lng['admin']['configfiles']['selectrecommended'] = 'Empfohlene wählen';
$lng['update']['description'] = 'Aktualisierung der froxlor Datenbank'; $lng['update']['description'] = 'Aktualisierung der froxlor Datenbank';
$lng['admin']['smtpsettings'] = 'SMTP Einstellungen';

View File

@@ -624,7 +624,7 @@ $lng['admin']['text'] = 'Messaggio';
$lng['menu']['message'] = 'Messaggi'; $lng['menu']['message'] = 'Messaggi';
$lng['error']['errorsendingmail'] = 'Il messaggio a "%s" fallito'; $lng['error']['errorsendingmail'] = 'Il messaggio a "%s" fallito';
$lng['error']['cannotreaddir'] = 'Impossibile leggere la cartella "%s"'; $lng['error']['cannotreaddir'] = 'Impossibile leggere la cartella "%s"';
$lng['message']['success'] = 'Inviato correttamente il messaggio a %s recipients'; $lng['success']['messages_success'] = 'Inviato correttamente il messaggio a %s recipients';
$lng['message']['norecipients'] = 'Nessuna e-mail è stata inviata perch¸ non ci sono i destinatari nel database'; $lng['message']['norecipients'] = 'Nessuna e-mail è stata inviata perch¸ non ci sono i destinatari nel database';
$lng['admin']['sslsettings'] = 'Impostazioni SSL'; $lng['admin']['sslsettings'] = 'Impostazioni SSL';
$lng['cronjobs']['notyetrun'] = 'Non ancora avviato'; $lng['cronjobs']['notyetrun'] = 'Non ancora avviato';

View File

@@ -568,7 +568,7 @@ $lng['admin']['text'] = 'Mensagem';
$lng['menu']['message'] = 'Mensagens'; $lng['menu']['message'] = 'Mensagens';
$lng['error']['errorsendingmail'] = 'A mensagem para "%s" falhou'; $lng['error']['errorsendingmail'] = 'A mensagem para "%s" falhou';
$lng['error']['cannotreaddir'] = 'Não é possível ler o diretório "%s"'; $lng['error']['cannotreaddir'] = 'Não é possível ler o diretório "%s"';
$lng['message']['success'] = 'Mensagens enviadas para %s destinatários com sucesso'; $lng['success']['messages_success'] = 'Mensagens enviadas para %s destinatários com sucesso';
$lng['message']['norecipients'] = 'Email não enviado porque não tem destinatário no banco de dados'; $lng['message']['norecipients'] = 'Email não enviado porque não tem destinatário no banco de dados';
$lng['admin']['sslsettings'] = 'Configuração de SSL'; $lng['admin']['sslsettings'] = 'Configuração de SSL';
$lng['cronjobs']['notyetrun'] = 'Ainda não está rodando'; $lng['cronjobs']['notyetrun'] = 'Ainda não está rodando';

View File

@@ -1,4 +1,4 @@
<div class="alert alert-{{ type }} fade show pb-1" role="alert"> <div class="alert alert-{{ type|default("info") }} fade show pb-1" role="alert">
{% if heading is defined and heading is not empty %} {% if heading is defined and heading is not empty %}
<h4 class="alert-heading"> <h4 class="alert-heading">
{{ heading }} {{ heading }}

View File

@@ -1,8 +1,10 @@
{% extends "Froxlor/user/form.html.twig" %} {% extends "Froxlor/user/form.html.twig" %}
{% block content %} {% block content %}
<div class="row mb-2"> {% if alert_msg is defined and alert_msg is not empty %}
{% include 'Froxlor/misc/alertbox.html.twig' %} <div class="row mb-2">
</div> {% include 'Froxlor/misc/alertbox.html.twig' %}
</div>
{% endif %}
{{ parent() }} {{ parent() }}
{% endblock %} {% endblock %}