summaryrefslogtreecommitdiffstats
path: root/modules-available/runmode/inc/runmode.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-08-10 15:56:58 +0200
committerSimon Rettberg2017-08-10 15:56:58 +0200
commit9abacc2da789048a83953da5622a6e588bb432a4 (patch)
treeee3b98760bc5b23b64a722fb92d7cbbce3fb7beb /modules-available/runmode/inc/runmode.inc.php
parent[baseconfig] PHP 7 compat (diff)
downloadslx-admin-9abacc2da789048a83953da5622a6e588bb432a4.tar.gz
slx-admin-9abacc2da789048a83953da5622a6e588bb432a4.tar.xz
slx-admin-9abacc2da789048a83953da5622a6e588bb432a4.zip
[runmode] Add isclient property per client, implement overview page
Diffstat (limited to 'modules-available/runmode/inc/runmode.inc.php')
-rw-r--r--modules-available/runmode/inc/runmode.inc.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/modules-available/runmode/inc/runmode.inc.php b/modules-available/runmode/inc/runmode.inc.php
index 916866f1..0f4994f4 100644
--- a/modules-available/runmode/inc/runmode.inc.php
+++ b/modules-available/runmode/inc/runmode.inc.php
@@ -9,7 +9,7 @@ class RunMode
* Get runmode config for a specific module
*
* @param string $module name of module
- * @return RunModeModuleConfig|false
+ * @return \RunModeModuleConfig|false config, false if moudles doesn't support run modes
*/
public static function getModuleConfig($module)
{
@@ -23,7 +23,15 @@ class RunMode
return (self::$moduleConfigs[$module] = new RunModeModuleConfig($file));
}
- public static function setRunMode($machineuuid, $moduleId, $modeId, $modeData)
+ /**
+ * @param string $machineuuid
+ * @param string $moduleId
+ * @param string|null $modeId an ID specific to the module to further specify the run mode, NULL to delete the run mode entry
+ * @param string|null $modeData optional, additional data for the run mode
+ * @param bool|null $isClient whether to count the machine as a client (in statistics etc.) NULL for looking at module's general runmode config
+ * @return bool whether it was set
+ */
+ public static function setRunMode($machineuuid, $moduleId, $modeId, $modeData, $isClient)
{
// - Check if module provides runmode config at all
$config = self::getModuleConfig($moduleId);
@@ -37,13 +45,18 @@ class RunMode
if (is_null($modeId)) {
Database::exec('DELETE FROM runmode WHERE machineuuid = :machineuuid', compact('machineuuid'));
} else {
- Database::exec('INSERT INTO runmode (machineuuid, module, modeid, modedata)'
- . ' VALUES (:uuid, :module, :modeid, :modedata)'
- . ' ON DUPLICATE KEY UPDATE module = VALUES(module), modeid = VALUES(modeid), modedata = VALUES(modedata)', array(
+ if ($isClient === null) {
+ $isClient = $config->isClient;
+ }
+ Database::exec('INSERT INTO runmode (machineuuid, module, modeid, modedata, isclient)'
+ . ' VALUES (:uuid, :module, :modeid, :modedata, :isclient)'
+ . ' ON DUPLICATE KEY'
+ . ' UPDATE module = VALUES(module), modeid = VALUES(modeid), modedata = VALUES(modedata), isclient = VALUES(isclient)', array(
'uuid' => $machineuuid,
'module' => $moduleId,
'modeid' => $modeId,
'modedata' => $modeData,
+ 'isclient' => ($isClient ? 1 : 0),
));
}
return true;