diff options
author | Renato Botelho <renato@netgate.com> | 2016-12-09 17:10:05 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-12-09 18:22:55 -0200 |
commit | 75bb5037eeccf7702451b3f24e4792e6654af036 (patch) | |
tree | 7dd714745d7cc55dae6eeafba8c30ac83805762f /src/etc/inc/itemid.inc | |
parent | 21408bb4812e25d9e113413d6748494104142c5c (diff) | |
download | pfsense-75bb5037eeccf7702451b3f24e4792e6654af036.zip pfsense-75bb5037eeccf7702451b3f24e4792e6654af036.tar.gz |
Simplify logic
Diffstat (limited to 'src/etc/inc/itemid.inc')
-rw-r--r-- | src/etc/inc/itemid.inc | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/src/etc/inc/itemid.inc b/src/etc/inc/itemid.inc index 9988223..618f3a5 100644 --- a/src/etc/inc/itemid.inc +++ b/src/etc/inc/itemid.inc @@ -32,38 +32,29 @@ function delete_id($id, &$array) { global $config; - // Index to delete - $delete_index = NULL; - if (!is_array($array)) { return false; } // Search for the item in the array - foreach ($array as $key => $item) { - // If this item is the one we want to delete - if (isset($item['associated-rule-id']) && $item['associated-rule-id'] == $id) { - $delete_index = $key; - $if = $item['interface']; - break; - } - } + $delete_index = get_id($id, $array); // If we found the item, unset it - if ($delete_index !== NULL) { - unset($array[$delete_index]); - - // Update the separators - $a_separators = &$config['filter']['separator'][strtolower($if)]; - $ridx = ifridx($if, $delete_index); // get rule index within interface - $mvnrows = -1; - move_separators($a_separators, $ridx, $mvnrows); - - return true; - } else { + if ($delete_index === false) { return false; } + $if = $array[$delete_index]['interface']; + unset($array[$delete_index]); + + // Update the separators + $a_separators = &$config['filter']['separator'][strtolower($if)]; + // get rule index within interface + $ridx = ifridx($if, $delete_index); + $mvnrows = -1; + move_separators($a_separators, $ridx, $mvnrows); + + return true; } /****f* itemid/get_id @@ -85,7 +76,8 @@ function get_id($id, $array) { // Search for the item in the array foreach ($array as $key => $item) { // If this item is the one we want to delete - if (isset($item['associated-rule-id']) && $item['associated-rule-id'] == $id) { + if (isset($item['associated-rule-id']) && + $item['associated-rule-id'] == $id) { return $key; } } |