Make consistent rule information section

(cherry picked from commit f0dc8b688c)
(cherry picked from commit 4c4504b1e7)
This commit is contained in:
Phil Davis 2017-05-19 13:40:27 +05:45 committed by jim-p
parent f4f220a796
commit 1ea6736f8f
4 changed files with 46 additions and 67 deletions

View File

@ -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;

View File

@ -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(

View File

@ -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);

View File

@ -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>'
));
}
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>'
));
}
}
$form->add($section);
gen_created_updated_fields($form, $a_filter[$id]['created'], $a_filter[$id]['updated']);
echo $form;
?>