From da5fe90f4b8091b13abd5a5f3486dbadd528e214 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 6 Oct 2017 18:00:22 +0200 Subject: [runmode] Support returning associative array --- modules-available/runmode/inc/runmode.inc.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'modules-available/runmode') diff --git a/modules-available/runmode/inc/runmode.inc.php b/modules-available/runmode/inc/runmode.inc.php index 0f4994f4..bf20596b 100644 --- a/modules-available/runmode/inc/runmode.inc.php +++ b/modules-available/runmode/inc/runmode.inc.php @@ -64,7 +64,8 @@ class RunMode /** * @param string|\Module $module - * @return array + * @param bool true = wrap in array where key is modeid + * @return array key=machineuuid, value={'machineuuid', 'modeid', 'modedata'} */ public static function getForModule($module, $groupByModeId = false) { @@ -91,9 +92,10 @@ class RunMode * @param string|\Module $module * @param string $modeId * @param bool $detailed whether to return meta data about machine, not just machineuuid - * @return array + * @param bool $assoc use machineuuid as array key + * @return array , value={'machineuuid', 'modedata', <'hostname', 'clientip', 'macaddr', 'locationid'>} */ - public static function getForMode($module, $modeId, $detailed = false) + public static function getForMode($module, $modeId, $detailed = false, $assoc = false) { if (is_object($module)) { $module = $module->getIdentifier(); @@ -114,7 +116,11 @@ class RunMode if ($detailed && empty($row['hostname'])) { $row['hostname'] = $row['clientip']; } - $ret[] = $row; + if ($assoc) { + $ret[$row['machineuuid']] = $row; + } else { + $ret[] = $row; + } } return $ret; } -- cgit v1.2.3-55-g7522