diff --git a/admin_templates.php b/admin_templates.php
index ca098bd4..c43505c2 100644
--- a/admin_templates.php
+++ b/admin_templates.php
@@ -41,6 +41,9 @@ $available_templates = array(
if ((int) Settings::Get('system.report_enable') == 1) {
array_push($available_templates, 'trafficmaxpercent', 'diskmaxpercent');
}
+if (Settings::Get('panel.sendalternativemail') == 1) {
+ array_push($available_templates, 'pop_success_alternative');
+}
$file_templates = array(
'index_html'
@@ -50,15 +53,12 @@ if ($action == '') {
// email templates
$log->logAction(\Froxlor\FroxlorLogger::ADM_ACTION, LOG_NOTICE, "viewed admin_templates");
- if (Settings::Get('panel.sendalternativemail') == 1) {
- $available_templates[] = 'pop_success_alternative';
- }
-
$templates_array = array();
$result_stmt = Database::prepare("
SELECT `id`, `language`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `templategroup`='mails'
- ORDER BY `language`, `varname`");
+ ORDER BY `language`, `varname`
+ ");
Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid']
));
@@ -69,24 +69,27 @@ if ($action == '') {
$templates_array[$row['language']][$parts[1]][$parts[3]] = $row['id'];
}
- $templates = '';
+ $templates = [];
foreach ($templates_array as $language => $template_defs) {
foreach ($template_defs as $action => $email) {
- $subjectid = $email['subject'];
- $mailbodyid = $email['mailbody'];
- $template = $lng['admin']['templates'][$action];
- eval("\$templates.=\"" . \Froxlor\UI\Template::getTemplate("templates/templates_template") . "\";");
+ $templates[] = [
+ 'subjectid' => $email['subject'],
+ 'mailbodyid' => $email['mailbody'],
+ 'template' => $lng['admin']['templates'][$action],
+ 'language' => $language
+ ];
}
}
- $add = false;
+ $mail_actions_links = false;
foreach ($languages as $language_file => $language_name) {
$templates_done = array();
$result_stmt = Database::prepare("
SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `language`= :lang
- AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'");
+ AND `templategroup` = 'mails' AND `varname` LIKE '%_subject'
+ ");
Database::pexecute($result_stmt, array(
'adminid' => $userinfo['adminid'],
'lang' => $language_name
@@ -97,13 +100,20 @@ if ($action == '') {
}
if (count(array_diff($available_templates, $templates_done)) > 0) {
- $add = true;
+ $mail_actions_links = [[
+ 'href' => $linker->getLink(['section' => 'templates', 'page' => $page, 'action' => 'add']),
+ 'label' => $lng['admin']['templates']['template_add']
+ ]];
}
}
+ $mailtpl_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.mailtemplates.php';
+ $collection_mail = [
+ 'data' => $templates,
+ 'pagination' => []
+ ];
+
// filetemplates
- $filetemplates = '';
- $filetemplateadd = false;
$result_stmt = Database::prepare("
SELECT `id`, `varname` FROM `" . TABLE_PANEL_TEMPLATES . "`
WHERE `adminid` = :adminid AND `templategroup`='files'");
@@ -111,14 +121,35 @@ if ($action == '') {
'adminid' => $userinfo['adminid']
));
- if (Database::num_rows() != count($file_templates)) {
- $filetemplateadd = true;
+ $filetemplates = [];
+ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
+ $filetemplates[] = [
+ 'id' => $row['id'],
+ 'template' => $lng['admin']['templates'][$row['varname']]
+ ];
}
- while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
- eval("\$filetemplates.=\"" . \Froxlor\UI\Template::getTemplate("templates/templates_filetemplate") . "\";");
+ $file_actions_links = false;
+ if (Database::num_rows() != count($file_templates)) {
+ $file_actions_links = [[
+ 'href' => $linker->getLink(['section' => 'templates', 'page' => $page, 'action' => 'add', 'files' => 'files']),
+ 'label' => $lng['admin']['templates']['template_fileadd']
+ ]];
}
- eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/templates") . "\";");
+
+ $filetpl_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/admin/tablelisting.filetemplates.php';
+ $collection_file = [
+ 'data' => $filetemplates,
+ 'pagination' => []
+ ];
+
+ UI::twigBuffer('user/table-tpl.html.twig', [
+ 'maillisting' => \Froxlor\UI\Listing::formatFromArray($collection_mail, $mailtpl_list_data['mailtpl_list']),
+ 'filelisting' => \Froxlor\UI\Listing::formatFromArray($collection_file, $filetpl_list_data['filetpl_list']),
+ 'mail_actions_links' => $mail_actions_links,
+ 'file_actions_links' => $file_actions_links
+ ]);
+ UI::twigOutputBuffer();
} elseif ($action == 'delete' && $subjectid != 0 && $mailbodyid != 0) {
// email templates
$result_stmt = Database::prepare("
@@ -194,15 +225,25 @@ if ($action == '') {
}
} elseif ($action == 'add') {
- if (Settings::Get('panel.sendalternativemail') == 1) {
- $available_templates[] = 'pop_success_alternative';
- }
-
if (isset($_POST['prepare']) && $_POST['prepare'] == 'prepare') {
// email templates
$language = htmlentities(\Froxlor\Validate\Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect'));
$template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template');
+ $result_stmt = Database::prepare("
+ SELECT COUNT(*) as def FROM `" . TABLE_PANEL_TEMPLATES . "`
+ WHERE `adminid` = :adminid AND `language` = :lang
+ AND `templategroup` = 'mails' AND `varname` LIKE :template
+ ");
+ $result = Database::pexecute_first($result_stmt, array(
+ 'adminid' => $userinfo['adminid'],
+ 'lang' => $language,
+ 'template' => $template . '%'
+ ));
+ if ($result && $result['def'] > 0) {
+ \Froxlor\UI\Response::standard_error('templatelanguagecombodefined');
+ }
+
$lng_bak = $lng;
foreach ($langs['English'] as $key => $value) {
include_once \Froxlor\FileDir::makeSecurePath($value['file']);
@@ -226,7 +267,7 @@ if ($action == '') {
'replacers' => $template_add_data['template_replacers']
]);
UI::twigOutputBuffer();
- } elseif (isset($_POST['send']) && $_POST['send'] == 'send') {
+ } elseif (isset($_POST['send']) && $_POST['send'] == 'send' && !isset($_POST['filesend'])) {
// email templates
$language = htmlentities(\Froxlor\Validate\Validate::validate($_POST['language'], 'language', '/^[^\r\n\0"\']+$/', 'nolanguageselect'));
$template = \Froxlor\Validate\Validate::validate($_POST['template'], 'template');
@@ -369,7 +410,8 @@ if ($action == '') {
]
]
]
- ]
+ ],
+ 'editid' => $id
]);
UI::twigOutputBuffer();
} else {
@@ -515,12 +557,14 @@ if ($action == '') {
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
$filetemplate_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/templates/formfield.filetemplate_edit.php';
- $filetemplate_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($filetemplate_edit_data);
- $title = $filetemplate_edit_data['filetemplate_edit']['title'];
- $image = $filetemplate_edit_data['filetemplate_edit']['image'];
-
- eval("echo \"" . \Froxlor\UI\Template::getTemplate("templates/filetemplates_edit") . "\";");
+ UI::twigBuffer('user/form-replacers.html.twig', [
+ 'formaction' => $linker->getLink(array('section' => 'templates')),
+ 'formdata' => $filetemplate_edit_data['filetemplate_edit'],
+ 'replacers' => $filetemplate_edit_data['filetemplate_replacers'],
+ 'editid' => $id
+ ]);
+ UI::twigOutputBuffer();
}
} else {
\Froxlor\UI\Response::standard_error('templatenotfound');
diff --git a/lib/formfields/admin/templates/formfield.filetemplate_edit.php b/lib/formfields/admin/templates/formfield.filetemplate_edit.php
index 8459a890..3ae5ea6c 100644
--- a/lib/formfields/admin/templates/formfield.filetemplate_edit.php
+++ b/lib/formfields/admin/templates/formfield.filetemplate_edit.php
@@ -35,9 +35,37 @@ return array(
'cols' => 60,
'rows' => 12,
'value' => $row['value']
+ ),
+ 'filesend' => array(
+ 'type' => 'hidden',
+ 'value' => 'filesend'
)
)
)
)
- )
+ ),
+ 'filetemplate_replacers' => [
+ 'replacers' => [
+ [
+ 'var' => 'SERVERNAME',
+ 'description' => $lng['admin']['templates']['SERVERNAME']
+ ],
+ [
+ 'var' => 'CUSTOMER',
+ 'description' => $lng['admin']['templates']['CUSTOMER']
+ ],
+ [
+ 'var' => 'ADMIN',
+ 'description' => $lng['admin']['templates']['ADMIN']
+ ],
+ [
+ 'var' => 'CUSTOMER_EMAIL',
+ 'description' => $lng['admin']['templates']['CUSTOMER_EMAIL']
+ ],
+ [
+ 'var' => 'ADMIN_EMAIL',
+ 'description' => $lng['admin']['templates']['ADMIN_EMAIL']
+ ]
+ ]
+ ]
);
diff --git a/lib/tablelisting/admin/tablelisting.filetemplates.php b/lib/tablelisting/admin/tablelisting.filetemplates.php
new file mode 100644
index 00000000..21dd6d95
--- /dev/null
+++ b/lib/tablelisting/admin/tablelisting.filetemplates.php
@@ -0,0 +1,57 @@
+ (2010-)
+ * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
+ * @package Tabellisting
+ *
+ */
+
+use Froxlor\UI\Listing;
+
+return [
+ 'filetpl_list' => [
+ 'title' => $lng['admin']['templates']['filetemplates'],
+ 'icon' => 'fa-solid fa-file-lines',
+ 'columns' => [
+ 'template' => [
+ 'label' => $lng['admin']['templates']['action'],
+ 'field' => 'template'
+ ],
+ ],
+ 'visible_columns' => Listing::getVisibleColumnsForListing('filetpl_list', [
+ 'template'
+ ]),
+ 'actions' => [
+ 'edit' => [
+ 'icon' => 'fa fa-edit',
+ 'title' => $lng['panel']['edit'],
+ 'href' => [
+ 'section' => 'templates',
+ 'page' => $page,
+ 'action' => 'editf',
+ 'id' => ':id'
+ ],
+ ],
+ 'delete' => [
+ 'icon' => 'fa fa-trash',
+ 'title' => $lng['panel']['delete'],
+ 'class' => 'text-danger',
+ 'href' => [
+ 'section' => 'templates',
+ 'page' => $page,
+ 'action' => 'deletef',
+ 'id' => ':id'
+ ],
+ ],
+ ],
+ ]
+];
diff --git a/lib/tablelisting/admin/tablelisting.mailtemplates.php b/lib/tablelisting/admin/tablelisting.mailtemplates.php
new file mode 100644
index 00000000..85a30e57
--- /dev/null
+++ b/lib/tablelisting/admin/tablelisting.mailtemplates.php
@@ -0,0 +1,64 @@
+ (2010-)
+ * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
+ * @package Tabellisting
+ *
+ */
+
+use Froxlor\UI\Listing;
+
+return [
+ 'mailtpl_list' => [
+ 'title' => $lng['admin']['templates']['templates'],
+ 'icon' => 'fa-solid fa-envelope',
+ 'columns' => [
+ 'language' => [
+ 'label' => $lng['login']['language'],
+ 'field' => 'language'
+ ],
+ 'template' => [
+ 'label' => $lng['admin']['templates']['action'],
+ 'field' => 'template'
+ ],
+ ],
+ 'visible_columns' => Listing::getVisibleColumnsForListing('mailtpl_list', [
+ 'language',
+ 'template'
+ ]),
+ 'actions' => [
+ 'edit' => [
+ 'icon' => 'fa fa-edit',
+ 'title' => $lng['panel']['edit'],
+ 'href' => [
+ 'section' => 'templates',
+ 'page' => $page,
+ 'action' => 'edit',
+ 'subjectid' => ':subjectid',
+ 'mailbodyid' => ':mailbodyid'
+ ],
+ ],
+ 'delete' => [
+ 'icon' => 'fa fa-trash',
+ 'title' => $lng['panel']['delete'],
+ 'class' => 'text-danger',
+ 'href' => [
+ 'section' => 'templates',
+ 'page' => $page,
+ 'action' => 'delete',
+ 'subjectid' => ':subjectid',
+ 'mailbodyid' => ':mailbodyid'
+ ],
+ ],
+ ],
+ ]
+];
diff --git a/lng/english.lng.php b/lng/english.lng.php
index 18f0a21b..44069fd1 100644
--- a/lng/english.lng.php
+++ b/lng/english.lng.php
@@ -231,6 +231,7 @@ $lng['error']['destinationalreadyexistasmail'] = 'The forwarder to %s already ex
$lng['error']['destinationalreadyexist'] = 'You have already defined a forwarder to "%s"';
$lng['error']['destinationiswrong'] = 'The forwarder %s contains invalid character(s) or is incomplete.';
$lng['error']['backupfoldercannotbedocroot'] = 'The folder for backups cannot be your homedir, please chose a folder within your homedir, e.g. /backups';
+$lng['error']['templatelanguagecombodefined'] = 'The selected language/template combination has already been defined.';
/**
* Questions
@@ -305,6 +306,7 @@ $lng['admin']['ownvhostsettings'] = 'Own vHost-settings';
$lng['admin']['configfiles']['serverconfiguration'] = 'Configuration';
$lng['admin']['templates']['templates'] = 'Email-templates';
$lng['admin']['templates']['template_add'] = 'Add template';
+$lng['admin']['templates']['template_fileadd'] = 'Add file template';
$lng['admin']['templates']['template_edit'] = 'Edit template';
$lng['admin']['templates']['action'] = 'Action';
$lng['admin']['templates']['email'] = 'Email & file templates';
diff --git a/lng/german.lng.php b/lng/german.lng.php
index 10dcc591..ebe4b676 100644
--- a/lng/german.lng.php
+++ b/lng/german.lng.php
@@ -301,6 +301,7 @@ $lng['admin']['ownvhostsettings'] = 'Eigene vHost-Einstellungen';
$lng['admin']['configfiles']['serverconfiguration'] = 'Konfiguration';
$lng['admin']['templates']['templates'] = 'E-Mail-Vorlagen';
$lng['admin']['templates']['template_add'] = 'Vorlage hinzufügen';
+$lng['admin']['templates']['template_fileadd'] = 'Dateivorlage hinzufügen';
$lng['admin']['templates']['template_edit'] = 'Vorlage bearbeiten';
$lng['admin']['templates']['action'] = 'Aktion';
$lng['admin']['templates']['email'] = 'E-Mail- & Dateivorlagen';
@@ -318,6 +319,7 @@ $lng['admin']['templates']['PASSWORD'] = 'Wird mit dem Passwort des neuen Kunden
$lng['admin']['templates']['EMAIL'] = 'Wird mit der Adresse des neuen E-Mail-Kontos ersetzt.';
$lng['admin']['templates']['CUSTOMER_NO'] = 'Wir mit der Kunden-Nummer ersetzt';
$lng['admin']['bindzonewarning'] = $lng['panel']['emptyfordefault'] . '
WARNUNG: Bei der Verwendung einer Zonendatei müssen alle benötigten Records aller Subdomains ebenfalls manuell verwaltet werden.';
+$lng['error']['templatelanguagecombodefined'] = 'Die gewählte Kombination aus Sprache und Vorlage ist bereits definiert.';
/**
* Serversettings
diff --git a/templates/Froxlor/misc/alertbox.html.twig b/templates/Froxlor/misc/alertbox.html.twig
index 2be5d200..f3c5d591 100644
--- a/templates/Froxlor/misc/alertbox.html.twig
+++ b/templates/Froxlor/misc/alertbox.html.twig
@@ -14,7 +14,7 @@
+