From 3f40fada1bd93dffe8aeebcfde462034ec19deb1 Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Thu, 3 Nov 2022 07:25:18 +0100 Subject: [PATCH] edit page for default domain and mailbox settings --- data/web/edit.php | 107 ++++++---- data/web/templates/edit/domain-defaults.twig | 156 ++++++++++++++ data/web/templates/edit/mailbox-defaults.twig | 195 ++++++++++++++++++ data/web/templates/mailbox.twig | 4 +- 4 files changed, 419 insertions(+), 43 deletions(-) create mode 100644 data/web/templates/edit/domain-defaults.twig create mode 100644 data/web/templates/edit/mailbox-defaults.twig diff --git a/data/web/edit.php b/data/web/edit.php index ff1ccc44e..185e7934b 100644 --- a/data/web/edit.php +++ b/data/web/edit.php @@ -38,24 +38,36 @@ if (isset($_SESSION['mailcow_cc_role'])) { $template = 'edit/admin.twig'; $template_data = ['admin' => $admin]; } - elseif (isset($_GET['domain']) && - is_valid_domain_name($_GET["domain"]) && - !empty($_GET["domain"])) { - $domain = $_GET["domain"]; - $result = mailbox('get', 'domain_details', $domain); - $quota_notification_bcc = quota_notification_bcc('get', $domain); - $rl = ratelimit('get', 'domain', $domain); - $rlyhosts = relayhost('get'); - $template = 'edit/domain.twig'; - $template_data = [ - 'acl' => $_SESSION['acl'], - 'domain' => $domain, - 'quota_notification_bcc' => $quota_notification_bcc, - 'rl' => $rl, - 'rlyhosts' => $rlyhosts, - 'dkim' => dkim('details', $domain), - 'domain_details' => $result, - ]; + elseif (isset($_GET['domain'])) { + if ($_GET['domain'] == "defaults") { + // edit domain default settings + //$result = mailbox('get', 'domain_defaults'); + //$rl = ratelimit('get', 'domain_defaults'); + $result = true; + $template = 'edit/domain-defaults.twig'; + $template_data = [ + // 'rl' => $rl, + ]; + } + elseif (is_valid_domain_name($_GET["domain"]) && + !empty($_GET["domain"])) { + // edit domain + $domain = $_GET["domain"]; + $result = mailbox('get', 'domain_details', $domain); + $quota_notification_bcc = quota_notification_bcc('get', $domain); + $rl = ratelimit('get', 'domain', $domain); + $rlyhosts = relayhost('get'); + $template = 'edit/domain.twig'; + $template_data = [ + 'acl' => $_SESSION['acl'], + 'domain' => $domain, + 'quota_notification_bcc' => $quota_notification_bcc, + 'rl' => $rl, + 'rlyhosts' => $rlyhosts, + 'dkim' => dkim('details', $domain), + 'domain_details' => $result, + ]; + } } elseif (isset($_GET['oauth2client']) && is_numeric($_GET["oauth2client"]) && @@ -79,29 +91,42 @@ if (isset($_SESSION['mailcow_cc_role'])) { 'dkim' => dkim('details', $alias_domain), ]; } - elseif (isset($_GET['mailbox']) && filter_var(html_entity_decode(rawurldecode($_GET["mailbox"])), FILTER_VALIDATE_EMAIL) && !empty($_GET["mailbox"])) { - $mailbox = html_entity_decode(rawurldecode($_GET["mailbox"])); - $result = mailbox('get', 'mailbox_details', $mailbox); - $rl = ratelimit('get', 'mailbox', $mailbox); - $pushover_data = pushover('get', $mailbox); - $quarantine_notification = mailbox('get', 'quarantine_notification', $mailbox); - $quarantine_category = mailbox('get', 'quarantine_category', $mailbox); - $get_tls_policy = mailbox('get', 'tls_policy', $mailbox); - $rlyhosts = relayhost('get'); - $template = 'edit/mailbox.twig'; - $template_data = [ - 'acl' => $_SESSION['acl'], - 'mailbox' => $mailbox, - 'rl' => $rl, - 'pushover_data' => $pushover_data, - 'quarantine_notification' => $quarantine_notification, - 'quarantine_category' => $quarantine_category, - 'get_tls_policy' => $get_tls_policy, - 'rlyhosts' => $rlyhosts, - 'sender_acl_handles' => mailbox('get', 'sender_acl_handles', $mailbox), - 'user_acls' => acl('get', 'user', $mailbox), - 'mailbox_details' => $result - ]; + elseif (isset($_GET['mailbox'])){ + if ($_GET['mailbox'] == "defaults"){ + // edit mailbox default settings + // $result = mailbox('get', 'mailbox_defaults'); + // $rl = ratelimit('get', 'mailbox_defaults'); + $result = true; + $template = 'edit/mailbox-defaults.twig'; + $template_data = [ + // 'rl' => $rl, + ]; + } + elseif(filter_var(html_entity_decode(rawurldecode($_GET["mailbox"])), FILTER_VALIDATE_EMAIL) && !empty($_GET["mailbox"])) { + // edit mailbox + $mailbox = html_entity_decode(rawurldecode($_GET["mailbox"])); + $result = mailbox('get', 'mailbox_details', $mailbox); + $rl = ratelimit('get', 'mailbox', $mailbox); + $pushover_data = pushover('get', $mailbox); + $quarantine_notification = mailbox('get', 'quarantine_notification', $mailbox); + $quarantine_category = mailbox('get', 'quarantine_category', $mailbox); + $get_tls_policy = mailbox('get', 'tls_policy', $mailbox); + $rlyhosts = relayhost('get'); + $template = 'edit/mailbox.twig'; + $template_data = [ + 'acl' => $_SESSION['acl'], + 'mailbox' => $mailbox, + 'rl' => $rl, + 'pushover_data' => $pushover_data, + 'quarantine_notification' => $quarantine_notification, + 'quarantine_category' => $quarantine_category, + 'get_tls_policy' => $get_tls_policy, + 'rlyhosts' => $rlyhosts, + 'sender_acl_handles' => mailbox('get', 'sender_acl_handles', $mailbox), + 'user_acls' => acl('get', 'user', $mailbox), + 'mailbox_details' => $result + ]; + } } elseif (isset($_GET['relayhost']) && is_numeric($_GET["relayhost"]) && !empty($_GET["relayhost"])) { $relayhost = intval($_GET["relayhost"]); diff --git a/data/web/templates/edit/domain-defaults.twig b/data/web/templates/edit/domain-defaults.twig new file mode 100644 index 000000000..84b150dac --- /dev/null +++ b/data/web/templates/edit/domain-defaults.twig @@ -0,0 +1,156 @@ +{% extends 'edit.twig' %} + +{% block inner_content %} +{% if result %} + +
+
+
+
+ + + + + + {% if mailcow_cc_role == 'admin' %} +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ {% endif %} +
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + + + +
+
+
+
+
+
+
+

{{ lang.user.spamfilter_wl }}

+

{{ lang.user.spamfilter_wl_desc|raw }}

+
+
+ + + + +
+
+
+ +
+
+

{{ lang.user.spamfilter_bl }}

+

{{ lang.user.spamfilter_bl_desc|raw }}

+
+
+ + + + +
+
+
+ +
+
+
+
+
+
+

{{ lang.edit.quota_warning_bcc }}

+

{{ lang.edit.quota_warning_bcc_info|raw }}

+
+ +
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+{% else %} + {{ parent() }} +{% endif %} +{% endblock %} diff --git a/data/web/templates/edit/mailbox-defaults.twig b/data/web/templates/edit/mailbox-defaults.twig new file mode 100644 index 000000000..9487c8565 --- /dev/null +++ b/data/web/templates/edit/mailbox-defaults.twig @@ -0,0 +1,195 @@ +{% extends 'edit.twig' %} + +{% block inner_content %} +{% if result %} + +
+
+
+
+ + + + +
+ +
+ + 0 = ∞ +
+
+
+ +
+
+ + + + +
+

{{ lang.user.quarantine_notification_info }}

+
+
+
+ +
+
+ + + +
+

{{ lang.user.quarantine_category_info }}

+
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+ +
+
+
+ +
+
+
+
+
+ + {{ lang.edit.force_pw_update_info|format(ui_texts.main_name) }} +
+
+
+ {% if not skip_sogo %} +
+
+
+ + {{ lang.edit.sogo_access_info }} +
+
+
+ {% endif %} +
+
+ +
+
+
+
+
+
+
+
+

ACL

+
+
+ + +
+
+
+
+
+
+
+
+

{{ lang.acl.ratelimit }}

+
+
+ + + +

{{ lang.edit.mbox_rl_info }}

+
+
+
+
+
+{% else %} + {{ parent() }} +{% endif %} +{% endblock %} diff --git a/data/web/templates/mailbox.twig b/data/web/templates/mailbox.twig index 382a206cd..26215ef27 100644 --- a/data/web/templates/mailbox.twig +++ b/data/web/templates/mailbox.twig @@ -7,7 +7,7 @@ {{ lang.mailbox.domains }} {# #} @@ -16,7 +16,7 @@ {{ lang.mailbox.mailboxes }}