From 205178aa8277442587aae5db76ff5510ebdcc5c9 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 18 Jul 2015 23:02:10 +0545 Subject: Switch logic of $disabled tests system_gateways --- usr/local/www/system_gateways.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/system_gateways.php b/usr/local/www/system_gateways.php index c78b41a..850c5ba 100644 --- a/usr/local/www/system_gateways.php +++ b/usr/local/www/system_gateways.php @@ -90,10 +90,10 @@ function can_delete_disable_gateway_item($id, $disable = false) { foreach ($group['item'] as $item) { $items = explode("|", $item); if ($items[0] == $a_gateways[$id]['name']) { - if ($disable) { - $input_errors[] = sprintf(gettext("Gateway '%s' cannot be disabled because it is in use on Gateway Group '%s'"), $a_gateways[$id]['name'], $group['name']); - } else { + if (!$disable) { $input_errors[] = sprintf(gettext("Gateway '%s' cannot be deleted because it is in use on Gateway Group '%s'"), $a_gateways[$id]['name'], $group['name']); + } else { + $input_errors[] = sprintf(gettext("Gateway '%s' cannot be disabled because it is in use on Gateway Group '%s'"), $a_gateways[$id]['name'], $group['name']); } } } @@ -103,15 +103,13 @@ function can_delete_disable_gateway_item($id, $disable = false) { if (is_array($config['staticroutes']['route'])) { foreach ($config['staticroutes']['route'] as $route) { if ($route['gateway'] == $a_gateways[$id]['name']) { - if ($disable) { - // The user wants to disable this gateway. - if (!isset($route['disabled'])) { - // But there is a static route that uses this gateway and is enabled (not disabled). - $input_errors[] = sprintf(gettext("Gateway '%s' cannot be disabled because it is in use on Static Route '%s'"), $a_gateways[$id]['name'], $route['network']); - } - } else { + if (!$disable) { // The user wants to delete this gateway, but there is a static route (enabled or disabled) that refers to the gateway. $input_errors[] = sprintf(gettext("Gateway '%s' cannot be deleted because it is in use on Static Route '%s'"), $a_gateways[$id]['name'], $route['network']); + } else if (!isset($route['disabled'])) { + // The user wants to disable this gateway. + // But there is a static route that uses this gateway and is enabled (not disabled). + $input_errors[] = sprintf(gettext("Gateway '%s' cannot be disabled because it is in use on Static Route '%s'"), $a_gateways[$id]['name'], $route['network']); } } } -- cgit v1.1