handle speciallogfile-warning-note when editing domain as admin

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-03-13 16:16:48 +01:00
parent 343339d510
commit 7e9e89e1fd
7 changed files with 52 additions and 36 deletions

View File

@@ -590,8 +590,6 @@ if ($page == 'domains' || $page == 'overview') {
$domain_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/domains/formfield.domains_edit.php';
$speciallogwarning = sprintf($lng['admin']['speciallogwarning'], $lng['admin']['delete_statistics']);
UI::twigBuffer('user/form.html.twig', [
'formaction' => $linker->getLink(array('section' => 'domains', 'id' => $id)),
'formdata' => $domain_edit_data['domain_edit'],
@@ -606,6 +604,23 @@ if ($page == 'domains' || $page == 'overview') {
$allowed_phpconfigs = \Froxlor\Customer\Customer::getCustomerDetail($customerid, 'allowed_phpconfigs');
echo !empty($allowed_phpconfigs) ? $allowed_phpconfigs : json_encode([]);
exit();
} elseif ($action == 'jqSpeciallogfileNote') {
$domainid = intval($_POST['id']);
$newval = intval($_POST['newval']);
try {
$json_result = Domains::getLocal($userinfo, array(
'id' => $domainid
))->get();
} catch (Exception $e) {
\Froxlor\UI\Response::dynamic_error($e->getMessage());
}
$result = json_decode($json_result, true)['data'];
if ($newval != $result['speciallogfile']) {
echo json_encode(['changed' => true, 'info' => $lng['admin']['speciallogwarning']]);
exit();
}
echo 0;
exit();
} elseif ($action == 'import') {
if (isset($_POST['send']) && $_POST['send'] == 'send') {
@@ -660,32 +675,3 @@ if ($page == 'domains' || $page == 'overview') {
require_once __DIR__ . '/logfiles_viewer.php';
}
function formatDomainEntry(&$row, &$idna_convert)
{
$row['domain'] = $idna_convert->decode($row['domain']);
$row['aliasdomain'] = $idna_convert->decode($row['aliasdomain']);
$row['ipandport'] = '';
foreach ($row['ipsandports'] as $rowip) {
if (filter_var($rowip['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$row['ipandport'] .= '[' . $rowip['ip'] . ']:' . $rowip['port'] . "\n";
} else {
$row['ipandport'] .= $rowip['ip'] . ':' . $rowip['port'] . "\n";
}
}
$row['ipandport'] = substr($row['ipandport'], 0, -1);
$row['termination_date'] = str_replace("0000-00-00", "", $row['termination_date']);
$row['termination_css'] = "";
if ($row['termination_date'] != "") {
$cdate = strtotime($row['termination_date'] . " 23:59:59");
$today = time();
if ($cdate < $today) {
$row['termination_css'] = 'domain-expired';
} else {
$row['termination_css'] = 'domain-canceled';
}
}
}

View File

@@ -127,6 +127,10 @@ return array(
'value' => '1',
'checked' => $result['speciallogfile']
),
'speciallogverified' => array(
'type' => 'hidden',
'value' => '0'
),
'specialsettings' => array(
'visible' => ($userinfo['change_serversettings'] == '1' ? true : false),
'label' => $lng['admin']['ownvhostsettings'],

View File

@@ -1555,7 +1555,7 @@ $lng['serversettings']['phpfpm_settings']['idle_timeout']['description'] = 'Time
// ADDED IN 0.9.27-svn2
$lng['panel']['cancel'] = 'Cancel';
$lng['admin']['delete_statistics'] = 'Delete Statistics';
$lng['admin']['speciallogwarning'] = 'WARNING: By changing this setting you will lose all your old statistics for this domain. If you are sure you wish to change this type "%s" in the field below and click the "delete" button.<br /><br />';
$lng['admin']['speciallogwarning'] = '<div id="speciallogfilenote" class="invalid-feedback">WARNING: By changing this setting you will lose all your old statistics for this domain.</div>';
// ADDED IN 0.9.28-svn2
$lng['serversettings']['vmail_maildirname']['title'] = 'Maildir name';

View File

@@ -1278,8 +1278,7 @@ $lng['serversettings']['phpfpm_settings']['idle_timeout']['title'] = 'Idle-Timeo
$lng['serversettings']['phpfpm_settings']['idle_timeout']['description'] = 'Timeout-Einstellung für PHP-FPM FastCGI.';
// ADDED IN 0.9.27-svn2
$lng['admin']['delete_statistics'] = 'Statistiken Löschen';
$lng['admin']['speciallogwarning'] = 'ACHTUNG: Durch diese Einstellungen werden Sie alle bisherige Statistiken dieser Domain verlieren. Wenn Sie dabei wirklich sicher sind, geben Sie bitte folgenden Text in das nachfolgende Textfeld ein: "%s" und bestätigen Sie mit "Löschen".<br /><br />';
$lng['admin']['speciallogwarning'] = '<div id="speciallogfilenote" class="invalid-feedback">ACHTUNG: Durch diese Einstellungen werden Sie alle bisherige Statistiken dieser Domain verlieren.</div>';
// ADDED IN 0.9.28-svn2
$lng['serversettings']['vmail_maildirname']['title'] = 'Maildir-(Unter-)Ordner';

View File

@@ -1502,8 +1502,7 @@ $lng['serversettings']['mod_fcgid']['idle_timeout']['description'] = 'Impostazio
$lng['serversettings']['phpfpm_settings']['idle_timeout']['title'] = 'Timeout Inattività';
$lng['serversettings']['phpfpm_settings']['idle_timeout']['description'] = 'Impostazione Timeout per PHP5 FPM FastCGI.';
$lng['panel']['cancel'] = 'Annulla';
$lng['admin']['delete_statistics'] = 'Elimina Statistiche';
$lng['admin']['speciallogwarning'] = 'AVVISO: Cambiando questa impostazione perderai tutte le vecchie statistiche per questo dominio. Se sei sicuro che vuoi cambiare questo digita "%s" nel campo sottostante e clicca il bottone "elimina".<br /><br />';
$lng['admin']['speciallogwarning'] = '<div id="speciallogfilenote" class="invalid-feedback">AVVISO: Cambiando questa impostazione perderai tutte le vecchie statistiche per questo dominio.</div>';
$lng['serversettings']['vmail_maildirname']['title'] = 'nome Maildir';
$lng['serversettings']['vmail_maildirname']['description'] = 'cartella Maildir nell account utente. Normalmente \'Maildir\', in alcune implementazioni \'.maildir\', e direttamente nella cartella utente se lasciato vuoto.';
$lng['tasks']['DELETE_EMAIL_DATA'] = 'Elimina i dati di posta elettronica del cliente.';

View File

@@ -73,6 +73,7 @@
{% endfor %}
{% 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 %}>
</div>
{% endif %}

View File

@@ -29,4 +29,31 @@ $(document).ready(function () {
});
});
// show warning if speciallogfile option is toggled
if ($('input[name=speciallogverified]')) {
$('input[name=speciallogfile]').click(function () {
$('#speciallogfilenote').remove();
$('#speciallogfile').removeClass('is-invalid');
$('#speciallogverified').val(0);
$.ajax({
url: "admin_domains.php?s=" + window.$session + "&page=overview&action=jqSpeciallogfileNote",
type: "POST",
data: {
id: $('input[name=id]').val(), newval: +$('#speciallogfile').is(':checked')
},
dataType: "json",
success: function (json) {
if (json.changed) {
$('#speciallogfile').addClass('is-invalid');
$('#speciallogfile').parent().append(json.info);
$('#speciallogverified').val(1);
}
},
error: function (a, b) {
console.log(a, b);
}
});
});
}
});