Skip to content

Commit

Permalink
show email-only domains in customers list for potential dns entries i…
Browse files Browse the repository at this point in the history
…nformation (if necessary)

Signed-off-by: Michael Kaufmann <[email protected]>
  • Loading branch information
d00p committed Jul 19, 2024
1 parent 9d47d67 commit bda24d7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 16 deletions.
7 changes: 4 additions & 3 deletions lib/Froxlor/Api/Commands/SubDomains.php
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,11 @@ public function listing()
'`d`.`letsencrypt`',
'`d`.`registration_date`',
'`d`.`termination_date`',
'`d`.`deactivated`'
'`d`.`deactivated`',
'`d`.`email_only`',
];
}

$query_fields = [];

// prepare select statement
Expand All @@ -996,7 +998,6 @@ public function listing()
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 = [];
Expand Down Expand Up @@ -1092,13 +1093,13 @@ public function listingCount()
$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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Froxlor/Dns/Dns.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function getAllowedDomainEntry(int $domain_id, string $area = 'cus
$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'];
}

Expand Down
10 changes: 7 additions & 3 deletions lib/Froxlor/UI/Callbacks/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public static function domainTarget(array $attributes)
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 [
Expand Down Expand Up @@ -127,7 +130,7 @@ public static function canEdit(array $attributes): bool

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) {
Expand Down Expand Up @@ -157,6 +160,7 @@ public static function canEditDNS(array $attributes): bool
&& $attributes['fields']['caneditdomain'] == '1'
&& Settings::Get('system.bind_enable') == '1'
&& Settings::Get('system.dnsenabled') == '1'
&& !$attributes['fields']['email_only']
&& !$attributes['fields']['deactivated'];
}

Expand All @@ -169,7 +173,7 @@ public static function adminCanEditDNS(array $attributes): bool

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);
}

/**
Expand All @@ -181,7 +185,7 @@ public static function canEditSSL(array $attributes): bool
&& 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;
Expand Down
21 changes: 12 additions & 9 deletions lib/formfields/customer/domains/formfield.domains_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@
'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'],
Expand All @@ -63,49 +64,50 @@
'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',
'select_var' => $redirectcode,
'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',
'select_var' => $serveraliasoptions,
'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',
Expand Down Expand Up @@ -139,7 +141,7 @@
'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'),
Expand Down Expand Up @@ -194,6 +196,7 @@
]
]
]
]
],
'buttons' => ((int)$result['email_only'] == 1) ? [] : null
]
];
1 change: 1 addition & 0 deletions lng/de.lng.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@
'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.<br />Ein Konto ist wie Ihr Briefkasten vor der Haustür. Wenn jemand eine E-Mail an Sie schreibt, wird diese in dieses Konto gelegt.<br /><br />Die Zugangsdaten lauten wie folgt: (Die Angaben in <i>kursiver</i> Schrift sind durch die jeweiligen Einträge zu ersetzen)<br /><br />Hostname: <b><i>Domainname</i></b><br />Benutzername: <b><i>Kontoname / E-Mail-Adresse</i></b><br />Passwort: <b><i>das gewählte Passwort</i></b>',
Expand Down
1 change: 1 addition & 0 deletions lng/en.lng.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@
'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.<br />An account is like your letterbox in front of your house. If someone sends you an email, it will be dropped into the account.<br /><br />To download your emails use the following settings in your mailprogram: (The data in <i>italics</i> has to be changed to the equivalents you typed in!)<br />Hostname: <b><i>domainname</i></b><br />Username: <b><i>account name / e-mail address</i></b><br />password: <b><i>the password you\'ve chosen</i></b>',
Expand Down
4 changes: 4 additions & 0 deletions logfiles_viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
}
$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') {
Expand Down
4 changes: 4 additions & 0 deletions ssl_editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
}
$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 {
Expand Down

0 comments on commit bda24d7

Please sign in to comment.