fix nav-sections to be open when active; show error if customer has no (email)domain assigned when trying to add a new address

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-03-04 10:47:22 +01:00
parent 0c93a5166b
commit 7b28a33aba
3 changed files with 20 additions and 11 deletions

View File

@@ -138,16 +138,20 @@ if ($page == 'overview' || $page == 'emails') {
];
}
$email_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_add.php';
if (count($domains) > 0) {
$email_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_add.php';
if (Settings::Get('catchall.catchall_enabled') != '1') {
unset($email_add_data['emails_add']['sections']['section_a']['fields']['iscatchall']);
if (Settings::Get('catchall.catchall_enabled') != '1') {
unset($email_add_data['emails_add']['sections']['section_a']['fields']['iscatchall']);
}
UI::twigBuffer('user/form.html.twig', [
'formaction' => $linker->getLink(array('section' => 'email')),
'formdata' => $email_add_data['emails_add']
]);
UI::twigOutputBuffer();
} else {
\Froxlor\UI\Response::standard_error('noemaildomainaddedyet');
}
UI::twigBuffer('user/form.html.twig', [
'formaction' => $linker->getLink(array('section' => 'email')),
'formdata' => $email_add_data['emails_add']
]);
UI::twigOutputBuffer();
}
} else {
\Froxlor\UI\Response::standard_error('allresourcesused');
@@ -179,7 +183,7 @@ if ($page == 'overview' || $page == 'emails') {
'label' => $lng['panel']['delete'],
'classes' => 'btn btn-sm btn-danger'
];
$forwarders_count ++;
$forwarders_count++;
}
$result['destination'][$dest_id] = $destination;
}

View File

@@ -42,6 +42,7 @@ class HTML
foreach ($navigation as $box) {
if ((!isset($box['show_element']) || $box['show_element'] === true) && (!isset($box['required_resources']) || $box['required_resources'] == '' || (isset($userinfo[$box['required_resources']]) && ((int) $userinfo[$box['required_resources']] > 0 || $userinfo[$box['required_resources']] == '-1')))) {
$navigation_links = [];
$box_active = false;
foreach ($box['elements'] as $element_id => $element) {
if ((!isset($element['show_element']) || $element['show_element'] === true) && (!isset($element['required_resources']) || $element['required_resources'] == '' || (isset($userinfo[$element['required_resources']]) && ((int) $userinfo[$element['required_resources']] > 0 || $userinfo[$element['required_resources']] == '-1')))) {
$target = '';
@@ -66,8 +67,10 @@ class HTML
if (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && isset($_GET['action']) && substr_count($element['url'], "action=" . $_GET['action']) > 0) {
$active = true;
$box_active = true;
} elseif (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && substr_count($element['url'], "action=") == 0 && !isset($_GET['action'])) {
$active = true;
$box_active = true;
}
$navurl = htmlspecialchars($element['url']);
@@ -81,7 +84,7 @@ class HTML
$navigation_links[] = [
'url' => $navurl,
'target' => $target,
'is_active' => $active,
'active' => $active,
'label' => $navlabel,
'icon' => $icon
];
@@ -121,7 +124,8 @@ class HTML
'target' => $target,
'label' => $navlabel,
'icon' => $icon,
'items' => $navigation_links
'items' => $navigation_links,
'active' => $box_active
];
}
}

View File

@@ -40,3 +40,4 @@ $lng['menue']['logger']['logger'] = $lng['admin']['loggersystem'];
$lng['serversettings']['default_sslvhostconf']['description'] = $lng['serversettings']['default_vhostconf']['description'];
$lng['admin']['include_ownvhostsettings'] = $lng['serversettings']['includedefault_sslvhostconf'];
$lng['error']['noemaildomainaddedyet'] = $lng['emails']['noemaildomainaddedyet'];