From c2ec309a01588f02c1e2fc0241ded1467ae07e57 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 25 Feb 2022 09:52:35 +0100 Subject: [PATCH 01/13] more work on tablelisting Signed-off-by: Michael Kaufmann --- customer_domains.php | 70 ++------- lib/Froxlor/UI/Callbacks/Domain.php | 47 ++++++ lib/Froxlor/UI/Callbacks/Text.php | 40 ++--- lib/Froxlor/UI/Collection.php | 17 ++- lib/Froxlor/UI/Panel/UI.php | 17 +++ lib/Froxlor/User.php | 2 +- .../domains/formfield.domains_add.php | 19 ++- lib/init.php | 1 + .../admin/tablelisting.customers.php | 137 ++++++++--------- .../admin/tablelisting.domains.php | 144 +++++++++--------- .../customer/tablelisting.domains.php | 79 ++++++++++ 11 files changed, 336 insertions(+), 237 deletions(-) create mode 100644 lib/Froxlor/UI/Callbacks/Domain.php create mode 100644 lib/tablelisting/customer/tablelisting.domains.php diff --git a/customer_domains.php b/customer_domains.php index 6c30cb57..8d250987 100644 --- a/customer_domains.php +++ b/customer_domains.php @@ -39,69 +39,23 @@ if ($page == 'overview') { } elseif ($page == 'domains') { if ($action == '') { $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_domains::domains"); - $fields = array( - 'd.domain_ace' => $lng['domains']['domainname'], - 'd.aliasdomain' => $lng['domains']['aliasdomain'] - ); + + $parentdomain_id = (int) Request::get('pid', '0'); + try { - // get total count - $json_result = SubDomains::getLocal($userinfo)->listingCount(); - $result = json_decode($json_result, true)['data']; - // initialize pagination and filtering - $paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); - // get list - $json_result = SubDomains::getLocal($userinfo, $paging->getApiCommandParams())->listing(); + $domain_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.domains.php'; + $list = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\SubDomains::class, $userinfo)) +// ->addParam(['sql_search' => ['d.parentdomainid' => $parentdomain_id]]) + ->withPagination($domain_list_data['domain_list']['columns']) + ->getList(); } catch (Exception $e) { \Froxlor\UI\Response::dynamic_error($e->getMessage()); } - $result = json_decode($json_result, true)['data']; - $sortcode = $paging->getHtmlSortCode($lng); - $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); - $searchcode = $paging->getHtmlSearchCode($lng); - $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); - $domains = ''; - $parentdomains_count = 0; - $domains_count = $paging->getEntries(); - $domain_array = array(); - - foreach ($result['list'] as $row) { - formatDomainEntry($row, $idna_convert); - if ($row['parentdomainid'] == '0' && $row['caneditdomain'] == '1') { - $parentdomains_count++; - } - $domain_array[$row['parentdomainname']][] = $row; - } - - foreach ($domain_array as $parentdomain => $sdomains) { - // PARENTDOMAIN - if (Settings::Get('system.awstats_enabled') == '1') { - $statsapp = 'awstats'; - } else { - $statsapp = 'webalizer'; - } - $row = [ - 'domain' => $idna_convert->decode($parentdomain) - ]; - eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_delimiter") . "\";"); - - foreach ($sdomains as $domain) { - $row = \Froxlor\PhpHelper::htmlentitiesArray($domain); - - // show docroot nicely - if (strpos($row['documentroot'], $userinfo['documentroot']) === 0) { - $row['documentroot'] = \Froxlor\FileDir::makeCorrectDir(str_replace($userinfo['documentroot'], "/", $row['documentroot'])); - } - // get ssl-ips if activated - $show_ssledit = false; - if (Settings::Get('system.use_ssl') == '1' && \Froxlor\Domain\Domain::domainHasSslIpPort($row['id']) && $row['caneditdomain'] == '1' && $row['letsencrypt'] == 0) { - $show_ssledit = true; - } - eval("\$domains.=\"" . \Froxlor\UI\Template::getTemplate("domains/domains_domain") . "\";"); - } - } - - eval("echo \"" . \Froxlor\UI\Template::getTemplate("domains/domainlist") . "\";"); + UI::twigBuffer('user/table.html.twig', [ + 'listing' => \Froxlor\UI\Listing::format($list, $domain_list_data['domain_list']), + ]); + UI::twigOutputBuffer(); } elseif ($action == 'delete' && $id != 0) { try { $json_result = SubDomains::getLocal($userinfo, array( diff --git a/lib/Froxlor/UI/Callbacks/Domain.php b/lib/Froxlor/UI/Callbacks/Domain.php new file mode 100644 index 00000000..7ba4ad8e --- /dev/null +++ b/lib/Froxlor/UI/Callbacks/Domain.php @@ -0,0 +1,47 @@ + (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Listing + * + */ + +class Domain +{ + public static function domainTarget(string $data, array $attributes): mixed + { + if (empty($attributes['aliasdomain'])) { + // path or redirect + if (preg_match('/^https?\:\/\//', $attributes['documentroot'])) { + return [ + 'type' => 'link', + 'data' => [ + 'text' => $attributes['documentroot'], + 'href' => $attributes['documentroot'], + 'target' => '_blank' + ] + ]; + } else { + // show docroot nicely + if (strpos($attributes['documentroot'], UI::getCurrentUser()['documentroot']) === 0) { + $attributes['documentroot'] = \Froxlor\FileDir::makeCorrectDir(str_replace(UI::getCurrentUser()['documentroot'], "/", $attributes['documentroot'])); + } + return $attributes['documentroot']; + } + } + return UI::getLng('domains.aliasdomain') . ' ' . $attributes['aliasdomain']; + } +} diff --git a/lib/Froxlor/UI/Callbacks/Text.php b/lib/Froxlor/UI/Callbacks/Text.php index 04d9b4e0..cdf3e301 100644 --- a/lib/Froxlor/UI/Callbacks/Text.php +++ b/lib/Froxlor/UI/Callbacks/Text.php @@ -1,4 +1,5 @@ 'boolean', - 'data' => (bool) $data - ]; - } + public static function boolean(?string $data): array + { + return [ + 'type' => 'boolean', + 'data' => (bool) $data + ]; + } - public static function domainWithSan(string $data, array $attributes): array - { - return [ - 'type' => 'domainWithSan', - 'data' => [ - 'domain' => $data, - 'san' => implode(', ', $attributes['san'] ?? []), - ] - ]; - } + public static function domainWithSan(string $data, array $attributes): array + { + return [ + 'type' => 'domainWithSan', + 'data' => [ + 'domain' => $data, + 'san' => implode(', ', $attributes['san'] ?? []), + ] + ]; + } + + public static function customerfullname(string $data, array $attributes): string + { + return \Froxlor\User::getCorrectFullUserDetails($attributes); + } } diff --git a/lib/Froxlor/UI/Collection.php b/lib/Froxlor/UI/Collection.php index 82f216c8..bdc67e7f 100644 --- a/lib/Froxlor/UI/Collection.php +++ b/lib/Froxlor/UI/Collection.php @@ -81,16 +81,23 @@ class Collection public function has(string $column, string $class, string $parentKey = 'id', string $childKey = 'id', array $params = []): Collection { $this->has[] = [ - 'column' => $column, - 'class' => $class, - 'parentKey' => $parentKey, - 'childKey' => $childKey, - 'params' => $params + 'column' => $column, + 'class' => $class, + 'parentKey' => $parentKey, + 'childKey' => $childKey, + 'params' => $params ]; return $this; } + public function addParam(array $keyval): Collection + { + $this->params = array_merge($this->params, $keyval); + + return $this; + } + public function withPagination(array $columns): Collection { // TODO: handle 'sortable' => true in $columns diff --git a/lib/Froxlor/UI/Panel/UI.php b/lib/Froxlor/UI/Panel/UI.php index 9025b610..696ca466 100644 --- a/lib/Froxlor/UI/Panel/UI.php +++ b/lib/Froxlor/UI/Panel/UI.php @@ -35,6 +35,13 @@ class UI */ private static $linker = null; + /** + * current logged in user + * + * @var array + */ + private static $userinfo = []; + /** * default fallback theme * @@ -224,6 +231,16 @@ class UI return self::$linker; } + public static function setCurrentUser($userinfo = null) + { + self::$userinfo = $userinfo; + } + + public static function getCurrentUser(): array + { + return self::$userinfo; + } + public static function setLng($lng = array()) { self::$lng = $lng; diff --git a/lib/Froxlor/User.php b/lib/Froxlor/User.php index 717579e9..0600683d 100644 --- a/lib/Froxlor/User.php +++ b/lib/Froxlor/User.php @@ -24,7 +24,7 @@ class User $returnval = $userinfo['name'] . ', ' . $userinfo['firstname']; } else { if ($userinfo['name'] != '' && $userinfo['firstname'] != '') { - $returnval = $userinfo['name'] . ', ' . $userinfo['firstname'] . ' | ' . $userinfo['company']; + $returnval = $userinfo['name'] . ', ' . $userinfo['firstname'] . '
' . $userinfo['company'] . ''; } else { $returnval = $userinfo['company']; } diff --git a/lib/formfields/customer/domains/formfield.domains_add.php b/lib/formfields/customer/domains/formfield.domains_add.php index 937975e6..914848f0 100644 --- a/lib/formfields/customer/domains/formfield.domains_add.php +++ b/lib/formfields/customer/domains/formfield.domains_add.php @@ -14,6 +14,9 @@ * @package Formfields * */ + +use Froxlor\Settings; + return array( 'domain_add' => array( 'title' => $lng['domains']['subdomain_add'], @@ -41,19 +44,19 @@ return array( ), 'path' => array( 'label' => $lng['panel']['path'], - 'desc' => (\Froxlor\Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescriptionSubdomain'] : null), + 'desc' => (Settings::Get('panel.pathedit') != 'Dropdown' ? $lng['panel']['pathDescriptionSubdomain'] : null), 'type' => $pathSelect['type'], 'select_var' => $pathSelect['select_var'] ?? '', 'value' => $pathSelect['value'], 'note' => $pathSelect['note'] ?? '', ), 'url' => array( - 'visible' => (\Froxlor\Settings::Get('panel.pathedit') == 'Dropdown' ? true : false), + 'visible' => (Settings::Get('panel.pathedit') == 'Dropdown' ? true : false), 'label' => $lng['panel']['urloverridespath'], 'type' => 'text' ), 'redirectcode' => array( - 'visible' => (\Froxlor\Settings::Get('customredirect.enabled') == '1' ? true : false), + 'visible' => (Settings::Get('customredirect.enabled') == '1' ? true : false), 'label' => $lng['domains']['redirectifpathisurl'], 'desc' => $lng['domains']['redirectifpathisurlinfo'], 'type' => 'select', @@ -71,18 +74,18 @@ return array( 'select_var' => $openbasedir ), 'phpsettingid' => array( - 'visible' => (((int) \Froxlor\Settings::Get('system.mod_fcgid') == 1 || (int) \Froxlor\Settings::Get('phpfpm.enabled') == 1) && count($phpconfigs) > 0 ? true : false), + 'visible' => (((int) Settings::Get('system.mod_fcgid') == 1 || (int) Settings::Get('phpfpm.enabled') == 1) && count($phpconfigs) > 0 ? true : false), 'label' => $lng['admin']['phpsettings']['title'], 'type' => 'select', 'select_var' => $phpconfigs, - 'selected' => (int) Settings::Get('phpfpm.enabled') == 1) ? Settings::Get('phpfpm.defaultini') : Settings::Get('system.mod_fcgid_defaultini') + 'selected' => (int) Settings::Get('phpfpm.enabled') == 1 ? Settings::Get('phpfpm.defaultini') : Settings::Get('system.mod_fcgid_defaultini') ) ) ), 'section_bssl' => array( 'title' => $lng['admin']['webserversettings_ssl'], 'image' => 'icons/domain_add.png', - 'visible' => \Froxlor\Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports ? true : false) : false, + 'visible' => Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports ? true : false) : false, 'fields' => array( 'sslenabled' => array( 'label' => $lng['admin']['domain_sslenabled'], @@ -98,7 +101,7 @@ return array( 'checked' => false ), 'letsencrypt' => array( - 'visible' => (\Froxlor\Settings::Get('system.leenabled') == '1' ? true : false), + 'visible' => (Settings::Get('system.leenabled') == '1' ? true : false), 'label' => $lng['customer']['letsencrypt']['title'], 'desc' => $lng['customer']['letsencrypt']['description'], 'type' => 'checkbox', @@ -106,7 +109,7 @@ return array( 'checked' => false ), 'http2' => array( - 'visible' => ($ssl_ipsandports ? true : false) && \Froxlor\Settings::Get('system.webserver') != 'lighttpd' && \Froxlor\Settings::Get('system.http2_support') == '1', + 'visible' => ($ssl_ipsandports ? true : false) && Settings::Get('system.webserver') != 'lighttpd' && Settings::Get('system.http2_support') == '1', 'label' => $lng['admin']['domain_http2']['title'], 'desc' => $lng['admin']['domain_http2']['description'], 'type' => 'checkbox', diff --git a/lib/init.php b/lib/init.php index 5c64f2c6..c82a8320 100644 --- a/lib/init.php +++ b/lib/init.php @@ -362,6 +362,7 @@ if ($nosession == 1 && AREA != 'login') { } UI::twig()->addGlobal('userinfo', ($userinfo ?? [])); +UI::setCurrentUser($userinfo); /** * Logic moved out of lng-file diff --git a/lib/tablelisting/admin/tablelisting.customers.php b/lib/tablelisting/admin/tablelisting.customers.php index 629bf7a4..b431c698 100644 --- a/lib/tablelisting/admin/tablelisting.customers.php +++ b/lib/tablelisting/admin/tablelisting.customers.php @@ -16,81 +16,74 @@ * */ +use Froxlor\UI\Callbacks\Text; use Froxlor\UI\Callbacks\Impersonate; use Froxlor\UI\Callbacks\ProgressBar; use Froxlor\UI\Listing; return [ - 'customer_list' => [ - 'title' => $lng['admin']['customers'], - 'icon' => 'fa-solid fa-user', - 'columns' => [ - 'c.loginname' => [ - 'label' => $lng['login']['username'], - 'column' => 'loginname', - 'format_callback' => [Impersonate::class, 'customer'], - ], - 'a.loginname' => [ - 'label' => $lng['admin']['admin'], - 'column' => 'admin.loginname', - 'format_callback' => [Impersonate::class, 'admin'], - ], - 'c.name' => [ - 'label' => $lng['customer']['name'], - 'column' => 'name', - ], - 'c.email' => [ - 'label' => $lng['customer']['email'], - 'column' => 'email', - ], - 'c.firstname' => [ - 'label' => $lng['customer']['firstname'], - 'column' => 'firstname', - ], - 'c.company' => [ - 'label' => $lng['customer']['company'], - 'column' => 'company', - ], - 'c.diskspace' => [ - 'label' => $lng['customer']['diskspace'], - 'column' => 'diskspace', - 'format_callback' => [ProgressBar::class, 'diskspace'], - ], - 'c.traffic' => [ - 'label' => $lng['customer']['traffic'], - 'column' => 'traffic', - 'format_callback' => [ProgressBar::class, 'traffic'], - ], - ], - 'visible_columns' => Listing::getVisibleColumnsForListing('customer_list', [ - 'c.loginname', - 'a.loginname', - 'c.email', - 'c.firstname', - 'c.company', - 'c.diskspace', - 'c.traffic', - ]), - 'actions' => [ - 'edit' => [ - 'icon' => 'fa fa-edit', - 'href' => [ - 'section' => 'customers', - 'page' => 'customers', - 'action' => 'edit', - 'id' => ':customerid' - ], - ], - 'delete' => [ - 'icon' => 'fa fa-trash', - 'class' => 'text-danger', - 'href' => [ - 'section' => 'customers', - 'page' => 'customers', - 'action' => 'delete', - 'id' => ':customerid' - ], - ], - ], - ] + 'customer_list' => [ + 'title' => $lng['admin']['customers'], + 'icon' => 'fa-solid fa-user', + 'columns' => [ + 'c.name' => [ + 'label' => $lng['customer']['name'], + 'column' => 'name', + 'format_callback' => [Text::class, 'customerfullname'], + ], + 'c.loginname' => [ + 'label' => $lng['login']['username'], + 'column' => 'loginname', + 'format_callback' => [Impersonate::class, 'customer'], + ], + 'a.loginname' => [ + 'label' => $lng['admin']['admin'], + 'column' => 'admin.loginname', + 'format_callback' => [Impersonate::class, 'admin'], + ], + 'c.email' => [ + 'label' => $lng['customer']['email'], + 'column' => 'email', + ], + 'c.diskspace' => [ + 'label' => $lng['customer']['diskspace'], + 'column' => 'diskspace', + 'format_callback' => [ProgressBar::class, 'diskspace'], + ], + 'c.traffic' => [ + 'label' => $lng['customer']['traffic'], + 'column' => 'traffic', + 'format_callback' => [ProgressBar::class, 'traffic'], + ], + ], + 'visible_columns' => Listing::getVisibleColumnsForListing('customer_list', [ + 'c.name', + 'c.loginname', + 'a.loginname', + 'c.email', + 'c.diskspace', + 'c.traffic', + ]), + 'actions' => [ + 'edit' => [ + 'icon' => 'fa fa-edit', + 'href' => [ + 'section' => 'customers', + 'page' => 'customers', + 'action' => 'edit', + 'id' => ':customerid' + ], + ], + 'delete' => [ + 'icon' => 'fa fa-trash', + 'class' => 'text-danger', + 'href' => [ + 'section' => 'customers', + 'page' => 'customers', + 'action' => 'delete', + 'id' => ':customerid' + ], + ], + ], + ] ]; diff --git a/lib/tablelisting/admin/tablelisting.domains.php b/lib/tablelisting/admin/tablelisting.domains.php index fb54fdcc..42001055 100644 --- a/lib/tablelisting/admin/tablelisting.domains.php +++ b/lib/tablelisting/admin/tablelisting.domains.php @@ -16,84 +16,76 @@ * */ +use Froxlor\UI\Callbacks\Text; use Froxlor\UI\Callbacks\Impersonate; use Froxlor\UI\Listing; return [ - 'domain_list' => [ - 'title' => $lng['admin']['domains'], - 'icon' => 'fa-solid fa-user', - 'columns' => [ - 'd.domain_ace' => [ - 'label' => $lng['domains']['domainname'], - 'column' => 'domain_ace', - ], - 'c.name' => [ - 'label' => $lng['customer']['name'], - 'column' => 'customer.name', - ], - 'c.firstname' => [ - 'label' => $lng['customer']['firstname'], - 'column' => 'customer.firstname', - ], - 'c.company' => [ - 'label' => $lng['customer']['company'], - 'column' => 'customer.company', - ], - 'c.loginname' => [ - 'label' => $lng['login']['username'], - 'column' => 'customer.loginname', - 'format_callback' => [Impersonate::class, 'customer'], - ], - 'd.aliasdomain' => [ - 'label' => $lng['domains']['aliasdomain'], - 'column' => 'aliasdomain', - ], - ], - 'visible_columns' => Listing::getVisibleColumnsForListing('domain_list', [ - 'd.domain_ace', - 'c.name', - 'c.firstname', - 'c.company', - 'c.loginname', - 'd.aliasdomain', - ]), - 'actions' => [ - 'edit' => [ - 'icon' => 'fa fa-edit', - 'href' => [ - 'section' => 'domains', - 'page' => 'domains', - 'action' => 'edit', - 'id' => ':id' - ], - ], - 'logfiles' => [ - 'icon' => 'fa fa-file', - 'href' => [ - 'section' => 'domains', - 'page' => 'logfiles', - 'domain_id' => ':id' - ], - ], - 'domaindnseditor' => [ - 'icon' => 'fa fa-globe', - 'href' => [ - 'section' => 'domains', - 'page' => 'domaindnseditor', - 'domain_id' => ':id' - ], - ], - 'delete' => [ - 'icon' => 'fa fa-trash', - 'class' => 'text-danger', - 'href' => [ - 'section' => 'domains', - 'page' => 'domains', - 'action' => 'delete', - 'id' => ':id' - ], - ], - ] - ] + 'domain_list' => [ + 'title' => $lng['admin']['domains'], + 'icon' => 'fa-solid fa-user', + 'columns' => [ + 'd.domain_ace' => [ + 'label' => $lng['domains']['domainname'], + 'column' => 'domain_ace', + ], + 'c.name' => [ + 'label' => $lng['customer']['name'], + 'column' => 'customer.name', + 'format_callback' => [Text::class, 'customerfullname'], + ], + 'c.loginname' => [ + 'label' => $lng['login']['username'], + 'column' => 'customer.loginname', + 'format_callback' => [Impersonate::class, 'customer'], + ], + 'd.aliasdomain' => [ + 'label' => $lng['domains']['aliasdomain'], + 'column' => 'aliasdomain', + ], + ], + 'visible_columns' => Listing::getVisibleColumnsForListing('domain_list', [ + 'd.domain_ace', + 'c.name', + 'c.loginname', + 'd.aliasdomain', + ]), + 'actions' => [ + 'edit' => [ + 'icon' => 'fa fa-edit', + 'href' => [ + 'section' => 'domains', + 'page' => 'domains', + 'action' => 'edit', + 'id' => ':id' + ], + ], + 'logfiles' => [ + 'icon' => 'fa fa-file', + 'href' => [ + 'section' => 'domains', + 'page' => 'logfiles', + 'domain_id' => ':id' + ], + ], + 'domaindnseditor' => [ + 'icon' => 'fa fa-globe', + 'href' => [ + 'section' => 'domains', + 'page' => 'domaindnseditor', + 'domain_id' => ':id' + ], + ], + 'delete' => [ + 'icon' => 'fa fa-trash', + 'class' => 'text-danger', + 'href' => [ + 'section' => 'domains', + 'page' => 'domains', + 'action' => 'delete', + 'id' => ':id' + ], + ] + ] + ] ]; diff --git a/lib/tablelisting/customer/tablelisting.domains.php b/lib/tablelisting/customer/tablelisting.domains.php new file mode 100644 index 00000000..84ba85f5 --- /dev/null +++ b/lib/tablelisting/customer/tablelisting.domains.php @@ -0,0 +1,79 @@ + (2010-) + * @author Maurice Preuß + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Tabellisting + * + */ + +use Froxlor\UI\Callbacks\Domain; +use Froxlor\UI\Listing; + +return [ + 'domain_list' => [ + 'title' => $lng['admin']['domains'], + 'icon' => 'fa-solid fa-user', + 'columns' => [ + 'd.domain_ace' => [ + 'label' => $lng['domains']['domainname'], + 'column' => 'domain_ace', + ], + 'd.documentroot' => [ + 'label' => $lng['panel']['path'], + 'column' => 'documentroot', + 'format_callback' => [Domain::class, 'domainTarget'], + ] + ], + 'visible_columns' => Listing::getVisibleColumnsForListing('domain_list', [ + 'd.domain_ace', + 'd.documentroot' + ]), + 'actions' => [ + 'edit' => [ + 'icon' => 'fa fa-edit', + 'href' => [ + 'section' => 'domains', + 'page' => 'domains', + 'action' => 'edit', + 'id' => ':id' + ], + ], + 'logfiles' => [ + 'icon' => 'fa fa-file', + 'href' => [ + 'section' => 'domains', + 'page' => 'logfiles', + 'domain_id' => ':id' + ], + ], + 'domaindnseditor' => [ + 'icon' => 'fa fa-globe', + 'href' => [ + 'section' => 'domains', + 'page' => 'domaindnseditor', + 'domain_id' => ':id' + ], + ], + 'delete' => [ + 'icon' => 'fa fa-trash', + 'class' => 'text-danger', + 'href' => [ + 'section' => 'domains', + 'page' => 'domains', + 'action' => 'delete', + 'id' => ':id' + ], + ] + ] + ] +]; From 5b675c25a329fed528e4c1b44e4e02448fa6e377 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 25 Feb 2022 10:10:47 +0100 Subject: [PATCH 02/13] don't show SU link for yourself Signed-off-by: Michael Kaufmann --- lib/Froxlor/UI/Callbacks/Impersonate.php | 70 +++++++++++++----------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/lib/Froxlor/UI/Callbacks/Impersonate.php b/lib/Froxlor/UI/Callbacks/Impersonate.php index c9b508f1..3d3bea32 100644 --- a/lib/Froxlor/UI/Callbacks/Impersonate.php +++ b/lib/Froxlor/UI/Callbacks/Impersonate.php @@ -1,4 +1,5 @@ 'link', - 'data' => [ - 'text' => $data, - 'href' => $linker->getLink([ - 'section' => 'admins', - 'page' => 'admins', - 'action' => 'su', - 'id' => $attributes['adminid'], - ]), - ] - ]; - } + public static function admin(string $data, array $attributes): mixed + { + if (UI::getCurrentUser()['adminid'] != $attributes['adminid']) { + $linker = UI::getLinker(); + return [ + 'type' => 'link', + 'data' => [ + 'text' => $data, + 'href' => $linker->getLink([ + 'section' => 'admins', + 'page' => 'admins', + 'action' => 'su', + 'id' => $attributes['adminid'], + ]), + ] + ]; + } + return $data; + } - public static function customer(string $data, array $attributes): array - { - $linker = UI::getLinker(); - return [ - 'type' => 'link', - 'data' => [ - 'text' => $data, - 'href' => $linker->getLink([ - 'section' => 'customers', - 'page' => 'customers', - 'action' => 'su', - 'sort' => $attributes['loginname'], - 'id' => $attributes['customerid'], - ]), - ] - ]; - } + public static function customer(string $data, array $attributes): array + { + $linker = UI::getLinker(); + return [ + 'type' => 'link', + 'data' => [ + 'text' => $data, + 'href' => $linker->getLink([ + 'section' => 'customers', + 'page' => 'customers', + 'action' => 'su', + 'sort' => $attributes['loginname'], + 'id' => $attributes['customerid'], + ]), + ] + ]; + } } From c7cc2d435746248108047da55841ca30b8325e6d Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 25 Feb 2022 11:22:00 +0100 Subject: [PATCH 03/13] email listing Signed-off-by: Michael Kaufmann --- customer_email.php | 91 ++----------------- lib/Froxlor/UI/Callbacks/Email.php | 35 +++++++ .../email/formfield.emails_addaccount.php | 2 +- .../email/formfield.emails_addforwarder.php | 2 +- .../customer/tablelisting.emails.php | 83 +++++++++++++++++ templates/Froxlor/form/formfields.html.twig | 2 +- templates/Froxlor/table/callbacks.html.twig | 11 +++ templates/Froxlor/table/table.html.twig | 2 + 8 files changed, 143 insertions(+), 85 deletions(-) create mode 100644 lib/Froxlor/UI/Callbacks/Email.php create mode 100644 lib/tablelisting/customer/tablelisting.emails.php diff --git a/customer_email.php b/customer_email.php index 93f9da5c..9cd97b8c 100644 --- a/customer_email.php +++ b/customer_email.php @@ -40,91 +40,15 @@ if ($page == 'overview') { } elseif ($page == 'emails') { if ($action == '') { $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_email::emails"); - $fields = array( - 'd.domain_ace' => $lng['domains']['domainname'], - 'm.email_full' => $lng['emails']['emailaddress'], - 'm.destination' => $lng['emails']['forwarders'] - ); + try { - // get total count - $json_result = Emails::getLocal($userinfo)->listingCount(); - $result = json_decode($json_result, true)['data']; - // initialize pagination and filtering - $paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); - // get list - $json_result = Emails::getLocal($userinfo, $paging->getApiCommandParams())->listing(); + $email_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.emails.php'; + $list = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Emails::class, $userinfo)) + ->withPagination($email_list_data['email_list']['columns']) + ->getList(); } catch (Exception $e) { \Froxlor\UI\Response::dynamic_error($e->getMessage()); } - $result = json_decode($json_result, true)['data']; - - $sortcode = $paging->getHtmlSortCode($lng); - $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); - $searchcode = $paging->getHtmlSearchCode($lng); - $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); - $emails = array(); - $emailscount = $paging->getEntries(); - - foreach ($result['list'] as $row) { - if (! isset($emails[$row['domain']]) || ! is_array($emails[$row['domain']])) { - $emails[$row['domain']] = array(); - } - - $emails[$row['domain']][$row['email_full']] = $row; - } - - if ($paging->sortfield == 'd.domain_ace' && $paging->sortorder == 'desc') { - krsort($emails); - } else { - ksort($emails); - } - - $count = 0; - $accounts = ''; - $emails_count = 0; - $domainname = ''; - foreach ($emails as $domainid => $emailaddresses) { - if ($paging->sortfield == 'm.email_full' && $paging->sortorder == 'desc') { - krsort($emailaddresses); - } else { - ksort($emailaddresses); - } - - foreach ($emailaddresses as $row) { - if ($domainname != $idna_convert->decode($row['domain'])) { - $domainname = $idna_convert->decode($row['domain']); - eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_domain") . "\";"); - } - - $emails_count ++; - $row['email'] = $idna_convert->decode($row['email']); - $row['email_full'] = $idna_convert->decode($row['email_full']); - $row['destination'] = explode(' ', $row['destination']); - uasort($row['destination'], 'strcasecmp'); - - $dest_list = $row['destination']; - foreach ($dest_list as $dest_id => $destination) { - $row['destination'][$dest_id] = $idna_convert->decode($row['destination'][$dest_id]); - - if ($row['destination'][$dest_id] == $row['email_full']) { - unset($row['destination'][$dest_id]); - } - } - - $destinations_count = count($row['destination']); - $row['destination'] = implode(', ', $row['destination']); - - if (strlen($row['destination']) > 35) { - $row['destination'] = substr($row['destination'], 0, 32) . '... (' . $destinations_count . ')'; - } - - $row['mboxsize'] = \Froxlor\PhpHelper::sizeReadable($row['mboxsize'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); - - $row = \Froxlor\PhpHelper::htmlentitiesArray($row); - eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_email") . "\";"); - $count ++; - } - } $result_stmt = Database::prepare(" SELECT COUNT(`id`) as emaildomains @@ -136,7 +60,10 @@ if ($page == 'overview') { )); $emaildomains_count = $result2['emaildomains']; - eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails") . "\";"); + UI::twigBuffer('user/table.html.twig', [ + 'listing' => \Froxlor\UI\Listing::format($list, $email_list_data['email_list']), + ]); + UI::twigOutputBuffer(); } elseif ($action == 'delete' && $id != 0) { try { $json_result = Emails::getLocal($userinfo, array( diff --git a/lib/Froxlor/UI/Callbacks/Email.php b/lib/Froxlor/UI/Callbacks/Email.php new file mode 100644 index 00000000..03e1a164 --- /dev/null +++ b/lib/Froxlor/UI/Callbacks/Email.php @@ -0,0 +1,35 @@ + (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Listing + * + */ + +class Email +{ + public static function account(string $data, array $attributes): mixed + { + return [ + 'type' => 'booleanWithInfo', + 'data' => [ + 'checked' => $data != 0, + 'info' => $data != 0 ? PhpHelper::sizeReadable($attributes['mboxsize'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s') : '' + ] + ]; + } +} diff --git a/lib/formfields/customer/email/formfield.emails_addaccount.php b/lib/formfields/customer/email/formfield.emails_addaccount.php index e57db43d..08e3827c 100644 --- a/lib/formfields/customer/email/formfield.emails_addaccount.php +++ b/lib/formfields/customer/email/formfield.emails_addaccount.php @@ -23,7 +23,7 @@ return array( 'title' => $lng['emails']['account_add'], 'image' => 'icons/email_add.png', 'fields' => array( - 'email_full' => array( + 'emailaddr' => array( 'label' => $lng['emails']['emailaddress'], 'type' => 'label', 'value' => $result['email_full'] diff --git a/lib/formfields/customer/email/formfield.emails_addforwarder.php b/lib/formfields/customer/email/formfield.emails_addforwarder.php index 2b3fee44..5900f55f 100644 --- a/lib/formfields/customer/email/formfield.emails_addforwarder.php +++ b/lib/formfields/customer/email/formfield.emails_addforwarder.php @@ -23,7 +23,7 @@ return array( 'title' => $lng['emails']['forwarder_add'], 'image' => 'icons/autoresponder_add.png', 'fields' => array( - 'email_full' => array( + 'emailaddr' => array( 'label' => $lng['emails']['from'], 'type' => 'label', 'value' => $result['email_full'] diff --git a/lib/tablelisting/customer/tablelisting.emails.php b/lib/tablelisting/customer/tablelisting.emails.php new file mode 100644 index 00000000..b4f79cae --- /dev/null +++ b/lib/tablelisting/customer/tablelisting.emails.php @@ -0,0 +1,83 @@ + (2010-) + * @author Maurice Preuß + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Tabellisting + * + */ + +use Froxlor\UI\Callbacks\Email; +use Froxlor\UI\Callbacks\Text; +use Froxlor\UI\Listing; + +return [ + 'email_list' => [ + 'title' => $lng['menue']['email']['emails'], + 'icon' => 'fa-solid fa-envelope', + 'columns' => [ + 'm.email_full' => [ + 'label' => $lng['emails']['emailaddress'], + 'column' => 'email_full', + ], + 'm.destination' => [ + 'label' => $lng['emails']['forwarders'], + 'column' => 'destination', + // @todo formatting + ], + 'm.popaccountid' => [ + 'label' => $lng['emails']['account'], + 'column' => 'popaccountid', + 'format_callback' => [Email::class, 'account'], + ], + 'm.iscatchall' => [ + 'label' => $lng['emails']['catchall'], + 'column' => 'iscatchall', + 'format_callback' => [Text::class, 'boolean'], + 'visible' => \Froxlor\Settings::Get('catchall.catchall_enabled') == '1' + ], + 'm.quota' => [ + 'label' => $lng['emails']['quota'], + 'column' => 'quota', + 'visible' => \Froxlor\Settings::Get('system.mail_quota_enabled') == '1' + ] + ], + 'visible_columns' => Listing::getVisibleColumnsForListing('email_list', [ + 'm.email_full', + 'm.destination', + 'm.popaccountid', + 'm.iscatchall', + 'm.quota' + ]), + 'actions' => [ + 'edit' => [ + 'icon' => 'fa fa-edit', + 'href' => [ + 'section' => 'email', + 'page' => 'emails', + 'action' => 'edit', + 'id' => ':id' + ], + ], + 'delete' => [ + 'icon' => 'fa fa-trash', + 'class' => 'text-danger', + 'href' => [ + 'section' => 'email', + 'page' => 'emails', + 'action' => 'delete', + 'id' => ':id' + ], + ] + ] + ] +]; diff --git a/templates/Froxlor/form/formfields.html.twig b/templates/Froxlor/form/formfields.html.twig index 1304ef99..08920022 100644 --- a/templates/Froxlor/form/formfields.html.twig +++ b/templates/Froxlor/form/formfields.html.twig @@ -53,7 +53,7 @@ {% if field.next_to is defined %}
{% endif %} - + {% if field.next_to is defined %} {% for nid, nfield in field.next_to %} {% if nfield.next_to_prefix is defined %} diff --git a/templates/Froxlor/table/callbacks.html.twig b/templates/Froxlor/table/callbacks.html.twig index 0258ad1d..421bba1e 100644 --- a/templates/Froxlor/table/callbacks.html.twig +++ b/templates/Froxlor/table/callbacks.html.twig @@ -18,6 +18,17 @@ {% endif %} {% endmacro %} +{% macro booleanWithInfo(data) %} + {% if (data.checked) %} + + {% else %} + + {% endif %} + {% if data.info is not empty %} + {{ data.info }} + {% endif %} +{% endmacro %} + {% macro link(data) %} {% apply spaceless %} diff --git a/templates/Froxlor/table/table.html.twig b/templates/Froxlor/table/table.html.twig index 157ee887..cbd7ab65 100644 --- a/templates/Froxlor/table/table.html.twig +++ b/templates/Froxlor/table/table.html.twig @@ -31,6 +31,8 @@ {{ callbacks.progressbar(td.data.data) }} {% elseif td.data.type == 'boolean' %} {{ callbacks.boolean(td.data.data) }} + {% elseif td.data.type == 'booleanWithInfo' %} + {{ callbacks.booleanWithInfo(td.data.data) }} {% elseif td.data.type == 'link' %} {{ callbacks.link(td.data.data) }} {% elseif td.data.type == 'domainWithSan' %} From 038b6f9510dbad12697db4b2e7d3988be3915b75 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 25 Feb 2022 14:25:58 +0100 Subject: [PATCH 04/13] customer ftp/mysql listing Signed-off-by: Michael Kaufmann --- customer_ftp.php | 41 ++-------- customer_mysql.php | 54 +++---------- lib/Froxlor/UI/Callbacks/Ftp.php | 33 ++++++++ lib/Froxlor/UI/Callbacks/Mysql.php | 34 +++++++++ .../customer/tablelisting.ftps.php | 74 ++++++++++++++++++ .../customer/tablelisting.mysqls.php | 76 +++++++++++++++++++ 6 files changed, 236 insertions(+), 76 deletions(-) create mode 100644 lib/Froxlor/UI/Callbacks/Ftp.php create mode 100644 lib/Froxlor/UI/Callbacks/Mysql.php create mode 100644 lib/tablelisting/customer/tablelisting.ftps.php create mode 100644 lib/tablelisting/customer/tablelisting.mysqls.php diff --git a/customer_ftp.php b/customer_ftp.php index 99743677..cd9b40bc 100644 --- a/customer_ftp.php +++ b/customer_ftp.php @@ -38,44 +38,19 @@ if ($page == 'overview') { } elseif ($page == 'accounts') { if ($action == '') { $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_ftp::accounts"); - $fields = array( - 'username' => $lng['login']['username'], - 'homedir' => $lng['panel']['path'], - 'description' => $lng['panel']['ftpdesc'] - ); try { - // get total count - $json_result = Ftps::getLocal($userinfo)->listingCount(); - $result = json_decode($json_result, true)['data']; - // initialize pagination and filtering - $paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); - // get list - $json_result = Ftps::getLocal($userinfo, $paging->getApiCommandParams())->listing(); + $ftp_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.ftps.php'; + $list = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Ftps::class, $userinfo)) + ->withPagination($ftp_list_data['ftp_list']['columns']) + ->getList(); } catch (Exception $e) { \Froxlor\UI\Response::dynamic_error($e->getMessage()); } - $result = json_decode($json_result, true)['data']; - $ftps_count = $paging->getEntries(); - $sortcode = $paging->getHtmlSortCode($lng); - $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); - $searchcode = $paging->getHtmlSearchCode($lng); - $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); - $count = 0; - $accounts = ''; - foreach ($result['list'] as $row) { - if (strpos($row['homedir'], $userinfo['documentroot']) === 0) { - $row['documentroot'] = str_replace($userinfo['documentroot'], "/", $row['homedir']); - } else { - $row['documentroot'] = $row['homedir']; - } - $row['documentroot'] = \Froxlor\FileDir::makeCorrectDir($row['documentroot']); - $row = \Froxlor\PhpHelper::htmlentitiesArray($row); - eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate('ftp/accounts_account') . "\";"); - $count++; - } - - eval("echo \"" . \Froxlor\UI\Template::getTemplate('ftp/accounts') . "\";"); + UI::twigBuffer('user/table.html.twig', [ + 'listing' => \Froxlor\UI\Listing::format($list, $ftp_list_data['ftp_list']), + ]); + UI::twigOutputBuffer(); } elseif ($action == 'delete' && $id != 0) { try { $json_result = Ftps::getLocal($userinfo, array( diff --git a/customer_mysql.php b/customer_mysql.php index 895841e0..4db4fda9 100644 --- a/customer_mysql.php +++ b/customer_mysql.php @@ -47,56 +47,24 @@ if ($page == 'overview') { } elseif ($page == 'mysqls') { if ($action == '') { $log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_mysql::mysqls"); - $fields = array( - 'databasename' => $lng['mysql']['databasename'], - 'description' => $lng['mysql']['databasedescription'] - ); - try { - // get total count - $json_result = Mysqls::getLocal($userinfo)->listingCount(); - $result = json_decode($json_result, true)['data']; - // initialize pagination and filtering - $paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result); - // get list - $json_result = Mysqls::getLocal($userinfo, $paging->getApiCommandParams())->listing(); - } catch (Exception $e) { - \Froxlor\UI\Response::dynamic_error($e->getMessage()); - } - $result = json_decode($json_result, true)['data']; - - $mysqls_count = $paging->getEntries(); - $sortcode = $paging->getHtmlSortCode($lng); - $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); - $searchcode = $paging->getHtmlSearchCode($lng); - $pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s); - $count = 0; - $mysqls = ''; $dbservers_stmt = Database::query("SELECT COUNT(DISTINCT `dbserver`) as numservers FROM `" . TABLE_PANEL_DATABASES . "`"); $dbserver = $dbservers_stmt->fetch(PDO::FETCH_ASSOC); $count_mysqlservers = $dbserver['numservers']; - // Begin root-session - Database::needRoot(true); - foreach ($result['list'] as $row) { - $row = \Froxlor\PhpHelper::htmlentitiesArray($row); - $mbdata_stmt = Database::prepare("SELECT SUM(data_length + index_length) as MB FROM information_schema.TABLES - WHERE table_schema = :table_schema - GROUP BY table_schema"); - $mbdata = Database::pexecute_first($mbdata_stmt, array( - "table_schema" => $row['databasename'] - )); - if (!$mbdata) { - $mbdata = array('MB' => 0); - } - $row['size'] = \Froxlor\PhpHelper::sizeReadable($mbdata['MB'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s'); - eval("\$mysqls.=\"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls_database') . "\";"); - $count++; + try { + $mysql_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.mysqls.php'; + $list = (new \Froxlor\UI\Collection(\Froxlor\Api\Commands\Mysqls::class, $userinfo)) + ->withPagination($mysql_list_data['mysql_list']['columns']) + ->getList(); + } catch (Exception $e) { + \Froxlor\UI\Response::dynamic_error($e->getMessage()); } - Database::needRoot(false); - // End root-session - eval("echo \"" . \Froxlor\UI\Template::getTemplate('mysql/mysqls') . "\";"); + UI::twigBuffer('user/table.html.twig', [ + 'listing' => \Froxlor\UI\Listing::format($list, $mysql_list_data['mysql_list']), + ]); + UI::twigOutputBuffer(); } elseif ($action == 'delete' && $id != 0) { try { diff --git a/lib/Froxlor/UI/Callbacks/Ftp.php b/lib/Froxlor/UI/Callbacks/Ftp.php new file mode 100644 index 00000000..31f575ab --- /dev/null +++ b/lib/Froxlor/UI/Callbacks/Ftp.php @@ -0,0 +1,33 @@ + (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Listing + * + */ + +class Ftp +{ + public static function pathRelative(string $data, array $attributes): string + { + if (strpos($data, UI::getCurrentUser()['documentroot']) === 0) { + $data = str_replace(UI::getCurrentUser()['documentroot'], "/", $data); + } + $data = \Froxlor\FileDir::makeCorrectDir($data); + + return $data; + } +} diff --git a/lib/Froxlor/UI/Callbacks/Mysql.php b/lib/Froxlor/UI/Callbacks/Mysql.php new file mode 100644 index 00000000..f3e83411 --- /dev/null +++ b/lib/Froxlor/UI/Callbacks/Mysql.php @@ -0,0 +1,34 @@ + (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Listing + * + */ + +class Mysql +{ + public static function dbserver(string $data, array $attributes): string + { + // get sql-root access data + Database::needRoot(true, (int) $data); + Database::needSqlData(); + $sql_root = Database::getSqlData(); + Database::needRoot(false); + + return $sql_root['caption'] . '
' . $sql_root['host'] . ''; + } +} diff --git a/lib/tablelisting/customer/tablelisting.ftps.php b/lib/tablelisting/customer/tablelisting.ftps.php new file mode 100644 index 00000000..ce338c49 --- /dev/null +++ b/lib/tablelisting/customer/tablelisting.ftps.php @@ -0,0 +1,74 @@ + (2010-) + * @author Maurice Preuß + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Tabellisting + * + */ + +use Froxlor\UI\Callbacks\Ftp; +use Froxlor\UI\Listing; + +return [ + 'ftp_list' => [ + 'title' => $lng['menue']['ftp']['accounts'], + 'icon' => 'fa-solid fa-users', + 'columns' => [ + 'username' => [ + 'label' => $lng['login']['username'], + 'column' => 'username', + ], + 'description' => [ + 'label' => $lng['panel']['ftpdesc'], + 'column' => 'description' + ], + 'homedir' => [ + 'label' => $lng['panel']['path'], + 'column' => 'homedir', + 'format_callback' => [Ftp::class, 'pathRelative'] + ], + 'shell' => [ + 'label' => $lng['panel']['shell'], + 'column' => 'shell', + 'visible' => \Froxlor\Settings::Get('system.allow_customer_shell') == '1' + ] + ], + 'visible_columns' => Listing::getVisibleColumnsForListing('ftp_list', [ + 'username', + 'description', + 'homedir', + 'shell' + ]), + 'actions' => [ + 'edit' => [ + 'icon' => 'fa fa-edit', + 'href' => [ + 'section' => 'ftp', + 'page' => 'ftps', + 'action' => 'edit', + 'id' => ':id' + ], + ], + 'delete' => [ + 'icon' => 'fa fa-trash', + 'class' => 'text-danger', + 'href' => [ + 'section' => 'ftp', + 'page' => 'ftps', + 'action' => 'delete', + 'id' => ':id' + ], + ] + ] + ] +]; diff --git a/lib/tablelisting/customer/tablelisting.mysqls.php b/lib/tablelisting/customer/tablelisting.mysqls.php new file mode 100644 index 00000000..488037e5 --- /dev/null +++ b/lib/tablelisting/customer/tablelisting.mysqls.php @@ -0,0 +1,76 @@ + (2010-) + * @author Maurice Preuß + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package Tabellisting + * + */ + +use Froxlor\UI\Callbacks\Mysql; +use Froxlor\UI\Callbacks\Text; +use Froxlor\UI\Listing; + +return [ + 'mysql_list' => [ + 'title' => $lng['menue']['mysql']['databases'], + 'icon' => 'fa-solid fa-database', + 'columns' => [ + 'databasename' => [ + 'label' => $lng['mysql']['databasename'], + 'column' => 'databasename', + ], + 'description' => [ + 'label' => $lng['mysql']['databasedescription'], + 'column' => 'description' + ], + 'size' => [ + 'label' => $lng['mysql']['size'], + 'column' => 'size', + 'format_callback' => [Text::class, 'size'] + ], + 'dbserver' => [ + 'label' => $lng['mysql']['mysql_server'], + 'column' => 'dbserver', + 'format_callback' => [Mysql::class, 'dbserver'], + 'visible' => $count_mysqlservers > 1 + ] + ], + 'visible_columns' => Listing::getVisibleColumnsForListing('mysql_list', [ + 'databasename', + 'description', + 'size', + 'dbserver' + ]), + 'actions' => [ + 'edit' => [ + 'icon' => 'fa fa-edit', + 'href' => [ + 'section' => 'mysql', + 'page' => 'mysqls', + 'action' => 'edit', + 'id' => ':id' + ], + ], + 'delete' => [ + 'icon' => 'fa fa-trash', + 'class' => 'text-danger', + 'href' => [ + 'section' => 'mysql', + 'page' => 'mysqls', + 'action' => 'delete', + 'id' => ':id' + ], + ] + ] + ] +]; From 1faa9f17ab83999d224f35bd095ceee08cbbf563 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Fri, 25 Feb 2022 14:30:38 +0100 Subject: [PATCH 05/13] minor icon tweaks Signed-off-by: Michael Kaufmann --- lib/navigation/00.froxlor.main.php | 2 +- templates/Froxlor/userarea.html.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/navigation/00.froxlor.main.php b/lib/navigation/00.froxlor.main.php index 6e9ea20e..755d7286 100644 --- a/lib/navigation/00.froxlor.main.php +++ b/lib/navigation/00.froxlor.main.php @@ -83,7 +83,7 @@ return array( 'url' => 'customer_ftp.php', 'label' => $lng['menue']['ftp']['ftp'], 'show_element' => (! \Froxlor\Settings::IsInList('panel.customer_hide_options', 'ftp')), - 'icon' => 'fa fa-transfer', + 'icon' => 'fa fa-users', 'elements' => array( array( 'url' => 'customer_ftp.php?page=accounts', diff --git a/templates/Froxlor/userarea.html.twig b/templates/Froxlor/userarea.html.twig index 9f77c761..617d9945 100644 --- a/templates/Froxlor/userarea.html.twig +++ b/templates/Froxlor/userarea.html.twig @@ -43,7 +43,7 @@