summaryrefslogtreecommitdiffstats
path: root/modules-available/serversetup-bwlp-ipxe/inc
diff options
context:
space:
mode:
authorSimon Rettberg2019-03-19 23:52:11 +0100
committerSimon Rettberg2019-03-19 23:52:11 +0100
commit89e6c1ce7f901a19467fb5cbc18e8a87ea901482 (patch)
tree9b23b7ba486005b3aab53054810a0ab68b0346dd /modules-available/serversetup-bwlp-ipxe/inc
parent[serversetup-bwlp-ipxe] Fix incomplete bootentries, hide arch select (diff)
downloadslx-admin-89e6c1ce7f901a19467fb5cbc18e8a87ea901482.tar.gz
slx-admin-89e6c1ce7f901a19467fb5cbc18e8a87ea901482.tar.xz
slx-admin-89e6c1ce7f901a19467fb5cbc18e8a87ea901482.zip
[serversetup-bwlp-ipxe] Implement cascaded menus
Diffstat (limited to 'modules-available/serversetup-bwlp-ipxe/inc')
-rw-r--r--modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php35
-rw-r--r--modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php4
-rw-r--r--modules-available/serversetup-bwlp-ipxe/inc/menuentry.inc.php4
3 files changed, 40 insertions, 3 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php
index 0248e0ea..ee245e40 100644
--- a/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php
+++ b/modules-available/serversetup-bwlp-ipxe/inc/bootentry.inc.php
@@ -46,6 +46,11 @@ abstract class BootEntry
return null;
}
+ public static function forMenu($menuId)
+ {
+ return new MenuBootEntry($menuId);
+ }
+
public static function newStandardBootEntry($initData)
{
$ret = new StandardBootEntry($initData);
@@ -276,3 +281,33 @@ class CustomBootEntry extends BootEntry
return ['script' => $this->script];
}
}
+
+class MenuBootEntry extends BootEntry
+{
+ protected $menuId;
+
+ public function __construct($menuId)
+ {
+ $this->menuId = $menuId;
+ }
+
+ public function supportsMode($mode)
+ {
+ return true;
+ }
+
+ public function toScript($failLabel, $mode)
+ {
+ return 'chain -ar ${self}&menuid=' . $this->menuId . ' || goto ' . $failLabel . "\n";
+ }
+
+ public function toArray()
+ {
+ return [];
+ }
+
+ public function addFormFields(&$array)
+ {
+ }
+}
+
diff --git a/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php
index 6deea7f7..991ee403 100644
--- a/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php
+++ b/modules-available/serversetup-bwlp-ipxe/inc/ipxemenu.inc.php
@@ -25,7 +25,7 @@ class IPxeMenu
$this->timeoutMs = (int)$menu['timeoutms'];
$this->title = $menu['title'];
$this->defaultEntryId = $menu['defaultentryid'];
- $res = Database::simpleQuery("SELECT e.menuentryid, e.entryid, e.hotkey, e.title, e.hidden, e.sortval, e.md5pass,
+ $res = Database::simpleQuery("SELECT e.menuentryid, e.entryid, e.refmenuid, e.hotkey, e.title, e.hidden, e.sortval, e.md5pass,
b.data AS bootentry
FROM serversetup_menuentry e
LEFT JOIN serversetup_bootentry b USING (entryid)
@@ -139,4 +139,4 @@ class EmptyIPxeMenu extends IPxeMenu
]);
}
-} \ No newline at end of file
+}
diff --git a/modules-available/serversetup-bwlp-ipxe/inc/menuentry.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/menuentry.inc.php
index d29995c6..27713b9e 100644
--- a/modules-available/serversetup-bwlp-ipxe/inc/menuentry.inc.php
+++ b/modules-available/serversetup-bwlp-ipxe/inc/menuentry.inc.php
@@ -49,8 +49,10 @@ class MenuEntry
$this->hotkey = self::getKeyCode($row['hotkey']);
if (!empty($row['bootentry'])) {
$this->bootEntry = BootEntry::fromJson($row['bootentry']);
+ } elseif ($row['refmenuid'] !== null) {
+ $this->bootEntry = BootEntry::forMenu($row['refmenuid']);
}
- $this->gap = (array_key_exists('entryid', $row) && $row['entryid'] === null);
+ $this->gap = (array_key_exists('entryid', $row) && $row['entryid'] === null && $row['refmenuid'] === null);
}
settype($this->hidden, 'bool');
settype($this->gap, 'bool');