From b90c97b1f096008b5fa9abf8c50a120a85c47a4e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 30 Nov 2017 18:30:01 +0100 Subject: [roomplanner] Refactor to use runmode --- modules-available/runmode/inc/runmode.inc.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'modules-available/runmode/inc/runmode.inc.php') diff --git a/modules-available/runmode/inc/runmode.inc.php b/modules-available/runmode/inc/runmode.inc.php index 59f8cf01..50ae2d72 100644 --- a/modules-available/runmode/inc/runmode.inc.php +++ b/modules-available/runmode/inc/runmode.inc.php @@ -36,6 +36,9 @@ class RunMode */ public static function setRunMode($machineuuid, $moduleId, $modeId, $modeData = null, $isClient = null) { + if (is_object($moduleId)) { + $moduleId = $moduleId->getIdentifier(); + } // - Check if machine exists $machine = Statistics::getMachine($machineuuid, Machine::NO_DATA); if ($machine === false) @@ -196,6 +199,21 @@ class RunMode return call_user_func($conf->getModeName, $modeId); } + /** + * Delete given runmode. + * + * @param string|\Module $module Module runmode belongs to + * @param string $modeId run mode id + */ + public static function deleteMode($module, $modeId) + { + if (is_object($module)) { + $module = $module->getIdentifier(); + } + Database::exec('DELETE FROM runmode WHERE module = :module AND modeid = :modeId', + compact('module', 'modeId')); + } + } /* *\ @@ -235,6 +253,10 @@ class RunModeModuleConfig * @var bool If true, config.tgz should not be downloaded by the client */ public $noSysconfig = false; + /** + * @var bool Allow adding and removing machines to this mode via the generic form + */ + public $allowGenericEditor = true; public function __construct($file) { @@ -248,6 +270,7 @@ class RunModeModuleConfig $this->loadType($data, 'configHook', 'string'); $this->loadType($data, 'isClient', 'boolean'); $this->loadType($data, 'noSysconfig', 'boolean'); + $this->loadType($data, 'allowGenericEditor', 'boolean'); } private function loadType($data, $key, $type) -- cgit v1.2.3-55-g7522