summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Embry <dse@webonastick.com>2012-05-10 13:48:31 -0400
committerDarren Embry <dse@webonastick.com>2012-05-10 13:48:31 -0400
commita0539faabe2ddde99bc96c5b93b722f99a0b48d5 (patch)
tree837e271fe007647e25abdc2ce7902913912ce4eb
parenta1f7723876ec46bbe84d04f7b09809194b5be768 (diff)
downloadpfsense-a0539faabe2ddde99bc96c5b93b722f99a0b48d5.zip
pfsense-a0539faabe2ddde99bc96c5b93b722f99a0b48d5.tar.gz
prep work: function get_alias_list()
I wrote this function primarily to remove a lot of duplicate code that's there because of a lot of those autocomplete fields.
-rw-r--r--etc/inc/util.inc33
1 files changed, 33 insertions, 0 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index bce004e..5539400 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -1740,4 +1740,37 @@ function get_staticroutes($returnsubnetsonly = false) {
return $allstaticroutes;
}
}
+
+/****f* util/get_alias_list
+ * NAME
+ * get_alias_list - Provide a list of aliases.
+ * INPUTS
+ * $type - Optional, can be a string or array specifying what type(s) of aliases you need.
+ * RESULT
+ * Array containing list of aliases.
+ * If $type is unspecified, all aliases are returned.
+ * If $type is a string, all aliases of the type specified in $type are returned.
+ * If $type is an array, all aliases of any type specified in any element of $type are returned.
+ */
+function get_alias_list($type = null) {
+ global $config;
+ $result = array();
+ if ($config['aliases']['alias'] <> "" && is_array($config['aliases']['alias'])) {
+ foreach ($config['aliases']['alias'] as $alias) {
+ if ($type === null) {
+ $result[] = $alias['name'];
+ }
+ else if (is_array($type)) {
+ if (in_array($alias['type'], $type)) {
+ $result[] = $alias['name'];
+ }
+ }
+ else if ($type === $alias['type']) {
+ $result[] = $alias['name'];
+ }
+ }
+ }
+ return $result;
+}
+
?>
OpenPOWER on IntegriCloud