diff options
author | Darren Embry <dse@webonastick.com> | 2012-05-10 13:48:31 -0400 |
---|---|---|
committer | Darren Embry <dse@webonastick.com> | 2012-05-10 13:48:31 -0400 |
commit | a0539faabe2ddde99bc96c5b93b722f99a0b48d5 (patch) | |
tree | 837e271fe007647e25abdc2ce7902913912ce4eb /etc | |
parent | a1f7723876ec46bbe84d04f7b09809194b5be768 (diff) | |
download | pfsense-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.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/util.inc | 33 |
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; +} + ?> |