From a137e4074691a4123b2e703d6d4e52a4c06aceab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Sat, 6 Feb 2010 10:37:44 +0100 Subject: [PATCH] Implement DirEnum::getOptionsArray() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- include/directory.enums.inc.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/include/directory.enums.inc.php b/include/directory.enums.inc.php index 07786b3..5ea6b32 100644 --- a/include/directory.enums.inc.php +++ b/include/directory.enums.inc.php @@ -59,7 +59,6 @@ class DirEnum /** Retrieves all options for a given type * @param $type Type of enum for which options are requested * @return XorgDbIterator over the results - * TODO : Find a way to get either an array, or the adequate PlIterator */ static public function getOptions() { @@ -72,6 +71,21 @@ class DirEnum return call_user_func_array(array($obj, 'getOptions'), $args); } + /** Retrieves all options for a given type + * @param $type Type of enum for which options are requested + * @return Array of the results the results + */ + static public function getOptionsArray() + { + $args = func_get_args(); + $type = array_shift($args); + if (!array_key_exists($type, self::$enumerations)) { + self::init($type); + } + $obj = self::$enumerations[$type]; + return call_user_func_array(array($obj, 'getOptionsArray'), $args); + } + /** Retrieves all options with number of profiles for autocompletion * @param $type Type of enum for which options are requested * @param $text Text to autocomplete @@ -151,6 +165,16 @@ abstract class DirEnumeration return $this->options; } + public function getOptionsArray() + { + $this->_fetchOptions(); + $options = array(); + while ($row = $this->options->next()) { + $options[$row['id']] = $row['field']; + } + return $options; + } + // {{{ function getIDs /** Retrieves possible IDs for given text * @param $text Text to search for IDs -- 2.1.4