summaryrefslogtreecommitdiffstats
path: root/modules-available/runmode/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2018-01-15 17:19:56 +0100
committerSimon Rettberg2018-01-15 17:19:56 +0100
commit9fdf21f602de38ebcd9cb0ccb03c709a06cd2d06 (patch)
treeb7adea2ac4b93f2cc13348e2cf2ce164ca4c3fe4 /modules-available/runmode/page.inc.php
parent[statistics] Fix runtime filter (had math backwards) (diff)
downloadslx-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/runmode/page.inc.php')
-rw-r--r--modules-available/runmode/page.inc.php24
1 files changed, 18 insertions, 6 deletions
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,
]);
}