summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/etc/inc/pfsense-utils.inc41
-rw-r--r--src/usr/local/www/firewall_nat_edit.php29
-rw-r--r--src/usr/local/www/firewall_nat_out_edit.php29
-rw-r--r--src/usr/local/www/firewall_rules_edit.php30
4 files changed, 45 insertions, 84 deletions
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc
index e86e83d..20d9576 100644
--- a/src/etc/inc/pfsense-utils.inc
+++ b/src/etc/inc/pfsense-utils.inc
@@ -457,6 +457,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 55fc463..f833b44 100644
--- a/src/usr/local/www/firewall_nat_edit.php
+++ b/src/usr/local/www/firewall_nat_edit.php
@@ -958,34 +958,7 @@ if (isset($id) && $a_nat[$id] && (!isset($_POST['dup']) || !is_numericint($_POST
$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',
- sprintf(
- gettext('%1$s by %2$s'),
- date(gettext("n/j/y H:i:s"), $a_nat[$id]['created']['time']),
- $a_nat[$id]['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"), $a_nat[$id]['updated']['time']),
- $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 cc12353..e6720c0 100644
--- a/src/usr/local/www/firewall_nat_out_edit.php
+++ b/src/usr/local/www/firewall_nat_out_edit.php
@@ -684,34 +684,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',
- sprintf(
- gettext('%1$s by %2$s'),
- date(gettext("n/j/y H:i:s"), $a_out[$id]['created']['time']),
- $a_out[$id]['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"), $a_out[$id]['updated']['time']),
- $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 1012906..e880537 100644
--- a/src/usr/local/www/firewall_rules_edit.php
+++ b/src/usr/local/www/firewall_rules_edit.php
@@ -1746,36 +1746,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',
- sprintf(
- gettext('%1$s by %2$s'),
- date(gettext("n/j/y H:i:s"), $a_filter[$id]['created']['time']),
- '<b>' . $a_filter[$id]['created']['username'] . '</b>')
- ));
- }
+$form->add($section);
- 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"), $a_filter[$id]['updated']['time']),
- '<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