From a0539faabe2ddde99bc96c5b93b722f99a0b48d5 Mon Sep 17 00:00:00 2001 From: Darren Embry Date: Thu, 10 May 2012 13:48:31 -0400 Subject: 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. --- etc/inc/util.inc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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; +} + ?> -- cgit v1.1