summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/itemid.inc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-12-09 18:20:23 -0200
committerRenato Botelho <renato@netgate.com>2016-12-09 18:23:32 -0200
commit8aa2dd26225dc4d310fd6843582c6131ad0d76f7 (patch)
tree6a08ad4277b727284ed1845a48a8c710108b68b7 /src/etc/inc/itemid.inc
parent15586fff1775543b69b1b542cb4c8f692fe58aae (diff)
downloadpfsense-8aa2dd26225dc4d310fd6843582c6131ad0d76f7.zip
pfsense-8aa2dd26225dc4d310fd6843582c6131ad0d76f7.tar.gz
Ticket #6472: Add toggle_id
Introduce toggle_id() used to enable/disable associated firewall rules
Diffstat (limited to 'src/etc/inc/itemid.inc')
-rw-r--r--src/etc/inc/itemid.inc34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/etc/inc/itemid.inc b/src/etc/inc/itemid.inc
index 618f3a5..a33672d 100644
--- a/src/etc/inc/itemid.inc
+++ b/src/etc/inc/itemid.inc
@@ -57,6 +57,40 @@ function delete_id($id, &$array) {
return true;
}
+/****f* itemid/toggle_id
+ * NAME
+ * toggle_id - enable/disable item with ['assiciated-rule-id'] = $id from $array
+ * INPUTS
+ * $id - int: The ID to delete
+ * $array - array to delete the item from
+ * $status - true to enable item and false to disable
+ * RESULT
+ * boolean - true if item was found and set
+ ******/
+function toggle_id($id, &$array, $status) {
+ global $config;
+
+ if (!is_array($array)) {
+ return false;
+ }
+
+ // Search for the item in the array
+ $toggle_index = get_id($id, $array);
+
+ // If we found the item, unset it
+ if ($toggle_index === false) {
+ return false;
+ }
+
+ if ($status) {
+ unset($array[$toggle_index]['disabled']);
+ } else {
+ $array[$toggle_index]['disabled'] = true;
+ }
+
+ return true;
+}
+
/****f* itemid/get_id
* NAME
* get_id - Get an item id with ['associated-rule-id'] = $id from $array
OpenPOWER on IntegriCloud