summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Davis <phil@jankaritech.com>2017-05-19 13:40:27 +0545
committerjim-p <jimp@pfsense.org>2017-06-21 09:52:53 -0400
commit1ea6736f8fe2d641eecbbc9977bd28f97236b213 (patch)
tree8513a8ff74430bd317ce22d119e6637a0073ac5f
parentf4f220a796c0e529bd99f969b9f204d37ad79a97 (diff)
downloadpfsense-1ea6736f8fe2d641eecbbc9977bd28f97236b213.zip
pfsense-1ea6736f8fe2d641eecbbc9977bd28f97236b213.tar.gz
Make consistent rule information section
(cherry picked from commit f0dc8b688c2b7d973bc18769579ee8cc6d3d2dad) (cherry picked from commit 4c4504b1e785396d92be853072a9c557c55b3c4a)
-rw-r--r--src/etc/inc/pfsense-utils.inc41
-rw-r--r--src/usr/local/www/firewall_nat_edit.php23
-rw-r--r--src/usr/local/www/firewall_nat_out_edit.php23
-rw-r--r--src/usr/local/www/firewall_rules_edit.php24
4 files changed, 45 insertions, 66 deletions
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc
index 21a0cb2..580c328 100644
--- a/src/etc/inc/pfsense-utils.inc
+++ b/src/etc/inc/pfsense-utils.inc
@@ -418,6 +418,47 @@ function gen_requirestatefilter_field(&$section, $value) {
'before the states are displayed. Useful for systems with large state tables.');
}
+/****f* pfsense-utils/gen_created_updated_fields
+ * NAME
+ * gen_created_updated_fields
+ * INPUTS
+ * Pointer to form object
+ * Array of created time and username
+ * Array of updated time and username
+ * RESULT
+ * no return value, section object is added to form if needed
+ ******/
+function gen_created_updated_fields(&$form, $created, $updated) {
+ $has_created_time = (isset($created['time']) && isset($created['username']));
+ $has_updated_time = (isset($updated['time']) && isset($updated['username']));
+
+ if ($has_created_time || $has_updated_time) {
+ $section = new Form_Section('Rule Information');
+
+ if ($has_created_time) {
+ $section->addInput(new Form_StaticText(
+ 'Created',
+ sprintf(
+ gettext('%1$s by %2$s'),
+ date(gettext("n/j/y H:i:s"), $created['time']),
+ $created['username'])
+ ));
+ }
+
+ if ($has_updated_time) {
+ $section->addInput(new Form_StaticText(
+ 'Updated',
+ sprintf(
+ gettext('%1$s by %2$s'),
+ date(gettext("n/j/y H:i:s"), $updated['time']),
+ $updated['username'])
+ ));
+ }
+
+ $form->add($section);
+ }
+}
+
function hardware_offloading_applyflags($iface) {
global $config;
diff --git a/src/usr/local/www/firewall_nat_edit.php b/src/usr/local/www/firewall_nat_edit.php
index 0c0398d..1571fda 100644
--- a/src/usr/local/www/firewall_nat_edit.php
+++ b/src/usr/local/www/firewall_nat_edit.php
@@ -990,28 +990,7 @@ if (isset($id) && $a_nat[$id] && (!isset($_GET['dup']) || !is_numericint($_GET['
$form->add($section);
-$has_created_time = (isset($a_nat[$id]['created']) && is_array($a_nat[$id]['created']));
-$has_updated_time = (isset($a_nat[$id]['updated']) && is_array($a_nat[$id]['updated']));
-
-if ($has_created_time || $has_updated_time) {
- $section = new Form_Section('Rule Information');
-
- if ($has_created_time) {
- $section->addInput(new Form_StaticText(
- 'Created',
- date(gettext("n/j/y H:i:s"), $a_nat[$id]['created']['time']) . gettext(" by ") . $a_nat[$id]['created']['username']
- ));
- }
-
- if ($has_updated_time) {
- $section->addInput(new Form_StaticText(
- 'Updated',
- date(gettext("n/j/y H:i:s"), $a_nat[$id]['updated']['time']) . gettext(" by ") . $a_nat[$id]['updated']['username']
- ));
- }
-
- $form->add($section);
-}
+gen_created_updated_fields($form, $a_nat[$id]['created'], $a_nat[$id]['updated']);
if (isset($id) && $a_nat[$id]) {
$form->addGlobal(new Form_Input(
diff --git a/src/usr/local/www/firewall_nat_out_edit.php b/src/usr/local/www/firewall_nat_out_edit.php
index 0ca8933..3df52b8 100644
--- a/src/usr/local/www/firewall_nat_out_edit.php
+++ b/src/usr/local/www/firewall_nat_out_edit.php
@@ -686,28 +686,7 @@ $section->addInput(new Form_Input(
$form->add($section);
-$has_created_time = (isset($a_out[$id]['created']) && is_array($a_out[$id]['created']));
-$has_updated_time = (isset($a_out[$id]['updated']) && is_array($a_out[$id]['updated']));
-
-if ($has_created_time || $has_updated_time) {
- $section = new Form_Section('Rule Information');
-
- if ($has_created_time) {
- $section->addInput(new Form_StaticText(
- 'Created',
- date(gettext("n/j/y H:i:s"), $a_out[$id]['created']['time']) . gettext(" by ") . $a_out[$id]['created']['username']
- ));
- }
-
- if ($has_updated_time) {
- $section->addInput(new Form_StaticText(
- 'Updated',
- date(gettext("n/j/y H:i:s"), $a_out[$id]['updated']['time']) . gettext(" by ") . $a_out[$id]['updated']['username']
- ));
- }
-
- $form->add($section);
-}
+gen_created_updated_fields($form, $a_out[$id]['created'], $a_out[$id]['updated']);
print($form);
diff --git a/src/usr/local/www/firewall_rules_edit.php b/src/usr/local/www/firewall_rules_edit.php
index 2ccf127..7727082 100644
--- a/src/usr/local/www/firewall_rules_edit.php
+++ b/src/usr/local/www/firewall_rules_edit.php
@@ -1768,30 +1768,10 @@ $section->add($group)->setHelp('Choose the Acknowledge Queue only if there is a
'selected Queue.'
);
-$has_created_time = (isset($a_filter[$id]['created']) && is_array($a_filter[$id]['created']));
-$has_updated_time = (isset($a_filter[$id]['updated']) && is_array($a_filter[$id]['updated']));
-
-
-if ($has_created_time || $has_updated_time) {
- $form->add($section);
- $section = new Form_Section('Rule Information');
-
- if ($has_created_time) {
- $section->addInput(new Form_StaticText(
- 'Created',
- date('n/j/y H:i:s', $a_filter[$id]['created']['time']) . gettext(' by ') .'<b>'. $a_filter[$id]['created']['username'] .'</b>'
- ));
- }
+$form->add($section);
- if ($has_updated_time) {
- $section->addInput(new Form_StaticText(
- 'Updated',
- date('n/j/y H:i:s', $a_filter[$id]['updated']['time']) . gettext(' by ') .'<b>'. $a_filter[$id]['updated']['username'] .'</b>'
- ));
- }
-}
+gen_created_updated_fields($form, $a_filter[$id]['created'], $a_filter[$id]['updated']);
-$form->add($section);
echo $form;
?>
OpenPOWER on IntegriCloud