diff options
author | Simon Rettberg | 2018-01-15 17:19:56 +0100 |
---|---|---|
committer | Simon Rettberg | 2018-01-15 17:19:56 +0100 |
commit | 9fdf21f602de38ebcd9cb0ccb03c709a06cd2d06 (patch) | |
tree | b7adea2ac4b93f2cc13348e2cf2ce164ca4c3fe4 /modules-available | |
parent | [statistics] Fix runtime filter (had math backwards) (diff) | |
download | slx-admin-9fdf21f602de38ebcd9cb0ccb03c709a06cd2d06.tar.gz slx-admin-9fdf21f602de38ebcd9cb0ccb03c709a06cd2d06.tar.xz slx-admin-9fdf21f602de38ebcd9cb0ccb03c709a06cd2d06.zip |
[runmode] Do not allow re-assigning clients to new runmode if old mode doesn't support the generic editor
Doing so might leave some stale data in the old module, so we
better prevent it so the user has to manually remove the client
from the old runmode using the non-generic way (module specific)
first.
Diffstat (limited to 'modules-available')
-rw-r--r-- | modules-available/dnbd3/hooks/runmode/config.json | 4 | ||||
-rw-r--r-- | modules-available/runmode/inc/runmode.inc.php | 2 | ||||
-rw-r--r-- | modules-available/runmode/lang/de/messages.json | 1 | ||||
-rw-r--r-- | modules-available/runmode/lang/en/messages.json | 1 | ||||
-rw-r--r-- | modules-available/runmode/page.inc.php | 24 | ||||
-rw-r--r-- | modules-available/runmode/templates/module-machine-list.html | 4 |
6 files changed, 26 insertions, 10 deletions
diff --git a/modules-available/dnbd3/hooks/runmode/config.json b/modules-available/dnbd3/hooks/runmode/config.json index 095cb42f..5db53f0b 100644 --- a/modules-available/dnbd3/hooks/runmode/config.json +++ b/modules-available/dnbd3/hooks/runmode/config.json @@ -2,5 +2,7 @@ "isClient": false, "configHook": "Dnbd3Util::runmodeConfigHook", "noSysconfig": true, - "systemdDefaultTarget": "dnbd3-proxy" + "systemdDefaultTarget": "dnbd3-proxy", + "allowGenericEditor": false, + "deleteUrlSnippet": "dummyparam=" }
\ No newline at end of file diff --git a/modules-available/runmode/inc/runmode.inc.php b/modules-available/runmode/inc/runmode.inc.php index ad1f52bf..2c8083ca 100644 --- a/modules-available/runmode/inc/runmode.inc.php +++ b/modules-available/runmode/inc/runmode.inc.php @@ -72,7 +72,7 @@ class RunMode * @param string $machineuuid * @param int $returnData bitfield of data to return * @return false|array {'machineuuid', 'isclient', 'module', 'modeid', 'modedata', - * <'hostname', 'clientip', 'macaddr', 'locationid', 'lastseen'>} + * ('hostname', 'clientip', 'macaddr', 'locationid', 'lastseen'), ('moduleName', 'modeName')} */ public static function getRunMode($machineuuid, $returnData = self::DATA_MACHINE_DATA) { diff --git a/modules-available/runmode/lang/de/messages.json b/modules-available/runmode/lang/de/messages.json index 21b4b6ae..911d48d4 100644 --- a/modules-available/runmode/lang/de/messages.json +++ b/modules-available/runmode/lang/de/messages.json @@ -5,5 +5,6 @@ "machine-not-found": "Rechner {{0}} nicht gefunden", "machine-not-runmode": "Rechner {{0}} hatte keinen speziellen Betriebsmodus aktiviert", "machine-removed": "Rechner {{0}} entfernt", + "machine-still-assigned": "Rechner {{0}} ist noch im Betriebsmodus {{1}}; ignoriert.", "module-hasnt-runmode": "Modul {{0}} bietet keine speziellen Betriebsmodi" }
\ No newline at end of file diff --git a/modules-available/runmode/lang/en/messages.json b/modules-available/runmode/lang/en/messages.json index 1985ca66..6d890428 100644 --- a/modules-available/runmode/lang/en/messages.json +++ b/modules-available/runmode/lang/en/messages.json @@ -5,5 +5,6 @@ "machine-not-found": "Client {{0}} not found", "machine-not-runmode": "No special mode of operation configured for client {{0}}", "machine-removed": "Removed client {{0}}", + "machine-still-assigned": "Client {{0}} still set to mode {{1}}, not assigning new mode.", "module-hasnt-runmode": "Module {{0}} doesn't supply any special mode of operation" }
\ No newline at end of file diff --git a/modules-available/runmode/page.inc.php b/modules-available/runmode/page.inc.php index e26950d0..b94b8a31 100644 --- a/modules-available/runmode/page.inc.php +++ b/modules-available/runmode/page.inc.php @@ -42,6 +42,14 @@ class Page_RunMode extends Page } $active = 0; foreach ($machines as $machine) { + $oldMode = RunMode::getRunMode($machine, 0); + if ($oldMode !== false) { + $oldModule = RunMode::getModuleConfig($oldMode['module']); + if ($oldModule !== false && (!$oldModule->allowGenericEditor || $oldModule->deleteUrlSnippet !== false)) { + Message::addError('runmode.machine-still-assigned', $machine, $oldMode['module']); + continue; + } + } $ret = RunMode::setRunMode($machine, $module, $modeId, null, null); if ($ret) { $active++; @@ -105,10 +113,6 @@ class Page_RunMode extends Page Message::addError('module-hasnt-runmode', $moduleId); Util::redirect('?do=runmode'); } - if (!$config->allowGenericEditor) { - Message::addError('runmode.cannot-edit-module', $moduleId); - return; - } // Given modeId? $modeId = Request::get('modeid', false, 'string'); if ($modeId !== false) { @@ -170,9 +174,17 @@ class Page_RunMode extends Page { $moduleId = $module->getIdentifier(); $modeName = RunMode::getModeName($moduleId, $modeId); + $redirect = Request::get('redirect', '', 'string'); + if (empty($redirect)) { + $redirect = '?do=runmode'; + } if ($modeName === false) { Message::addError('invalid-modeid', $moduleId, $modeId); - Util::redirect('?do=runmode'); + Util::redirect($redirect); + } + if (!RunMode::getModuleConfig($moduleId)->allowGenericEditor) { + Message::addError('runmode.cannot-edit-module', $module); + Util::redirect($redirect); } Render::addTemplate('machine-selector', [ 'module' => $moduleId, @@ -180,7 +192,7 @@ class Page_RunMode extends Page 'moduleName' => $module->getDisplayName(), 'modeName' => $modeName, 'machines' => json_encode(RunMode::getForMode($module, $modeId, true)), - 'redirect' => Request::get('redirect', '', 'string'), + 'redirect' => $redirect, ]); } diff --git a/modules-available/runmode/templates/module-machine-list.html b/modules-available/runmode/templates/module-machine-list.html index 61bbbad9..283fb393 100644 --- a/modules-available/runmode/templates/module-machine-list.html +++ b/modules-available/runmode/templates/module-machine-list.html @@ -41,8 +41,8 @@ </button> {{/canedit}} {{#deleteUrl}} - <a class="btn btn-danger btn-sm" href="?do={{module}}&{{deleteUrl}}{{modeid}}"> - <span class="glyphicon glyphicon-trash"></span> + <a class="btn btn-default btn-sm" href="?do={{module}}&{{deleteUrl}}{{modeid}}"> + <span class="glyphicon glyphicon-edit"></span> </a> {{/deleteUrl}} </td> |