summaryrefslogtreecommitdiffstats
path: root/modules-available/serversetup-bwlp-ipxe
diff options
context:
space:
mode:
authorSimon Rettberg2021-11-30 15:27:59 +0100
committerSimon Rettberg2022-03-09 15:06:54 +0100
commit41612c4481111969367d1a228ad4875d781558a2 (patch)
treed59bc50a3a2822faa6b800bd1f74f97c5ca692b3 /modules-available/serversetup-bwlp-ipxe
parent[permissionmanager] Fix for PHP 8 (diff)
downloadslx-admin-41612c4481111969367d1a228ad4875d781558a2.tar.gz
slx-admin-41612c4481111969367d1a228ad4875d781558a2.tar.xz
slx-admin-41612c4481111969367d1a228ad4875d781558a2.zip
[locations] Modularize additional column handling
Additional columns are now added through a hook, moving specialized code where it belongs.
Diffstat (limited to 'modules-available/serversetup-bwlp-ipxe')
-rw-r--r--modules-available/serversetup-bwlp-ipxe/hooks/locations-column.inc.php57
-rw-r--r--modules-available/serversetup-bwlp-ipxe/lang/de/module.json1
-rw-r--r--modules-available/serversetup-bwlp-ipxe/lang/en/module.json1
3 files changed, 59 insertions, 0 deletions
diff --git a/modules-available/serversetup-bwlp-ipxe/hooks/locations-column.inc.php b/modules-available/serversetup-bwlp-ipxe/hooks/locations-column.inc.php
new file mode 100644
index 00000000..d3290b62
--- /dev/null
+++ b/modules-available/serversetup-bwlp-ipxe/hooks/locations-column.inc.php
@@ -0,0 +1,57 @@
+<?php
+
+if (!User::hasPermission('.serversetup.ipxe.menu.assign')
+ || !Module::isAvailable('serversetup')
+ || !class_exists('IPxe')) {
+ return null;
+}
+
+class IpxeLocationColumn extends AbstractLocationColumn
+{
+
+ private $lookup = [];
+
+ public function __construct(array $allowedLocationIds)
+ {
+ $res = Database::simpleQuery("SELECT ml.locationid, m.title, ml.defaultentryid FROM serversetup_menu m
+ INNER JOIN serversetup_menu_location ml USING (menuid)
+ WHERE locationid IN (:allowedLocationIds) GROUP BY locationid", compact('allowedLocationIds'));
+ foreach ($res as $row) {
+ $lid = (int)$row['locationid'];
+ if ($row['defaultentryid'] !== null) {
+ $row['title'] .= '(*)';
+ }
+ $this->lookup[$lid] = $row['title'];
+ }
+ }
+
+ public function getColumnHtml(int $locationId): string
+ {
+ return htmlspecialchars($this->lookup[$locationId] ?? '');
+ }
+
+ public function getEditUrl(int $locationId): string
+ {
+ if (!User::hasPermission('.serversetup.ipxe.menu.assign', $locationId))
+ return '';
+ return '?do=serversetup&show=assignlocation&locationid=' . $locationId;
+ }
+
+ public function header(): string
+ {
+ return Dictionary::translateFileModule('serversetup', 'module', 'location-column-header');
+ }
+
+ public function priority(): int
+ {
+ return 3000;
+ }
+
+ public function propagateColumn(): bool
+ {
+ return true;
+ }
+
+}
+
+return new IpxeLocationColumn($allowedLocationIds); \ No newline at end of file
diff --git a/modules-available/serversetup-bwlp-ipxe/lang/de/module.json b/modules-available/serversetup-bwlp-ipxe/lang/de/module.json
index 43209a2e..559b84a5 100644
--- a/modules-available/serversetup-bwlp-ipxe/lang/de/module.json
+++ b/modules-available/serversetup-bwlp-ipxe/lang/de/module.json
@@ -9,6 +9,7 @@
"dl-usb": "USB-Image",
"dl-usbnic": "Mit USB Netzwerktreibern",
"dl-x86_64": "64\u2009Bit",
+ "location-column-header": "Bootmen\u00fc",
"module_name": "iPXE \/ Boot Menu",
"page_title": "PXE- und Boot-Einstellungen",
"submenu_address": "Boot-IP \/ iPXE-Version setzen",
diff --git a/modules-available/serversetup-bwlp-ipxe/lang/en/module.json b/modules-available/serversetup-bwlp-ipxe/lang/en/module.json
index 643e51ba..ce660fc1 100644
--- a/modules-available/serversetup-bwlp-ipxe/lang/en/module.json
+++ b/modules-available/serversetup-bwlp-ipxe/lang/en/module.json
@@ -9,6 +9,7 @@
"dl-usb": "thumb drive image",
"dl-usbnic": "with USB NIC drivers",
"dl-x86_64": "64 bit",
+ "location-column-header": "Boot menu",
"module_name": "iPXE \/ Boot Menu",
"page_title": "iPXE and boot settings",
"submenu_address": "Set boot IP \/ iPXE version",