Commit 32b572c9 authored by Franco Fichtner's avatar Franco Fichtner

firewall: finish disabled banner

o Deduplicate inside guiconfig.inc, one word needs to be changed...
o No spurious functions unless needed, it will likely linger forever.
o Be less specific about what the function will do, it may change.
o Remove "dismissable", there's no use dismissing static alerts.
o Zap filter switch case, firewall is used in the GUI anyway.
o Mop up the manual instances of the early pull request still present.
o Transform gettext(html) into sprintf(gettext, html).
parent 168de680
...@@ -603,7 +603,7 @@ include("head.inc"); ...@@ -603,7 +603,7 @@ include("head.inc");
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php print_service_disabled_banner('firewall'); ?> <?php print_service_banner('firewall'); ?>
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?> <?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12"> <section class="col-xs-12">
......
...@@ -85,7 +85,7 @@ include("head.inc"); ...@@ -85,7 +85,7 @@ include("head.inc");
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php print_service_disabled_banner('firewall'); ?> <?php print_service_banner('firewall'); ?>
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?> <?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12"> <section class="col-xs-12">
......
...@@ -61,7 +61,7 @@ include("head.inc"); ...@@ -61,7 +61,7 @@ include("head.inc");
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php print_service_disabled_banner('firewall'); ?> <?php print_service_banner('firewall'); ?>
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?> <?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12"> <section class="col-xs-12">
......
...@@ -111,7 +111,7 @@ include("head.inc"); ?> ...@@ -111,7 +111,7 @@ include("head.inc"); ?>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php print_service_disabled_banner('firewall'); ?> <?php print_service_banner('firewall'); ?>
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?> <?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12"> <section class="col-xs-12">
<div class="tab-content content-box col-xs-12"> <div class="tab-content content-box col-xs-12">
......
...@@ -70,7 +70,7 @@ $( document ).ready(function() { ...@@ -70,7 +70,7 @@ $( document ).ready(function() {
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid col-xs-12"> <div class="container-fluid col-xs-12">
<div class="row"> <div class="row">
<?php print_service_disabled_banner('firewall'); ?> <?php print_service_banner('firewall'); ?>
<section class="col-xs-12"> <section class="col-xs-12">
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs"> <ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<?php <?php
......
...@@ -226,9 +226,7 @@ $( document ).ready(function() { ...@@ -226,9 +226,7 @@ $( document ).ready(function() {
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php if (isset($config['system']['disablefilter'])): ?> <?php print_service_banner('firewall'); ?>
<?php print_warning_box(gettext("The firewall has globally been disabled. Configured rules are currently not enforced."));?>
<?php endif; ?>
<?php if (isset($savemsg)) print_info_box($savemsg); ?> <?php if (isset($savemsg)) print_info_box($savemsg); ?>
<?php if (is_subsystem_dirty('natconf')): ?> <?php if (is_subsystem_dirty('natconf')): ?>
<?php print_info_box_apply(gettext("The NAT configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br /> <?php print_info_box_apply(gettext("The NAT configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br />
......
...@@ -176,10 +176,8 @@ $main_buttons = array( ...@@ -176,10 +176,8 @@ $main_buttons = array(
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php if (isset($config['system']['disablefilter'])): ?>
<?php print_warning_box(gettext("The firewall has globally been disabled. Configured rules are currently not enforced."));?>
<?php endif; ?>
<?php <?php
print_service_banner('firewall');
if (isset($savemsg)) if (isset($savemsg))
print_info_box($savemsg); print_info_box($savemsg);
if (is_subsystem_dirty('natconf')) if (is_subsystem_dirty('natconf'))
......
...@@ -177,9 +177,7 @@ $main_buttons = array( ...@@ -177,9 +177,7 @@ $main_buttons = array(
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php if (isset($config['system']['disablefilter'])): ?> <?php print_service_banner('firewall'); ?>
<?php print_warning_box(gettext("The firewall has globally been disabled. Configured rules are currently not enforced."));?>
<?php endif; ?>
<?php if (isset($savemsg)) print_info_box($savemsg); ?> <?php if (isset($savemsg)) print_info_box($savemsg); ?>
<?php if (is_subsystem_dirty('natconf')): ?> <?php if (is_subsystem_dirty('natconf')): ?>
<?php print_info_box_apply(gettext("The NAT configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br /> <?php print_info_box_apply(gettext("The NAT configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br />
......
...@@ -247,10 +247,8 @@ include("head.inc"); ...@@ -247,10 +247,8 @@ include("head.inc");
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php if (isset($config['system']['disablefilter'])): ?>
<?php print_warning_box(gettext("The firewall has globally been disabled. Configured rules are currently not enforced."));?>
<?php endif; ?>
<?php <?php
print_service_banner('firewall');
if (isset($savemsg)) if (isset($savemsg))
print_info_box($savemsg); print_info_box($savemsg);
if (is_subsystem_dirty('natconf')) if (is_subsystem_dirty('natconf'))
......
...@@ -199,7 +199,7 @@ $( document ).ready(function() { ...@@ -199,7 +199,7 @@ $( document ).ready(function() {
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php print_service_disabled_banner('firewall'); ?> <?php print_service_banner('firewall'); ?>
<?php if (isset($savemsg)) print_info_box($savemsg); ?> <?php if (isset($savemsg)) print_info_box($savemsg); ?>
<?php if (is_subsystem_dirty('filter')): ?><p> <?php if (is_subsystem_dirty('filter')): ?><p>
<?php print_info_box_apply(gettext("The firewall rule configuration has been changed.<br />You must apply the changes in order for them to take effect."));?> <?php print_info_box_apply(gettext("The firewall rule configuration has been changed.<br />You must apply the changes in order for them to take effect."));?>
......
...@@ -189,8 +189,9 @@ function do_input_validation($postdata, $reqdfields, $reqdfieldsn, &$input_error ...@@ -189,8 +189,9 @@ function do_input_validation($postdata, $reqdfields, $reqdfieldsn, &$input_error
} }
} }
function print_input_errors($input_errors) { function print_input_errors($input_errors)
echo '<div class="col-xs-12"><div class="alert alert-danger alert-dismissible" role="alert"> {
echo '<div class="col-xs-12"><div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button> <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
'; ';
...@@ -201,6 +202,18 @@ function print_input_errors($input_errors) { ...@@ -201,6 +202,18 @@ function print_input_errors($input_errors) {
echo "</ul></div></div>"; echo "</ul></div></div>";
} }
function print_alert_box($msg, $alert = 'warning', $button = '')
{
echo <<<EOFnp
<div class="col-xs-12">
<div class="alert alert-{$alert}" role="alert">
{$button}
<p>{$msg}</p>
</div>
</div>
EOFnp;
}
function print_info_box_apply($msg) function print_info_box_apply($msg)
{ {
$value = gettext('Apply changes'); $value = gettext('Apply changes');
...@@ -215,63 +228,35 @@ function print_info_box_apply($msg) ...@@ -215,63 +228,35 @@ function print_info_box_apply($msg)
} }
$savebutton .= '</form>'; $savebutton .= '</form>';
echo <<<EOFnp print_alert_box($msg, 'info', $savebutton);
<div class="col-xs-12">
<div class="alert alert-info alert-dismissible" role="alert">
{$savebutton}
<p>{$msg}</p>
</div>
</div>
EOFnp;
} }
function print_info_box($msg) function print_info_box($msg)
{ {
$savebutton = '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>'; print_alert_box($msg, 'info');
echo <<<EOFnp
<div class="col-xs-12">
<div class="alert alert-info alert-dismissible" role="alert">
{$savebutton}
<p>{$msg}</p>
</div>
</div>
EOFnp;
}
function print_warning_box($msg) {
echo <<<EOFnp
<div class="col-xs-12">
<div class="alert alert-warning alert-dismissible" role="alert">
<p>{$msg}</p>
</div>
</div>
EOFnp;
} }
function is_service_enabled($service) { function print_service_banner($service)
{
global $config; global $config;
switch ($service) { switch ($service) {
case 'firewall': case 'firewall':
case 'filter': if (!isset($config['system']['disablefilter'])) {
return !isset($config['system']['disablefilter']);
default:
return false;
}
}
function print_service_disabled_banner($service) {
if (!is_service_enabled($service)) {
switch ($service) {
case 'firewall':
case 'filter':
print_warning_box(gettext(
"The firewall has globally been disabled and configured rules are currently not enforced. " .
"It can be enabled in the <a href=\"system_advanced_firewall.php\">Firewall and NAT settings</a> page."
));
break; break;
} }
print_alert_box(sprintf(
gettext(
'The firewall has globally been disabled and configured rules are ' .
'currently not enforced. It can be enabled in the %sFirewall/NAT%s ' .
'settings.'
),
'<a href="/system_advanced_firewall.php">',
'</a>'
));
break;
default:
break;
} }
} }
......
...@@ -62,7 +62,7 @@ include("head.inc"); ...@@ -62,7 +62,7 @@ include("head.inc");
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<?php print_service_disabled_banner('firewall'); ?> <?php print_service_banner('firewall'); ?>
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?> <?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<section class="col-xs-12"> <section class="col-xs-12">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment