From 0e9f943a8a2a7233ceb10d60c57f0a890a88ca09 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 1 Dec 2017 10:57:09 +0100 Subject: [runmode] Fix syntax error in SQL query --- modules-available/runmode/inc/runmode.inc.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'modules-available/runmode') diff --git a/modules-available/runmode/inc/runmode.inc.php b/modules-available/runmode/inc/runmode.inc.php index 50ae2d72..8ba8587f 100644 --- a/modules-available/runmode/inc/runmode.inc.php +++ b/modules-available/runmode/inc/runmode.inc.php @@ -160,7 +160,7 @@ class RunMode $join = $sel = ''; } $res = Database::simpleQuery( - "SELECT r.machineuuid, r.modedata $sel + "SELECT r.machineuuid, r.modedata, r.isclient $sel FROM runmode r $join WHERE module = :module AND modeid = :modeId", compact('module', 'modeId')); @@ -178,6 +178,28 @@ class RunMode return $ret; } + /** + * Return assoc array of all configured clients. + * @param bool $withData also return data field? + * @param bool $clientsOnly only return those with isclient == true + * @return array all the entries from the table + */ + public static function getAllClients($withData = false, $clientsOnly = false) + { + $xtra = ''; + if ($withData) { + $xtra .= ', modedata'; + } + $res = Database::simpleQuery("SELECT machineuuid, module, modeid, isclient $withData FROM runmode"); + $ret = array(); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + if ($clientsOnly && !$row['isclient']) + continue; + $ret[$row['machineuuid']] = $row; + } + return $ret; + } + /** * Get display name of a module's mode. If the module doesn't have a getModeName * method configured, the modeId is simply returned. Otherwise the return value of -- cgit v1.2.3-55-g7522