fomfields for admin/domains and some fixes in tablelistings

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-03-10 16:39:49 +01:00
parent 5def8c1635
commit 9c60cf006f
13 changed files with 224 additions and 137 deletions

View File

@@ -5,6 +5,7 @@ namespace Froxlor\UI\Callbacks;
use Froxlor\FileDir;
use Froxlor\Settings;
use Froxlor\UI\Panel\UI;
use Froxlor\Domain\Domain as DDomain;
/**
* This file is part of the Froxlor project.
@@ -22,6 +23,20 @@ use Froxlor\UI\Panel\UI;
*/
class Domain
{
public static function domainWithCustomerLink(array $attributes)
{
$linker = UI::getLinker();
$result = '<a href="https://' . $attributes['data'] . '" target="_blank">' . $attributes['data'] . '</a>';
$result .= ' (<a href="' . $linker->getLink([
'section' => 'customers',
'page' => 'customers',
'action' => 'su',
'sort' => $attributes['fields']['loginname'],
'id' => $attributes['fields']['customerid'],
]) . '">' . $attributes['fields']['loginname'] . '</a>)';
return $result;
}
public static function domainTarget(array $attributes)
{
if (empty($attributes['fields']['aliasdomain'])) {
@@ -85,14 +100,31 @@ class Domain
&& Settings::Get('system.dnsenabled') == '1';
}
public function canEditSSL(array $attributes): bool
public static function hasLetsEncryptActivated(array $attributes): bool
{
// FIXME: https://github.com/Froxlor/Froxlor/blob/master/templates/Sparkle/customer/domains/domains_domain.tpl#L41
return (bool) $attributes['fields']['letsencrypt'];
}
public static function canEditSSL(array $attributes): bool
{
if (
Settings::Get('system.use_ssl') == '1'
&& DDomain::domainHasSslIpPort($attributes['fields']['id'])
&& $attributes['fields']['caneditdomain'] == '1'
&& $attributes['fields']['letsencrypt'] == 0
) {
return true;
}
return false;
}
public function canEditAlias(array $attributes): bool
public static function canEditAlias(array $attributes): bool
{
return !empty($attributes['fields']['domainaliasid']);
}
public static function isAssigned(array $attributes): bool
{
return ($attributes['fields']['parentdomainid'] == 0 && empty($attributes['fields']['domainaliasid']));
}
}

View File

@@ -39,6 +39,7 @@ return array(
'label' => $lng['admin']['admin'],
'type' => 'select',
'select_var' => $admins,
'selected' => $userinfo['adminid'],
'mandatory' => true
),
'alias' => array(
@@ -63,7 +64,7 @@ return array(
'label' => $lng['domains']['add_date'],
'desc' => $lng['panel']['dateformat'],
'type' => 'label',
'value' => $add_date
'value' => date('Y-m-d')
),
'registration_date' => array(
'label' => $lng['domains']['registration_date'],
@@ -102,7 +103,8 @@ return array(
'label' => $lng['admin']['selectserveralias'],
'desc' => $lng['admin']['selectserveralias_desc'],
'type' => 'select',
'select_var' => $serveraliasoptions
'select_var' => $serveraliasoptions,
'selected' => \Froxlor\Settings::Get('system.domaindefaultalias')
),
'speciallogfile' => array(
'label' => $lng['admin']['speciallogfile']['title'],
@@ -223,7 +225,7 @@ return array(
),
array(
'value' => 'TLSv1.3',
'label' => 'TLSv1.3<'
'label' => 'TLSv1.3'
)
),
'is_array' => 1
@@ -328,7 +330,7 @@ return array(
'label' => $lng['admin']['phpsettings']['title'],
'type' => 'select',
'select_var' => $phpconfigs,
'selected' => '@TODO'
'selected' => (int) \Froxlor\Settings::Get('phpfpm.enabled') == 1 ? \Froxlor\Settings::Get('phpfpm.defaultini') : \Froxlor\Settings::Get('system.mod_fcgid_defaultini')
),
'mod_fcgid_starter' => array(
'visible' => ((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 ? true : false),
@@ -380,7 +382,7 @@ return array(
'label' => $lng['admin']['subdomainforemail'],
'type' => 'select',
'select_var' => $subcanemaildomain,
'selected' => '@TODO'
'selected' => 0
),
'dkim' => array(
'visible' => (\Froxlor\Settings::Get('dkim.use_dkim') == '1' ? true : false),

View File

@@ -26,22 +26,23 @@ return array(
'domain' => array(
'label' => 'Domain',
'type' => 'label',
'value' => $result['domain'],
'mandatory' => true
'value' => $result['domain_ace']
),
'customerid' => array(
'label' => $lng['admin']['customer'],
'type' => (\Froxlor\Settings::Get('panel.allow_domain_change_customer') == '1' ? 'select' : 'label'),
'type' => (\Froxlor\Settings::Get('panel.allow_domain_change_customer') == '1' ? 'select' : 'infotext'),
'select_var' => (isset($customers) ? $customers : null),
'selected' => (isset($result['customername']) ? $result['customername'] : null),
'selected' => $result['customerid'],
'value' => (isset($result['customername']) ? $result['customername'] : null),
'mandatory' => true
),
'adminid' => array(
'visible' => ($userinfo['customers_see_all'] == '1' ? true : false),
'label' => $lng['admin']['admin'],
'type' => (\Froxlor\Settings::Get('panel.allow_domain_change_admin') == '1' ? 'select' : 'label'),
'select_var' => (isset($admins) ? $admins : null),
'selected' => (isset($result['adminname']) ? $result['adminname'] : null),
'type' => (\Froxlor\Settings::Get('panel.allow_domain_change_admin') == '1' ? 'select' : 'infotext'),
'select_var' => (!empty($admins) ? $admins : null),
'selected' => (isset($result['adminid']) ? $result['adminid'] : $userinfo['adminid']),
'value' => (isset($result['adminname']) ? $result['adminname'] : null),
'mandatory' => true
),
'alias' => array(
@@ -49,14 +50,14 @@ return array(
'label' => $lng['domains']['aliasdomain'],
'type' => 'select',
'select_var' => $domains,
'selected' => '@TODO'
'selected' => $result['aliasdomain']
),
'issubof' => array(
'label' => $lng['domains']['issubof'],
'desc' => $lng['domains']['issubofinfo'],
'type' => 'select',
'select_var' => $subtodomains,
'selected' => '@TODO'
'selected' => $result['ismainbutsubto']
),
'associated_info' => array(
'label' => $lng['domains']['associated_with_domain'],
@@ -74,7 +75,7 @@ return array(
'label' => $lng['domains']['add_date'],
'desc' => $lng['panel']['dateformat'],
'type' => 'label',
'value' => $result['add_date']
'value' => date('Y-m-d', (int) $result['add_date'])
),
'registration_date' => array(
'label' => $lng['domains']['registration_date'],
@@ -117,7 +118,7 @@ return array(
'desc' => $lng['admin']['selectserveralias_desc'],
'type' => 'select',
'select_var' => $serveraliasoptions,
'selected' => '@TODO'
'selected' => $result['iswildcarddomain'] == '1' ? 0 : ($result['wwwserveralias'] == '1' ? 1 : 2)
),
'speciallogfile' => array(
'label' => $lng['admin']['speciallogfile']['title'],
@@ -229,7 +230,7 @@ return array(
'label' => $lng['serversettings']['ssl']['ssl_protocols']['title'],
'desc' => $lng['serversettings']['ssl']['ssl_protocols']['description'],
'type' => 'checkbox',
'value' => ! empty($result['ssl_protocols']) ? explode(",", $result['ssl_protocols']) : explode(",", \Froxlor\Settings::Get('system.ssl_protocols')),
'value' => !empty($result['ssl_protocols']) ? explode(",", $result['ssl_protocols']) : explode(",", \Froxlor\Settings::Get('system.ssl_protocols')),
'values' => array(
array(
'value' => 'TLSv1',
@@ -255,14 +256,14 @@ return array(
'label' => $lng['serversettings']['ssl']['ssl_cipher_list']['title'],
'desc' => $lng['serversettings']['ssl']['ssl_cipher_list']['description'],
'type' => 'text',
'value' => ! empty($result['ssl_cipher_list']) ? $result['ssl_cipher_list'] : \Froxlor\Settings::Get('system.ssl_cipher_list')
'value' => !empty($result['ssl_cipher_list']) ? $result['ssl_cipher_list'] : \Froxlor\Settings::Get('system.ssl_cipher_list')
),
'tlsv13_cipher_list' => array(
'visible' => (($ssl_ipsandports != '' ? true : false) && $userinfo['change_serversettings'] == '1' && \Froxlor\Settings::Get('system.webserver') == "apache2" && \Froxlor\Settings::Get('system.apache24') == 1 ? true : false),
'label' => $lng['serversettings']['ssl']['tlsv13_cipher_list']['title'],
'desc' => $lng['serversettings']['ssl']['tlsv13_cipher_list']['description'],
'type' => 'text',
'value' => ! empty($result['tlsv13_cipher_list']) ? $result['tlsv13_cipher_list'] : \Froxlor\Settings::Get('system.tlsv13_cipher_list')
'value' => !empty($result['tlsv13_cipher_list']) ? $result['tlsv13_cipher_list'] : \Froxlor\Settings::Get('system.tlsv13_cipher_list')
),
'ssl_specialsettings' => array(
'visible' => ($userinfo['change_serversettings'] == '1' ? true : false),
@@ -350,7 +351,7 @@ return array(
'label' => $lng['admin']['phpsettings']['title'],
'type' => 'select',
'select_var' => $phpconfigs,
'selected' => '@TODO'
'selected' => $result['phpsettingid']
),
'phpsettingsforsubdomains' => array(
'visible' => ($userinfo['change_serversettings'] == '1' ? true : false),
@@ -364,13 +365,13 @@ return array(
'visible' => ((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 ? true : false),
'label' => $lng['admin']['mod_fcgid_starter']['title'],
'type' => 'number',
'value' => ((int) $result['mod_fcgid_starter'] != - 1 ? $result['mod_fcgid_starter'] : '')
'value' => ((int) $result['mod_fcgid_starter'] != -1 ? $result['mod_fcgid_starter'] : '')
),
'mod_fcgid_maxrequests' => array(
'visible' => ((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 ? true : false),
'label' => $lng['admin']['mod_fcgid_maxrequests']['title'],
'type' => 'number',
'value' => ((int) $result['mod_fcgid_maxrequests'] != - 1 ? $result['mod_fcgid_maxrequests'] : '')
'value' => ((int) $result['mod_fcgid_maxrequests'] != -1 ? $result['mod_fcgid_maxrequests'] : '')
)
)
),
@@ -413,7 +414,7 @@ return array(
'label' => $lng['admin']['subdomainforemail'],
'type' => 'select',
'select_var' => $subcanemaildomain,
'selected' => '@TODO'
'selected' => $result['subcanemaildomain']
),
'dkim' => array(
'visible' => (\Froxlor\Settings::Get('dkim.use_dkim') == '1' ? true : false),

View File

@@ -43,14 +43,14 @@ return array(
'image' => 'icons/ipsports_add.png',
'fields' => array(
'listen_statement' => array(
'visible' => ! $is_nginx,
'visible' => ! \Froxlor\Settings::Get('system.webserver') == 'nginx',
'label' => $lng['admin']['ipsandports']['create_listen_statement'],
'type' => 'checkbox',
'value' => '1',
'checked' => true
),
'namevirtualhost_statement' => array(
'visible' => $is_apache && ! $is_apache24,
'visible' => \Froxlor\Settings::Get('system.webserver') == 'apache2' && (int) \Froxlor\Settings::Get('system.apache24') == 0,
'label' => $lng['admin']['ipsandports']['create_namevirtualhost_statement'],
'type' => 'checkbox',
'value' => '1',
@@ -75,7 +75,7 @@ return array(
'rows' => 12
),
'vhostcontainer_servername_statement' => array(
'visible' => $is_apache,
'visible' => \Froxlor\Settings::Get('system.webserver') == 'apache2',
'label' => $lng['admin']['ipsandports']['create_vhostcontainer_servername_statement'],
'type' => 'checkbox',
'value' => '1',

View File

@@ -44,14 +44,14 @@ return array(
'image' => 'icons/ipsports_edit.png',
'fields' => array(
'listen_statement' => array(
'visible' => ! $is_nginx,
'visible' => ! \Froxlor\Settings::Get('system.webserver') == 'nginx',
'label' => $lng['admin']['ipsandports']['create_listen_statement'],
'type' => 'checkbox',
'value' => '1',
'checked' => $result['listen_statement']
),
'namevirtualhost_statement' => array(
'visible' => $is_apache && ! $is_apache24,
'visible' => \Froxlor\Settings::Get('system.webserver') == 'apache2' && (int) \Froxlor\Settings::Get('system.apache24') == 0,
'label' => $lng['admin']['ipsandports']['create_namevirtualhost_statement'],
'type' => 'checkbox',
'value' => '1',
@@ -78,7 +78,7 @@ return array(
'value' => $result['specialsettings']
),
'vhostcontainer_servername_statement' => array(
'visible' => $is_apache,
'visible' => \Froxlor\Settings::Get('system.webserver') == 'apache2',
'label' => $lng['admin']['ipsandports']['create_vhostcontainer_servername_statement'],
'type' => 'checkbox',
'value' => '1',

View File

@@ -82,10 +82,21 @@ return [
],
'visible' => [Domain::class, 'adminCanEditDNS']
],
'domainssleditor' => [
'icon' => 'fa fa-shield',
'title' => $lng['panel']['ssleditor'], // @todo different certificate types by $row['domain_hascert']
'href' => [
'section' => 'domains',
'page' => 'domainssleditor',
'action' => 'view',
'id' => ':id'
],
'visible' => [Domain::class, 'adminCanEditDNS']
],
'letsencrypt' => [
'icon' => 'fa fa-shield',
'title' => $lng['panel']['letsencrypt'],
'visible' => ':letsencrypt' // @fixme
'visible' => [Domain::class, 'hasLetsEncryptActivated']
],
'delete' => [
'icon' => 'fa fa-trash',

View File

@@ -17,6 +17,7 @@
*/
use Froxlor\Settings;
use Froxlor\UI\Callbacks\Domain;
use Froxlor\UI\Callbacks\SSLCertificate;
use Froxlor\UI\Callbacks\Text;
use Froxlor\UI\Listing;
@@ -28,7 +29,8 @@ return [
'columns' => [
'd.domain' => [
'label' => $lng['domains']['domainname'],
'field' => 'domain',
'field' => 'domains.domain_ace',
'callback' => [Domain::class, 'domainWithCustomerLink'],
],
'c.domain' => [
'label' => $lng['ssl_certificates']['certificate_for'],

View File

@@ -70,10 +70,37 @@ return [
],
'visible' => [Domain::class, 'canEditDNS']
],
'domainssleditor' => [
'icon' => 'fa fa-shield',
'title' => $lng['panel']['ssleditor'], // @todo different certificate types by $row['domain_hascert']
'href' => [
'section' => 'domains',
'page' => 'domainssleditor',
'action' => 'view',
'id' => ':id'
],
'visible' => [Domain::class, 'adminCanEditDNS']
],
'letsencrypt' => [
'icon' => 'fa fa-shield',
'title' => $lng['panel']['letsencrypt'],
'visible' => ':letsencrypt' // @fixme
'visible' => [Domain::class, 'hasLetsEncryptActivated']
],
'haslias' => [
'icon' => 'fa fa-arrow-up-right-from-square',
'title' => $lng['domains']['hasaliasdomains'],
'href' => [
'section' => 'domains',
'page' => 'domains',
'searchfield' => 'd.aliasdomain',
'searchtext' => ':id'
],
'visible' => [Domain::class, 'canEditAlias']
],
'isassigned' => [
'icon' => 'fa-check-to-slot',
'title' => $lng['domains']['isassigneddomain'],
'visible' => [Domain::class, 'isAssigned']
],
'delete' => [
'icon' => 'fa fa-trash',