summaryrefslogtreecommitdiffstats
path: root/modules-available/serversetup-bwlp-ipxe/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2019-04-16 16:57:08 +0200
committerSimon Rettberg2019-04-16 16:59:55 +0200
commit2f57191cd05ad07de606f7cae8aae8e959f95c74 (patch)
tree41690d02be53b64f6d444859504e85f57a8f17e0 /modules-available/serversetup-bwlp-ipxe/page.inc.php
parent[serversetup-bwlp-ipxe] Fix permcheck for menu edit in menu list (diff)
downloadslx-admin-2f57191cd05ad07de606f7cae8aae8e959f95c74.tar.gz
slx-admin-2f57191cd05ad07de606f7cae8aae8e959f95c74.tar.xz
slx-admin-2f57191cd05ad07de606f7cae8aae8e959f95c74.zip
[serversetup-bwlp-ipxe] Make sure we always have a default entry
Diffstat (limited to 'modules-available/serversetup-bwlp-ipxe/page.inc.php')
-rw-r--r--modules-available/serversetup-bwlp-ipxe/page.inc.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/page.inc.php b/modules-available/serversetup-bwlp-ipxe/page.inc.php
index a00a18a1..25122a6c 100644
--- a/modules-available/serversetup-bwlp-ipxe/page.inc.php
+++ b/modules-available/serversetup-bwlp-ipxe/page.inc.php
@@ -671,7 +671,8 @@ class Page_ServerSetup extends Page
'sortval' => (int)$entry['sortval'],
'menuid' => $menu['menuid'],
];
- if (empty($entry['entryid'])) {
+ $spacer = empty($entry['entryid']);
+ if ($spacer) {
// Spacer
$params += [
'hotkey' => '',
@@ -691,7 +692,9 @@ class Page_ServerSetup extends Page
}
}
if (is_numeric($key)) {
- if ((string)$key === $wantedDefaultEntryId) { // Check now that we have generated our key
+ // Update, use known key
+ if (!$spacer && ((string)$key === $wantedDefaultEntryId
+ || $defaultEntryId === null)) { // if still null, use whatever as fallback, in case user didn't select any
$defaultEntryId = $key;
}
$keepIds[] = $key;
@@ -707,7 +710,9 @@ class Page_ServerSetup extends Page
VALUES (:menuid, :entryid, :refmenuid, :hotkey, :title, :hidden, :sortval, :plainpass, '')", $params, true);
if ($ret) {
$newKey = Database::lastInsertId();
- if ((string)$key === $wantedDefaultEntryId) { // Check now that we have generated our key
+ // Check now that we have generated our key
+ if (!$spacer && ((string)$key === $wantedDefaultEntryId
+ || $defaultEntryId === null)) { // if still null, use whatever as fallback, in case user didn't select any
$defaultEntryId = $newKey;
}
$keepIds[] = (int)$newKey;