From 13b6ab0b074109d5dace8e753488a7e6107a47b5 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sun, 24 Sep 2023 16:04:20 +0200 Subject: [PATCH] add documentation links to customer-ui for certain entities; add setting to allow menu to be expanded Signed-off-by: Michael Kaufmann --- actions/admin/settings/100.panel.php | 10 ++++- customer_domains.php | 21 +++++---- customer_email.php | 32 ++++++++++---- customer_extras.php | 50 ++++++++++++++++------ customer_ftp.php | 16 ++++--- customer_mysql.php | 21 +++++---- install/froxlor.sql.php | 1 + install/updates/froxlor/update_2.1.inc.php | 4 ++ lib/Froxlor/UI/HTML.php | 4 +- lng/de.lng.php | 4 ++ lng/en.lng.php | 4 ++ templates/Froxlor/user/form.html.twig | 5 ++- templates/Froxlor/user/logfiles.html.twig | 4 +- templates/Froxlor/user/table.html.twig | 2 +- 14 files changed, 129 insertions(+), 49 deletions(-) diff --git a/actions/admin/settings/100.panel.php b/actions/admin/settings/100.panel.php index 18a64def..40691a26 100644 --- a/actions/admin/settings/100.panel.php +++ b/actions/admin/settings/100.panel.php @@ -337,7 +337,15 @@ return [ 'image_name' => 'logo_login', 'default' => '', 'save_method' => 'storeSettingImage' - ] + ], + 'panel_menu_collapsed' => [ + 'label' => lng('serversettings.panel_menu_collapsed'), + 'settinggroup' => 'panel', + 'varname' => 'menu_collapsed', + 'type' => 'checkbox', + 'default' => true, + 'save_method' => 'storeSettingField', + ], ] ] ] diff --git a/customer_domains.php b/customer_domains.php index 944b4143..af3c0068 100644 --- a/customer_domains.php +++ b/customer_domains.php @@ -27,6 +27,7 @@ const AREA = 'customer'; require __DIR__ . '/lib/init.php'; use Froxlor\Api\Commands\SubDomains as SubDomains; +use Froxlor\CurrentUser; use Froxlor\Database\Database; use Froxlor\Domain\Domain; use Froxlor\FileDir; @@ -40,7 +41,6 @@ use Froxlor\UI\Panel\UI; use Froxlor\UI\Request; use Froxlor\UI\Response; use Froxlor\Validate\Validate; -use Froxlor\CurrentUser; // redirect if this customer page is hidden via settings if (Settings::IsInList('panel.customer_hide_options', 'domains')) { @@ -63,16 +63,21 @@ if ($page == 'overview' || $page == 'domains') { Response::dynamicError($e->getMessage()); } - $actions_links = false; + $actions_links = []; if (CurrentUser::canAddResource('subdomains')) { - $actions_links = [ - [ - 'href' => $linker->getLink(['section' => 'domains', 'page' => 'domains', 'action' => 'add']), - 'label' => lng('domains.subdomain_add') - ] + $actions_links[] = [ + 'href' => $linker->getLink(['section' => 'domains', 'page' => 'domains', 'action' => 'add']), + 'label' => lng('domains.subdomain_add') ]; } + $actions_links[] = [ + 'href' => 'https://docs.froxlor.org/v2/user-guide/domains/', + 'target' => '_blank', + 'icon' => 'fa-solid fa-circle-info', + 'class' => 'btn-outline-secondary' + ]; + $table_tpl = 'table.html.twig'; if ($collection->count() == 0) { $table_tpl = 'table-note.html.twig'; @@ -239,7 +244,7 @@ if ($page == 'overview' || $page == 'domains') { if (isset($result['customerid']) && $result['customerid'] == $userinfo['customerid']) { - if ((int) $result['caneditdomain'] == 0) { + if ((int)$result['caneditdomain'] == 0) { Response::standardError('domaincannotbeedited', $result['domain']); } diff --git a/customer_email.php b/customer_email.php index ca311caa..0373317f 100644 --- a/customer_email.php +++ b/customer_email.php @@ -27,9 +27,10 @@ const AREA = 'customer'; require __DIR__ . '/lib/init.php'; use Froxlor\Api\Commands\EmailAccounts; +use Froxlor\Api\Commands\EmailDomains; use Froxlor\Api\Commands\EmailForwarders; use Froxlor\Api\Commands\Emails; -use Froxlor\Api\Commands\EmailDomains; +use Froxlor\CurrentUser; use Froxlor\Database\Database; use Froxlor\FroxlorLogger; use Froxlor\PhpHelper; @@ -41,7 +42,6 @@ use Froxlor\UI\Panel\UI; use Froxlor\UI\Request; use Froxlor\UI\Response; use Froxlor\Validate\Check; -use Froxlor\CurrentUser; // redirect if this customer page is hidden via settings if (Settings::IsInList('panel.customer_hide_options', 'email') || $userinfo['emails'] == 0) { @@ -67,14 +67,24 @@ if ($page == 'overview' || $page == 'emails') { Response::dynamicError($e->getMessage()); } + $actions_links = []; + if (CurrentUser::canAddResource('emails')) { + $actions_links[] = [ + 'href' => $linker->getLink(['section' => 'email', 'page' => 'email_domain', 'action' => 'add']), + 'label' => lng('emails.emails_add') + ]; + } + + $actions_links[] = [ + 'href' => 'https://docs.froxlor.org/v2/user-guide/emails/', + 'target' => '_blank', + 'icon' => 'fa-solid fa-circle-info', + 'class' => 'btn-outline-secondary' + ]; + UI::view('user/table.html.twig', [ 'listing' => Listing::format($collection, $emaildomain_list_data, 'emaildomain_list'), - 'actions_links' => CurrentUser::canAddResource('emails') ? [ - [ - 'href' => $linker->getLink(['section' => 'email', 'page' => 'email_domain', 'action' => 'add']), - 'label' => lng('emails.emails_add') - ] - ] : null, + 'actions_links' => $actions_links, ]); } else { // only emails for one domain -> show email address listing directly @@ -127,6 +137,12 @@ if ($page == 'email_domain') { 'label' => lng('emails.emails_add') ]; } + $actions_links[] = [ + 'href' => 'https://docs.froxlor.org/v2/user-guide/emails/', + 'target' => '_blank', + 'icon' => 'fa-solid fa-circle-info', + 'class' => 'btn-outline-secondary' + ]; UI::view('user/table.html.twig', [ 'listing' => Listing::format($collection, $email_list_data, 'email_list'), diff --git a/customer_extras.php b/customer_extras.php index f5a850f2..2caae923 100644 --- a/customer_extras.php +++ b/customer_extras.php @@ -68,14 +68,22 @@ if ($page == 'overview' || $page == 'htpasswds') { Response::dynamicError($e->getMessage()); } + $actions_links = []; + $actions_links[] = [ + 'href' => $linker->getLink(['section' => 'extras', 'page' => 'htpasswds', 'action' => 'add']), + 'label' => lng('extras.directoryprotection_add') + ]; + + $actions_links[] = [ + 'href' => 'https://docs.froxlor.org/v2/user-guide/extras/', + 'target' => '_blank', + 'icon' => 'fa-solid fa-circle-info', + 'class' => 'btn-outline-secondary' + ]; + UI::view('user/table.html.twig', [ 'listing' => Listing::format($collection, $htpasswd_list_data, 'htpasswd_list'), - 'actions_links' => [ - [ - 'href' => $linker->getLink(['section' => 'extras', 'page' => 'htpasswds', 'action' => 'add']), - 'label' => lng('extras.directoryprotection_add') - ] - ], + 'actions_links' => $actions_links, 'entity_info' => lng('extras.description') ]); } elseif ($action == 'delete' && $id != 0) { @@ -185,14 +193,22 @@ if ($page == 'overview' || $page == 'htpasswds') { Response::dynamicError($e->getMessage()); } + $actions_links = []; + $actions_links[] = [ + 'href' => $linker->getLink(['section' => 'extras', 'page' => 'htaccess', 'action' => 'add']), + 'label' => lng('extras.pathoptions_add') + ]; + + $actions_links[] = [ + 'href' => 'https://docs.froxlor.org/v2/user-guide/extras/', + 'target' => '_blank', + 'icon' => 'fa-solid fa-circle-info', + 'class' => 'btn-outline-secondary' + ]; + UI::view('user/table.html.twig', [ 'listing' => Listing::format($collection, $htaccess_list_data, 'htaccess_list'), - 'actions_links' => [ - [ - 'href' => $linker->getLink(['section' => 'extras', 'page' => 'htaccess', 'action' => 'add']), - 'label' => lng('extras.pathoptions_add') - ] - ], + 'actions_links' => $actions_links, 'entity_info' => lng('extras.description') ]); } elseif ($action == 'delete' && $id != 0) { @@ -331,9 +347,19 @@ if ($page == 'overview' || $page == 'htpasswds') { $pathSelect = FileDir::makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid']); $export_data = include_once dirname(__FILE__) . '/lib/formfields/customer/extras/formfield.export.php'; + $actions_links = [ + [ + 'href' => 'https://docs.froxlor.org/v2/user-guide/extras/', + 'target' => '_blank', + 'icon' => 'fa-solid fa-circle-info', + 'class' => 'btn-outline-secondary' + ] + ]; + UI::view('user/form-datatable.html.twig', [ 'formaction' => $linker->getLink(['section' => 'extras']), 'formdata' => $export_data['export'], + 'actions_links' => $actions_links, 'tabledata' => Listing::format($collection, $export_list_data, 'export_list'), ]); } diff --git a/customer_ftp.php b/customer_ftp.php index 5fd78fe2..8ddb6199 100644 --- a/customer_ftp.php +++ b/customer_ftp.php @@ -27,6 +27,7 @@ const AREA = 'customer'; require __DIR__ . '/lib/init.php'; use Froxlor\Api\Commands\Ftps as Ftps; +use Froxlor\CurrentUser; use Froxlor\Database\Database; use Froxlor\FileDir; use Froxlor\FroxlorLogger; @@ -37,7 +38,6 @@ use Froxlor\UI\Listing; use Froxlor\UI\Panel\UI; use Froxlor\UI\Request; use Froxlor\UI\Response; -use Froxlor\CurrentUser; // redirect if this customer page is hidden via settings if (Settings::IsInList('panel.customer_hide_options', 'ftp')) { @@ -57,15 +57,19 @@ if ($page == 'overview' || $page == 'accounts') { Response::dynamicError($e->getMessage()); } - $actions_links = false; + $actions_links = []; if (CurrentUser::canAddResource('ftps')) { $actions_links = [ - [ - 'href' => $linker->getLink(['section' => 'ftp', 'page' => 'accounts', 'action' => 'add']), - 'label' => lng('ftp.account_add') - ] + 'href' => $linker->getLink(['section' => 'ftp', 'page' => 'accounts', 'action' => 'add']), + 'label' => lng('ftp.account_add') ]; } + $actions_links[] = [ + 'href' => 'https://docs.froxlor.org/v2/user-guide/ftp-accounts/', + 'target' => '_blank', + 'icon' => 'fa-solid fa-circle-info', + 'class' => 'btn-outline-secondary' + ]; UI::view('user/table.html.twig', [ 'listing' => Listing::format($collection, $ftp_list_data, 'ftp_list'), diff --git a/customer_mysql.php b/customer_mysql.php index 1caa2eda..2330df7b 100644 --- a/customer_mysql.php +++ b/customer_mysql.php @@ -28,6 +28,7 @@ require __DIR__ . '/lib/init.php'; use Froxlor\Api\Commands\Mysqls; use Froxlor\Api\Commands\MysqlServer; +use Froxlor\CurrentUser; use Froxlor\Database\Database; use Froxlor\FroxlorLogger; use Froxlor\Settings; @@ -37,7 +38,6 @@ use Froxlor\UI\Listing; use Froxlor\UI\Panel\UI; use Froxlor\UI\Request; use Froxlor\UI\Response; -use Froxlor\CurrentUser; // redirect if this customer page is hidden via settings or no resources given if (Settings::IsInList('panel.customer_hide_options', 'mysql') || $userinfo['mysqls'] == 0) { @@ -66,16 +66,21 @@ if ($page == 'overview' || $page == 'mysqls') { Response::dynamicError($e->getMessage()); } - $actions_links = false; + $actions_links = []; if (CurrentUser::canAddResource('mysqls')) { - $actions_links = [ - [ - 'href' => $linker->getLink(['section' => 'mysql', 'page' => 'mysqls', 'action' => 'add']), - 'label' => lng('mysql.database_create') - ] + $actions_links[] = [ + 'href' => $linker->getLink(['section' => 'mysql', 'page' => 'mysqls', 'action' => 'add']), + 'label' => lng('mysql.database_create') ]; } + $actions_links[] = [ + 'href' => 'https://docs.froxlor.org/v2/user-guide/databases/', + 'target' => '_blank', + 'icon' => 'fa-solid fa-circle-info', + 'class' => 'btn-outline-secondary' + ]; + UI::view('user/table.html.twig', [ 'listing' => Listing::format($collection, $mysql_list_data, 'mysql_list'), 'actions_links' => $actions_links, @@ -179,7 +184,7 @@ if ($page == 'overview' || $page == 'mysqls') { $result_json = MysqlServer::getLocal($userinfo)->listing(); $result_decoded = json_decode($result_json, true)['data']['list']; foreach ($result_decoded as $dbserver => $dbdata) { - $mysql_servers[$dbserver] = $dbdata['caption'] . ' (' . $dbdata['host'] . (isset($dbdata['port']) && !empty($dbdata['port']) ? ':' . $dbdata['port'] : '').')'; + $mysql_servers[$dbserver] = $dbdata['caption'] . ' (' . $dbdata['host'] . (isset($dbdata['port']) && !empty($dbdata['port']) ? ':' . $dbdata['port'] : '') . ')'; } } catch (Exception $e) { /* just none */ diff --git a/install/froxlor.sql.php b/install/froxlor.sql.php index fabae64b..25734520 100644 --- a/install/froxlor.sql.php +++ b/install/froxlor.sql.php @@ -743,6 +743,7 @@ opcache.validate_timestamps'), ('panel', 'logo_overridetheme', '0'), ('panel', 'logo_overridecustom', '0'), ('panel', 'settings_mode', '0'), + ('panel', 'menu_collapsed', '1'), ('panel', 'version', '2.1.0-dev1'), ('panel', 'db_version', '202305240'); diff --git a/install/updates/froxlor/update_2.1.inc.php b/install/updates/froxlor/update_2.1.inc.php index eeed5e6b..1d58504a 100644 --- a/install/updates/froxlor/update_2.1.inc.php +++ b/install/updates/froxlor/update_2.1.inc.php @@ -53,6 +53,10 @@ if (Froxlor::isDatabaseVersion('202304260')) { Database::query($sql); Update::lastStepStatus(0); + Update::showUpdateStep("Adding new settings"); + Settings::AddNew('panel.menu_collapsed', 1); + Update::lastStepStatus(0); + Update::showUpdateStep("Adjusting setting for deactivated webroot"); $current_deactivated_webroot = Settings::Get('system.deactivateddocroot'); if (empty($current_deactivated_webroot)) { diff --git a/lib/Froxlor/UI/HTML.php b/lib/Froxlor/UI/HTML.php index 6fc398df..181399b1 100644 --- a/lib/Froxlor/UI/HTML.php +++ b/lib/Froxlor/UI/HTML.php @@ -25,6 +25,8 @@ namespace Froxlor\UI; +use Froxlor\Settings; + class HTML { @@ -116,7 +118,7 @@ class HTML 'label' => $navlabel, 'icon' => $icon, 'items' => $navigation_links, - 'active' => $box_active + 'active' => ((int)Settings::Get('panel.menu_collapsed') == 0 ? 1 : $box_active) ]; } } diff --git a/lng/de.lng.php b/lng/de.lng.php index 269837c1..5a9b4ac9 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -2096,6 +2096,10 @@ Vielen Dank, Ihr Administrator', 'description' => 'Zeit in Sekunden für die maximale Anzahl von HTTP-Anfragen, Standard ist "60".', ], 'option_requires_otp' => 'Das Ändern dieser Einstellung erfordert OTP Validierung', + 'panel_menu_collapsed' => [ + 'title' => 'Menüabschnitte einklappen', + 'description' => 'Bei Deaktivierung werden die Menübereiche auf der linken Seite immer aufgeklappt angezeigt.', + ], ], 'spf' => [ 'use_spf' => 'Aktiviere SPF für Domains?', diff --git a/lng/en.lng.php b/lng/en.lng.php index 410b3c4c..4bbd6f39 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -2222,6 +2222,10 @@ Yours sincerely, your administrator', 'description' => 'Specify the time in seconds for the number of HTTP requests, default is "60"', ], 'option_requires_otp' => 'This setting requires an OTP validation', + 'panel_menu_collapsed' => [ + 'title' => 'Collapse menu-sections', + 'description' => 'If deactivated, the left-side menu sections will always be expanded.', + ], ], 'spf' => [ 'use_spf' => 'Activate SPF for domains?', diff --git a/templates/Froxlor/user/form.html.twig b/templates/Froxlor/user/form.html.twig index 2e960287..fce9afe0 100644 --- a/templates/Froxlor/user/form.html.twig +++ b/templates/Froxlor/user/form.html.twig @@ -32,8 +32,9 @@ {% if actions_links is iterable %} {% for link in actions_links %} {% if link.visible is not defined or (link.visible is defined and link.visible == true) %} - - {{ link.label }} + + + {% if link.label is defined and link.label is not empty %}{{ link.label }}{% endif %} {% endif %} {% endfor %} diff --git a/templates/Froxlor/user/logfiles.html.twig b/templates/Froxlor/user/logfiles.html.twig index f8be277d..226876a6 100644 --- a/templates/Froxlor/user/logfiles.html.twig +++ b/templates/Froxlor/user/logfiles.html.twig @@ -15,9 +15,9 @@
{% if actions_links is iterable %} {% for link in actions_links %} - + - {{ link.label }} + {% if link.label is defined and link.label is not empty %}{{ link.label }}{% endif %} {% endfor %} {% endif %} diff --git a/templates/Froxlor/user/table.html.twig b/templates/Froxlor/user/table.html.twig index feb119fc..4568f5ff 100644 --- a/templates/Froxlor/user/table.html.twig +++ b/templates/Froxlor/user/table.html.twig @@ -34,7 +34,7 @@ {% if actions_links is iterable %} {% for link in actions_links %} {% if link.visible is not defined or (link.visible is defined and link.visible == true) %} - + {% if link.label is defined and link.label is not empty %}{{ link.label }}{% endif %}