From bda24d7d6364d9c8609ea6fb55fc8bb7ccb0990e Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 19 Jul 2024 22:16:41 +0200 Subject: [PATCH] show email-only domains in customers list for potential dns entries information (if necessary) Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/SubDomains.php | 7 ++++--- lib/Froxlor/Dns/Dns.php | 2 +- lib/Froxlor/UI/Callbacks/Domain.php | 10 ++++++--- .../domains/formfield.domains_edit.php | 21 +++++++++++-------- lng/de.lng.php | 1 + lng/en.lng.php | 1 + logfiles_viewer.php | 4 ++++ ssl_editor.php | 4 ++++ 8 files changed, 34 insertions(+), 16 deletions(-) diff --git a/lib/Froxlor/Api/Commands/SubDomains.php b/lib/Froxlor/Api/Commands/SubDomains.php index 6c796234..1c4870c2 100644 --- a/lib/Froxlor/Api/Commands/SubDomains.php +++ b/lib/Froxlor/Api/Commands/SubDomains.php @@ -983,9 +983,11 @@ class SubDomains extends ApiCommand implements ResourceEntity '`d`.`letsencrypt`', '`d`.`registration_date`', '`d`.`termination_date`', - '`d`.`deactivated`' + '`d`.`deactivated`', + '`d`.`email_only`', ]; } + $query_fields = []; // prepare select statement @@ -996,7 +998,6 @@ class SubDomains extends ApiCommand implements ResourceEntity LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `da` ON `da`.`aliasdomain`=`d`.`id` LEFT JOIN `" . TABLE_PANEL_DOMAINS . "` `pd` ON `pd`.`id`=`d`.`parentdomainid` WHERE `d`.`customerid` IN (" . implode(', ', $customer_ids) . ") - AND `d`.`email_only` = '0' " . $this->getSearchWhere($query_fields, true) . " GROUP BY `d`.`id` ORDER BY `parentdomainname` ASC, `d`.`parentdomainid` ASC " . $this->getOrderBy(true) . $this->getLimit()); $result = []; @@ -1092,13 +1093,13 @@ class SubDomains extends ApiCommand implements ResourceEntity $this->getUserDetail('customerid') ]; } + if (!empty($customer_ids)) { // prepare select statement $domains_stmt = Database::prepare(" SELECT COUNT(*) as num_subdom FROM `" . TABLE_PANEL_DOMAINS . "` `d` WHERE `d`.`customerid` IN (" . implode(', ', $customer_ids) . ") - AND `d`.`email_only` = '0' "); $result = Database::pexecute_first($domains_stmt, null, true, true); if ($result) { diff --git a/lib/Froxlor/Dns/Dns.php b/lib/Froxlor/Dns/Dns.php index a8ca8771..b49a7e22 100644 --- a/lib/Froxlor/Dns/Dns.php +++ b/lib/Froxlor/Dns/Dns.php @@ -54,7 +54,7 @@ class Dns $dom_data['uid'] = $userinfo['userid']; } } else { - $where_clause = '`customerid` = :uid AND '; + $where_clause = '`customerid` = :uid AND `email_only` = "0" AND '; $dom_data['uid'] = $userinfo['userid']; } diff --git a/lib/Froxlor/UI/Callbacks/Domain.php b/lib/Froxlor/UI/Callbacks/Domain.php index b8fb3f68..f635ae25 100644 --- a/lib/Froxlor/UI/Callbacks/Domain.php +++ b/lib/Froxlor/UI/Callbacks/Domain.php @@ -74,6 +74,9 @@ class Domain if ($attributes['fields']['deactivated']) { return lng('admin.deactivated'); } + if ($attributes['fields']['email_only']) { + return lng('domains.email_only'); + } // path or redirect if (preg_match('/^https?\:\/\//', $attributes['fields']['documentroot'])) { return [ @@ -127,7 +130,7 @@ class Domain public static function canViewLogs(array $attributes): bool { - if ((!CurrentUser::isAdmin() || (CurrentUser::isAdmin() && (int)$attributes['fields']['email_only'] == 0)) && !$attributes['fields']['deactivated']) { + if ((int)$attributes['fields']['email_only'] == 0 && !$attributes['fields']['deactivated']) { if ((int)UI::getCurrentUser()['adminsession'] == 0 && (bool)UI::getCurrentUser()['logviewenabled']) { return true; } elseif ((int)UI::getCurrentUser()['adminsession'] == 1) { @@ -157,6 +160,7 @@ class Domain && $attributes['fields']['caneditdomain'] == '1' && Settings::Get('system.bind_enable') == '1' && Settings::Get('system.dnsenabled') == '1' + && !$attributes['fields']['email_only'] && !$attributes['fields']['deactivated']; } @@ -169,7 +173,7 @@ class Domain public static function hasLetsEncryptActivated(array $attributes): bool { - return ((bool)$attributes['fields']['letsencrypt'] && (!CurrentUser::isAdmin() || (CurrentUser::isAdmin() && (int)$attributes['fields']['email_only'] == 0))); + return ((bool)$attributes['fields']['letsencrypt'] && (int)$attributes['fields']['email_only'] == 0); } /** @@ -181,7 +185,7 @@ class Domain && DDomain::domainHasSslIpPort($attributes['fields']['id']) && (CurrentUser::isAdmin() || (!CurrentUser::isAdmin() && (int)$attributes['fields']['caneditdomain'] == 1)) && (int)$attributes['fields']['letsencrypt'] == 0 - && (!CurrentUser::isAdmin() || (CurrentUser::isAdmin() && (int)$attributes['fields']['email_only'] == 0)) + && !(int)$attributes['fields']['email_only'] && !$attributes['fields']['deactivated'] ) { return true; diff --git a/lib/formfields/customer/domains/formfield.domains_edit.php b/lib/formfields/customer/domains/formfield.domains_edit.php index 47dde7bb..6e0ab1cc 100644 --- a/lib/formfields/customer/domains/formfield.domains_edit.php +++ b/lib/formfields/customer/domains/formfield.domains_edit.php @@ -47,13 +47,14 @@ return [ 'values' => $domainips ], 'alias' => [ - 'visible' => $alias_check == '0', + 'visible' => $alias_check == '0' && (int)$result['email_only'] == 0, 'label' => lng('domains.aliasdomain'), 'type' => 'select', 'select_var' => $domains, 'selected' => $result['aliasdomain'] ], 'path' => [ + 'visible' => (int)$result['email_only'] == 0, 'label' => lng('panel.path'), 'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? lng('panel.pathDescriptionSubdomain').(Settings::Get('system.documentroot_use_default_value') == 1 ? lng('panel.pathDescriptionEx') : '') : null), 'type' => $pathSelect['type'], @@ -63,13 +64,13 @@ return [ 'note' => $pathSelect['note'] ?? '', ], 'url' => [ - 'visible' => Settings::Get('panel.pathedit') == 'Dropdown', + 'visible' => Settings::Get('panel.pathedit') == 'Dropdown' && (int)$result['email_only'] == 0, 'label' => lng('panel.urloverridespath'), 'type' => 'text', 'value' => $urlvalue ], 'redirectcode' => [ - 'visible' => Settings::Get('customredirect.enabled') == '1', + 'visible' => Settings::Get('customredirect.enabled') == '1' && (int)$result['email_only'] == 0, 'label' => lng('domains.redirectifpathisurl'), 'desc' => lng('domains.redirectifpathisurlinfo'), 'type' => 'select', @@ -77,7 +78,7 @@ return [ 'selected' => $def_code ], 'selectserveralias' => [ - 'visible' => ($result['parentdomainid'] == '0' && $userinfo['subdomains'] != '0') || $result['parentdomainid'] != '0', + 'visible' => (($result['parentdomainid'] == '0' && $userinfo['subdomains'] != '0') || $result['parentdomainid'] != '0') && (int)$result['email_only'] == 0, 'label' => lng('admin.selectserveralias'), 'desc' => lng('admin.selectserveralias_desc'), 'type' => 'select', @@ -85,27 +86,28 @@ return [ 'selected' => $serveraliasoptions_selected ], 'isemaildomain' => [ - 'visible' => ($result['subcanemaildomain'] == '1' || $result['subcanemaildomain'] == '2') && $result['parentdomainid'] != '0', + 'visible' => (($result['subcanemaildomain'] == '1' || $result['subcanemaildomain'] == '2') && $result['parentdomainid'] != '0') && (int)$result['email_only'] == 0, 'label' => 'Emaildomain', 'type' => 'checkbox', 'value' => '1', 'checked' => $result['isemaildomain'] ], 'openbasedir_path' => [ - 'visible' => $result['openbasedir'] == '1', + 'visible' => $result['openbasedir'] == '1' && (int)$result['email_only'] == 0, 'label' => lng('domain.openbasedirpath'), 'type' => 'select', 'select_var' => $openbasedir, 'selected' => $result['openbasedir_path'] ], 'phpsettingid' => [ - 'visible' => ((int)Settings::Get('system.mod_fcgid') == 1 || (int)Settings::Get('phpfpm.enabled') == 1) && count($phpconfigs) > 0 && $userinfo['phpenabled'] == '1' && $result['phpenabled'] == '1', + 'visible' => ((int)Settings::Get('system.mod_fcgid') == 1 || (int)Settings::Get('phpfpm.enabled') == 1) && count($phpconfigs) > 0 && $userinfo['phpenabled'] == '1' && $result['phpenabled'] == '1' && (int)$result['email_only'] == 0, 'label' => lng('admin.phpsettings.title'), 'type' => 'select', 'select_var' => $phpconfigs, 'selected' => $result['phpsettingid'] ], 'speciallogfile' => [ + 'visible' => (int)$result['email_only'] == 0, 'label' => lng('admin.speciallogfile.title'), 'desc' => lng('admin.speciallogfile.description'), 'type' => 'checkbox', @@ -139,7 +141,7 @@ return [ 'section_bssl' => [ 'title' => lng('admin.webserversettings_ssl'), 'image' => 'icons/domain_edit.png', - 'visible' => Settings::Get('system.use_ssl') == '1' && $ssl_ipsandports && Domain::domainHasSslIpPort($result['id']), + 'visible' => Settings::Get('system.use_ssl') == '1' && $ssl_ipsandports && Domain::domainHasSslIpPort($result['id']) && (int)$result['email_only'] == 0, 'fields' => [ 'sslenabled' => [ 'label' => lng('admin.domain_sslenabled'), @@ -194,6 +196,7 @@ return [ ] ] ] - ] + ], + 'buttons' => ((int)$result['email_only'] == 1) ? [] : null ] ]; diff --git a/lng/de.lng.php b/lng/de.lng.php index 8a3eb506..119cb0d0 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -713,6 +713,7 @@ return [ 'hsts' => 'HSTS aktiviert', 'aliasdomainid' => 'ID der Alias-Domain', 'nodomainsassignedbyadmin' => 'Diesem Account wurde noch keine (aktive) Domain zugewiesen. Bitte kontaktiere deinen Administrator, wenn du der Meinung bist, das ist nicht korrekt.', + 'email_only' => 'Nur E-Mail', ], 'emails' => [ 'description' => 'Hier können Sie Ihre E-Mail-Adressen einrichten.
Ein Konto ist wie Ihr Briefkasten vor der Haustür. Wenn jemand eine E-Mail an Sie schreibt, wird diese in dieses Konto gelegt.

Die Zugangsdaten lauten wie folgt: (Die Angaben in kursiver Schrift sind durch die jeweiligen Einträge zu ersetzen)

Hostname: Domainname
Benutzername: Kontoname / E-Mail-Adresse
Passwort: das gewählte Passwort', diff --git a/lng/en.lng.php b/lng/en.lng.php index 112686c7..d1cbb0c4 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -784,6 +784,7 @@ return [ 'hsts' => 'HSTS enabled', 'aliasdomainid' => 'ID of alias domain', 'nodomainsassignedbyadmin' => 'Your account has currently no (active) domains assigned to it. Please contact your administrator if you think this is wrong.', + 'email_only' => 'Email only', ], 'emails' => [ 'description' => 'Here you can create and change your email addresses.
An account is like your letterbox in front of your house. If someone sends you an email, it will be dropped into the account.

To download your emails use the following settings in your mailprogram: (The data in italics has to be changed to the equivalents you typed in!)
Hostname: domainname
Username: account name / e-mail address
password: the password you\'ve chosen', diff --git a/logfiles_viewer.php b/logfiles_viewer.php index 20d00d7c..e3a65872 100644 --- a/logfiles_viewer.php +++ b/logfiles_viewer.php @@ -61,6 +61,10 @@ if (function_exists('exec')) { } $domain = json_decode($json_result, true)['data']; + if ($domain['email_only']) { + Response::dynamicError("There are no webserver logfiles for email only domains."); + } + $speciallogfile = ''; if ($domain['speciallogfile'] == '1') { if ($domain['parentdomainid'] == '0') { diff --git a/ssl_editor.php b/ssl_editor.php index b0d1c770..8fea36d9 100644 --- a/ssl_editor.php +++ b/ssl_editor.php @@ -50,6 +50,10 @@ if ($action == '' || $action == 'view') { } $result_domain = json_decode($json_result, true)['data']; + if ($result_domain['email_only']) { + Response::dynamicError("There are no ssl-certificates for email only domains."); + } + if (Request::post('send') == 'send') { $do_insert = Request::post('do_insert', 0) == 1; try {