From f0dc8b688c2b7d973bc18769579ee8cc6d3d2dad Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 19 May 2017 13:40:27 +0545 Subject: Make consistent rule information section --- src/etc/inc/pfsense-utils.inc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/etc/inc/pfsense-utils.inc') 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; -- cgit v1.1