diff options
author | Simon Rettberg | 2017-11-30 18:30:01 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-11-30 18:30:01 +0100 |
commit | b90c97b1f096008b5fa9abf8c50a120a85c47a4e (patch) | |
tree | 2e6de58e0de3d044549946b352cb6b2bd61916fd /modules-available/runmode/page.inc.php | |
parent | Update translations (diff) | |
download | slx-admin-b90c97b1f096008b5fa9abf8c50a120a85c47a4e.tar.gz slx-admin-b90c97b1f096008b5fa9abf8c50a120a85c47a4e.tar.xz slx-admin-b90c97b1f096008b5fa9abf8c50a120a85c47a4e.zip |
[roomplanner] Refactor to use runmode
Diffstat (limited to 'modules-available/runmode/page.inc.php')
-rw-r--r-- | modules-available/runmode/page.inc.php | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/modules-available/runmode/page.inc.php b/modules-available/runmode/page.inc.php index 24566cec..ef42e7be 100644 --- a/modules-available/runmode/page.inc.php +++ b/modules-available/runmode/page.inc.php @@ -26,20 +26,33 @@ class Page_RunMode extends Page $machines = array_filter(Request::post('machines', [], 'array'), 'is_string'); $module = Request::post('module', false, 'string'); $modeId = Request::post('modeid', false, 'string'); - // TODO Validate + $modConfig = RunMode::getModuleConfig($module); + if ($modConfig === false) { + Message::addError('module-hasnt-runmode', $module); + return; + } + if (!$modConfig->allowGenericEditor) { + Message::addError('cannot-edit-module', $module); + return; + } + $test = RunMode::getModeName($module, $modeId); + if ($test === false) { + Message::addError('invalid-modeid', $module, $modeId); + return; + } $active = 0; foreach ($machines as $machine) { $ret = RunMode::setRunMode($machine, $module, $modeId, null, null); if ($ret) { $active++; } else { - Message::addError('invalid-module-or-machine', $module, $machine); + Message::addError('runmode.machine-not-found', $machine); } } $deleted = Database::exec('DELETE FROM runmode WHERE module = :module AND modeid = :modeId AND machineuuid NOT IN (:machines)', compact('module', 'modeId', 'machines')); - Message::addError('enabled-removed-save', $active, $deleted); + Message::addSuccess('runmode.enabled-removed-save', $active, $deleted); $redirect = Request::post('redirect', false, 'string'); if ($redirect !== false) { Util::redirect($redirect); @@ -141,7 +154,7 @@ class Page_RunMode extends Page $moduleId = $module->getIdentifier(); $modeName = RunMode::getModeName($moduleId, $modeId); if ($modeName === false) { - Message::addError('invalid-modeid', $modeId); + Message::addError('invalid-modeid', $moduleId, $modeId); Util::redirect('?do=runmode'); } Render::addTemplate('machine-selector', [ |