diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc
index 21a0cb250d..580c3287c6 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 0c0398d260..1571fda1d3 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 0ca8933ede..3df52b8802 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 2ccf127860..77270821bd 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 ') .''. $a_filter[$id]['created']['username'] .''
- ));
- }
-
- if ($has_updated_time) {
- $section->addInput(new Form_StaticText(
- 'Updated',
- date('n/j/y H:i:s', $a_filter[$id]['updated']['time']) . gettext(' by ') .''. $a_filter[$id]['updated']['username'] .''
- ));
- }
-}
-
$form->add($section);
+
+gen_created_updated_fields($form, $a_filter[$id]['created'], $a_filter[$id]['updated']);
+
echo $form;
?>