From 77d5885827f123745a0d304019bb6bd0952b45cd Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 15 Feb 2018 15:06:40 +0100 Subject: [serversetup-bwlp] Make use of new permission helpers --- modules-available/serversetup-bwlp/page.inc.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'modules-available/serversetup-bwlp/page.inc.php') diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php index 16d3f8e2..ae709da7 100644 --- a/modules-available/serversetup-bwlp/page.inc.php +++ b/modules-available/serversetup-bwlp/page.inc.php @@ -17,7 +17,8 @@ class Page_ServerSetup extends Page Util::redirect('?do=Main'); } - if (Request::any('action') === 'getimage' && User::hasPermission("download")) { + if (Request::any('action') === 'getimage') { + User::assertPermission("download"); $this->handleGetImage(); } @@ -30,13 +31,15 @@ class Page_ServerSetup extends Page $this->getLocalAddresses(); } - if ($action === 'ip' && User::hasPermission("edit.address")) { + if ($action === 'ip') { + User::assertPermission("edit.address"); // New address is to be set $this->getLocalAddresses(); $this->updateLocalAddress(); } - if ($action === 'ipxe' && User::hasPermission("edit.menu")) { + if ($action === 'ipxe') { + User::assertPermission("edit.menu"); // iPXE stuff changes $this->updatePxeMenu(); } @@ -50,12 +53,18 @@ class Page_ServerSetup extends Page Render::addTemplate('ipxe_update', array('taskid' => $taskid)); } + Permission::addGlobalTags($perms, null, ['edit.menu', 'edit.address', 'download']); + Render::addTemplate('ipaddress', array( 'ips' => $this->taskStatus['data']['addresses'], 'chooseHintClass' => $this->hasIpSet ? '' : 'alert alert-danger', 'editAllowed' => User::hasPermission("edit.address"), + 'perms' => $perms, )); $data = $this->currentMenu; + if (!User::hasPermission('edit.menu')) { + unset($data['masterpasswordclear']); + } if (!isset($data['defaultentry'])) { $data['defaultentry'] = 'net'; } @@ -68,8 +77,7 @@ class Page_ServerSetup extends Page if ($data['defaultentry'] === 'custom') { $data['active-custom'] = 'checked'; } - $data['editAllowed'] = User::hasPermission("edit.menu"); - $data['downloadAllowed'] = User::hasPermission("download"); + $data['perms'] = $perms; Render::addTemplate('ipxe', $data); } -- cgit v1.2.3-55-g7522 From 24815e16087b4b1b64e9f380d45d411af32daf42 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 9 Apr 2018 16:56:04 +0200 Subject: Permissions: Consistency: Make all pages require at least one permission to be accessible Closes #3340 --- modules-available/backup/page.inc.php | 1 + modules-available/exams/page.inc.php | 9 +-------- modules-available/locations/page.inc.php | 19 +++++++++++++++---- modules-available/news/page.inc.php | 10 ++-------- modules-available/news/permissions/permissions.json | 3 +++ modules-available/rebootcontrol/page.inc.php | 9 ++++++--- modules-available/serversetup-bwlp/page.inc.php | 6 ++++++ .../serversetup-bwlp/permissions/permissions.json | 3 +++ modules-available/statistics_reporting/page.inc.php | 1 + modules-available/sysconfig/page.inc.php | 2 +- modules-available/syslog/page.inc.php | 1 + modules-available/systemstatus/page.inc.php | 1 + modules-available/webinterface/page.inc.php | 4 ++++ .../webinterface/permissions/permissions.json | 3 +++ 14 files changed, 48 insertions(+), 24 deletions(-) (limited to 'modules-available/serversetup-bwlp/page.inc.php') diff --git a/modules-available/backup/page.inc.php b/modules-available/backup/page.inc.php index 14522734..985f39ee 100644 --- a/modules-available/backup/page.inc.php +++ b/modules-available/backup/page.inc.php @@ -23,6 +23,7 @@ class Page_Backup extends Page User::assertPermission("restore"); $this->restore(); } + User::assertPermission('*'); } protected function doRender() diff --git a/modules-available/exams/page.inc.php b/modules-available/exams/page.inc.php index 51975052..15640a73 100644 --- a/modules-available/exams/page.inc.php +++ b/modules-available/exams/page.inc.php @@ -441,16 +441,9 @@ class Page_Exams extends Page protected function doRender() { - if (Request::isPost()) { - $examid = Request::post('examid', 0, 'int'); - } else if (Request::isGet()) { - $examid = Request::get('examid', 0, 'int'); - } else { - die('Neither Post nor Get Request send.'); - } - if ($this->action === "show") { + User::assertPermission('exams.view'); // General title and description Render::addTemplate('page-main-heading'); // List of defined exam periods diff --git a/modules-available/locations/page.inc.php b/modules-available/locations/page.inc.php index 80a8076b..4d5c6628 100644 --- a/modules-available/locations/page.inc.php +++ b/modules-available/locations/page.inc.php @@ -24,6 +24,9 @@ class Page_Locations extends Page } elseif ($this->action === 'updatesubnets') { $this->updateSubnets(); } + if (Request::isPost()) { + Util::redirect('?do=locations'); + } } private function updateSubnets() @@ -306,10 +309,16 @@ class Page_Locations extends Page protected function doRender() { - $getAction = Request::get('action'); - if (empty($getAction)) { - // Until we have a main landing page? - Util::redirect('?do=Locations&action=showlocations'); + $getAction = Request::get('action', false, 'string'); + if ($getAction === false) { + if (User::hasPermission('location.view')) { + Util::redirect('?do=locations&action=showlocations'); + } elseif (User::hasPermission('subnets.edit')) { + Util::redirect('?do=locations&action=showsubnets'); + } else { + // Trigger permission denied by asserting non-existent permission + User::assertPermission('location.view'); + } } if ($getAction === 'showsubnets') { User::assertPermission('subnets.edit', NULL, '?do=locations'); @@ -324,6 +333,8 @@ class Page_Locations extends Page Render::addTemplate('subnets', array('list' => $rows)); } elseif ($getAction === 'showlocations') { $this->showLocationList(); + } else { + Util::redirect('?do=locations'); } } diff --git a/modules-available/news/page.inc.php b/modules-available/news/page.inc.php index e7b70c0f..1e2e3eef 100644 --- a/modules-available/news/page.inc.php +++ b/modules-available/news/page.inc.php @@ -46,14 +46,8 @@ class Page_News extends Page // check which action we need to do $action = Request::any('action', 'show'); - if ($action === 'clear') { - // clear news input fields - // TODO: is this the right way? - $this->newsId = false; - $this->newsTitle = false; - $this->newsContent = false; - $this->newsDate = false; - } elseif ($action === 'show') { + if ($action === 'show') { + User::assertPermission('access-page'); /* load latest things */ $this->loadLatest('help'); $this->loadLatest('news'); diff --git a/modules-available/news/permissions/permissions.json b/modules-available/news/permissions/permissions.json index 0d9435d7..953599df 100644 --- a/modules-available/news/permissions/permissions.json +++ b/modules-available/news/permissions/permissions.json @@ -1,4 +1,7 @@ { + "access-page": { + "location-aware": false + }, "help.delete": { "location-aware": false }, diff --git a/modules-available/rebootcontrol/page.inc.php b/modules-available/rebootcontrol/page.inc.php index abbdb2c3..041ae74f 100644 --- a/modules-available/rebootcontrol/page.inc.php +++ b/modules-available/rebootcontrol/page.inc.php @@ -79,11 +79,14 @@ class Page_RebootControl extends Page //location you want to see, default are "not assigned" clients $requestedLocation = Request::get('location', false, 'int'); $allowedLocs = User::getAllowedLocations("action.*"); + if (empty($allowedLocs)) { + User::assertPermission('action.*'); + } if ($requestedLocation === false) { if (in_array(0, $allowedLocs)) { $requestedLocation = 0; - } elseif (!empty($allowedLocs)) { + } else { $requestedLocation = reset($allowedLocs); } } @@ -105,8 +108,8 @@ class Page_RebootControl extends Page Render::addTemplate('header', $data); // only fill table if user has at least one permission for the location - if ($requestedLocation === false) { - Message::addError('main.no-permission'); + if (!in_array($requestedLocation, $allowedLocs)) { + Message::addError('locations.no-permission-location', $requestedLocation); } else { $data['data'] = RebootQueries::getMachineTable($requestedLocation); Render::addTemplate('_page', $data); diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php index ae709da7..78096d7b 100644 --- a/modules-available/serversetup-bwlp/page.inc.php +++ b/modules-available/serversetup-bwlp/page.inc.php @@ -43,6 +43,12 @@ class Page_ServerSetup extends Page // iPXE stuff changes $this->updatePxeMenu(); } + + if (Request::isPost()) { + Util::redirect('?do=serversetup'); + } + + User::assertPermission('access-page'); } protected function doRender() diff --git a/modules-available/serversetup-bwlp/permissions/permissions.json b/modules-available/serversetup-bwlp/permissions/permissions.json index 6bae5422..44927506 100644 --- a/modules-available/serversetup-bwlp/permissions/permissions.json +++ b/modules-available/serversetup-bwlp/permissions/permissions.json @@ -1,4 +1,7 @@ { + "access-page": { + "location-aware": false + }, "download": { "location-aware": false }, diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php index af4b2b12..cc03e4d8 100644 --- a/modules-available/statistics_reporting/page.inc.php +++ b/modules-available/statistics_reporting/page.inc.php @@ -84,6 +84,7 @@ class Page_Statistics_Reporting extends Page die(json_encode($report)); } } + User::assertPermission('*'); } /** diff --git a/modules-available/sysconfig/page.inc.php b/modules-available/sysconfig/page.inc.php index 7bb3e599..8d1799af 100644 --- a/modules-available/sysconfig/page.inc.php +++ b/modules-available/sysconfig/page.inc.php @@ -160,7 +160,7 @@ class Page_SysConfig extends Page $pMods = User::hasPermission('module.view-list'); $pConfs = User::hasPermission('config.view-list'); if (!($pMods || $pConfs)) { - Message::addError('main.no-permission'); + User::assertPermission('config.view-list'); } Render::openTag('div', array('class' => 'row')); if ($pConfs) { diff --git a/modules-available/syslog/page.inc.php b/modules-available/syslog/page.inc.php index 3a7513b5..00c55a3f 100644 --- a/modules-available/syslog/page.inc.php +++ b/modules-available/syslog/page.inc.php @@ -25,6 +25,7 @@ class Page_SysLog extends Page } Util::redirect('?do=syslog'); } + User::assertPermission('*'); } protected function doRender() diff --git a/modules-available/systemstatus/page.inc.php b/modules-available/systemstatus/page.inc.php index 816caa05..66b30bcf 100644 --- a/modules-available/systemstatus/page.inc.php +++ b/modules-available/systemstatus/page.inc.php @@ -18,6 +18,7 @@ class Page_SystemStatus extends Page User::assertPermission("serverreboot"); $this->rebootTask = Taskmanager::submit('Reboot'); } + User::assertPermission('*'); } protected function doRender() diff --git a/modules-available/webinterface/page.inc.php b/modules-available/webinterface/page.inc.php index 806ffd59..ca52c2ab 100644 --- a/modules-available/webinterface/page.inc.php +++ b/modules-available/webinterface/page.inc.php @@ -28,6 +28,10 @@ class Page_WebInterface extends Page $this->actionCustomization(); break; } + if (Request::isPost()) { + Util::redirect('?do=webinterface'); + } + User::assertPermission('access-page'); } private function actionConfigureHttps() diff --git a/modules-available/webinterface/permissions/permissions.json b/modules-available/webinterface/permissions/permissions.json index fa6f493f..ed81602a 100644 --- a/modules-available/webinterface/permissions/permissions.json +++ b/modules-available/webinterface/permissions/permissions.json @@ -1,4 +1,7 @@ { + "access-page": { + "location-aware": false + }, "edit.design": { "location-aware": false }, -- cgit v1.2.3-55-g7522 From 9b24161637553f3889d9a81344e6eec59dc6aa00 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 7 May 2018 17:34:35 +0200 Subject: [serversetup-bwlp] Add log output to ipxe building task --- inc/event.inc.php | 3 +-- inc/trigger.inc.php | 1 + .../serversetup-bwlp/lang/de/template-tags.json | 4 +++- .../serversetup-bwlp/lang/en/template-tags.json | 4 +++- modules-available/serversetup-bwlp/page.inc.php | 20 ++++++++++-------- .../serversetup-bwlp/templates/ipxe_update.html | 24 ++++++++++++++++++---- 6 files changed, 40 insertions(+), 16 deletions(-) (limited to 'modules-available/serversetup-bwlp/page.inc.php') diff --git a/inc/event.inc.php b/inc/event.inc.php index fe59b2b9..b1ee3663 100644 --- a/inc/event.inc.php +++ b/inc/event.inc.php @@ -98,8 +98,7 @@ class Event public static function serverIpChanged() { error_log('Server ip changed'); - global $tidIpxe; - $tidIpxe = Trigger::ipxe(); + Trigger::ipxe(); if (Module::isAvailable('sysconfig')) { // TODO: Modularize events ConfigModule::serverIpChanged(); } diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php index b49cafb0..93f57236 100644 --- a/inc/trigger.inc.php +++ b/inc/trigger.inc.php @@ -25,6 +25,7 @@ class Trigger $task = Taskmanager::submit('CompileIPxe', $data); if (!isset($task['id'])) return false; + Property::set('ipxe-task-id', $task['id'], 15); return $task['id']; } diff --git a/modules-available/serversetup-bwlp/lang/de/template-tags.json b/modules-available/serversetup-bwlp/lang/de/template-tags.json index f80febb0..74ab494b 100644 --- a/modules-available/serversetup-bwlp/lang/de/template-tags.json +++ b/modules-available/serversetup-bwlp/lang/de/template-tags.json @@ -21,9 +21,11 @@ "lang_menuCustomHint3": "und w\u00e4hlen Sie als Standard-Bootverhalten ebenfalls custom.", "lang_menuDisplayTime": "Anzeigedauer des Men\u00fcs", "lang_menuGeneration": "Erzeugen des Bootmen\u00fcs", - "lang_moduleHeading": "iPXE / Boot Menu", + "lang_moduleHeading": "iPXE \/ Boot Menu", + "lang_pxeBuilt": "PXE-Binary gebaut", "lang_seconds": "Sekunden", "lang_set": "Setzen", + "lang_usbBuilt": "USB-Image gebaut", "lang_usbImage": "USB-Image", "lang_usbImgHelp": "Mit dem USB-Image k\u00f6nnen Sie einen bootbaren USB-Stick erstellen, \u00fcber den sich bwLehrpool an Rechnern starten l\u00e4sst, die keinen Netzwerkboot unterst\u00fctzen, bzw. f\u00fcr die keine entsprechende DHCP-Konfiguration vorhanden ist. Dies erfordert dann lediglich, dass in der BIOS-Konfiguration des Rechners USB-Boot zugelassen ist. Der Stick dient dabei lediglich als Einstiegspunkt; es ist nach wie vor ein bwLehrpool-Satellitenserver f\u00fcr den eigentlichen Bootvorgang von N\u00f6ten.", "lang_usbImgHelpLinux": "Nutzen Sie dd, um das Image auf einen USB-Stick zu schreiben. Das Image enth\u00e4lt bereits eine Partitionstabelle, achten Sie daher darauf, dass Sie das Image z.B. nach \/dev\/sdx schreiben, und nicht nach \/dev\/sdx1", diff --git a/modules-available/serversetup-bwlp/lang/en/template-tags.json b/modules-available/serversetup-bwlp/lang/en/template-tags.json index 1948718b..7f519022 100644 --- a/modules-available/serversetup-bwlp/lang/en/template-tags.json +++ b/modules-available/serversetup-bwlp/lang/en/template-tags.json @@ -21,9 +21,11 @@ "lang_menuCustomHint3": "and select as the default boot behavior custom as well.", "lang_menuDisplayTime": "Menu Display Time", "lang_menuGeneration": "Generating boot menu...", - "lang_moduleHeading": "iPXE / Boot Menu", + "lang_moduleHeading": "iPXE \/ Boot Menu", + "lang_pxeBuilt": "Built PXE binary", "lang_seconds": "Seconds", "lang_set": "Set", + "lang_usbBuilt": "Built USB image", "lang_usbImage": "USB image", "lang_usbImgHelp": "The USB image can be used to create a bootable USB stick, which enables you to boot bwLehrpool without changing your DHCP settings or enabling network boot in the clients. The only requirement is that you enable USB boot in the client's BIOS. The USB stick is only used for bootstrapping, the actual bwLehrpool system is still loaded via network from your local bwLehrpool server.", "lang_usbImgHelpLinux": "On Linux you can simply use dd to write the image to a usb stick. The image already contains a partition table, so make sure you write the image to the device itself and not to an already existing partition (e.g. to \/dev\/sdx not \/dev\/sdx1)", diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php index 78096d7b..52b3afe4 100644 --- a/modules-available/serversetup-bwlp/page.inc.php +++ b/modules-available/serversetup-bwlp/page.inc.php @@ -54,9 +54,15 @@ class Page_ServerSetup extends Page protected function doRender() { Render::addTemplate("heading"); - $taskid = Request::any('taskid'); - if ($taskid !== false && Taskmanager::isTask($taskid)) { - Render::addTemplate('ipxe_update', array('taskid' => $taskid)); + $task = Property::get('ipxe-task-id'); + if ($task !== false) { + $task = Taskmanager::status($task); + if (!Taskmanager::isTask($task) || Taskmanager::isFinished($task)) { + $task = false; + } + } + if ($task !== false) { + Render::addTemplate('ipxe_update', array('taskid' => $task['id'])); } Permission::addGlobalTags($perms, null, ['edit.menu', 'edit.address', 'download']); @@ -137,9 +143,7 @@ class Page_ServerSetup extends Page } if ($valid) { Property::setServerIp($newAddress); - global $tidIpxe; - if (isset($tidIpxe) && $tidIpxe !== false) - Util::redirect('?do=ServerSetup&taskid=' . $tidIpxe); + Util::redirect('?do=ServerSetup'); } else { Message::addError('invalid-ip', $newAddress); } @@ -163,8 +167,8 @@ class Page_ServerSetup extends Page else $this->currentMenu['masterpassword'] = Crypto::hash6($this->currentMenu['masterpasswordclear']); Property::setBootMenu($this->currentMenu); - $id = Trigger::ipxe(); - Util::redirect('?do=ServerSetup&taskid=' . $id); + Trigger::ipxe(); + Util::redirect('?do=ServerSetup'); } private function handleGetImage() diff --git a/modules-available/serversetup-bwlp/templates/ipxe_update.html b/modules-available/serversetup-bwlp/templates/ipxe_update.html index 9c598667..e7ba5ffa 100644 --- a/modules-available/serversetup-bwlp/templates/ipxe_update.html +++ b/modules-available/serversetup-bwlp/templates/ipxe_update.html @@ -1,20 +1,36 @@
{{lang_menuTitle}} | +{{lang_locationCount}} | +{{lang_isDefault}} | +{{lang_edit}} | +
---|---|---|---|
+ {{title}} + | ++ {{locationCount}} + | ++ {{#isdefault}} + + {{/isdefault}} + | ++ {{#allowEdit}} + + + + {{/allowEdit}} + | +
{{lang_entryId}} | {{lang_title}} | {{lang_hotkey}} | -{{lang_sortOrder}} | {{lang_password}} | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
-
+
+
+ |
+
+
+ |
+
{{#entryid}}
|
{{/entryid}}
-
-
- |
+
@@ -111,4 +116,25 @@
-
\ No newline at end of file
+
+
+
\ No newline at end of file
--
cgit v1.2.3-55-g7522
From 303e32fe9fbbe0897ea53dd8dd41c60abf1f0434 Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Thu, 28 Jun 2018 12:35:30 +0200
Subject: [serversetup-bwlp] Simplify sorting of menu entries
---
modules-available/serversetup-bwlp/page.inc.php | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
(limited to 'modules-available/serversetup-bwlp/page.inc.php')
diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php
index f2c422f3..061abfd5 100644
--- a/modules-available/serversetup-bwlp/page.inc.php
+++ b/modules-available/serversetup-bwlp/page.inc.php
@@ -186,10 +186,9 @@ class Page_ServerSetup extends Page
}
$menu['timeout'] = round($menu['timeoutms'] / 1000);
$menu['entries'] = Database::queryAll("SELECT menuentryid, entryid, hotkey, title, hidden, sortval, plainpass FROM
- serversetup_menuentry WHERE menuid = :id", compact('id'));
+ serversetup_menuentry WHERE menuid = :id ORDER BY sortval ASC", compact('id'));
$keyList = array_map(function ($item) { return ['key' => $item]; }, MenuEntry::getKeyList());
$entryList = Database::queryAll("SELECT entryid, title, hotkey FROM serversetup_bootentry ORDER BY title ASC");
- $sortVals = array();
foreach ($menu['entries'] as &$entry) {
$entry['isdefault'] = ($entry['menuentryid'] == $menu['defaultentryid']);
$entry['keys'] = $keyList;
@@ -207,12 +206,7 @@ class Page_ServerSetup extends Page
$item['title'] = $item['entryid'];
}
}
- $sortVals[] = $entry['sortval'];
}
- $arr = $menu['entries'];
- $keys = array_keys($arr);
- array_multisort( $sortVals, SORT_ASC, $arr, $keys);
- $menu['entries'] = $arr;
// TODO: Make assigned locations editable
Permission::addGlobalTags($menu['perms'], 0, ['ipxe.menu.edit']);
Render::addTemplate('menu-edit', $menu);
--
cgit v1.2.3-55-g7522
From ff57c086a3b868cc73f159fa29891d26a5a3e02b Mon Sep 17 00:00:00 2001
From: Simon Rettberg
Date: Wed, 4 Jul 2018 12:35:56 +0200
Subject: [serversetup-bwlp] Fix hotkey saving, adding new entries
---
.../serversetup-bwlp/inc/menuentry.inc.php | 1 +
modules-available/serversetup-bwlp/page.inc.php | 53 ++++++----
.../serversetup-bwlp/templates/menu-edit.html | 116 ++++++++++++++++++---
3 files changed, 134 insertions(+), 36 deletions(-)
(limited to 'modules-available/serversetup-bwlp/page.inc.php')
diff --git a/modules-available/serversetup-bwlp/inc/menuentry.inc.php b/modules-available/serversetup-bwlp/inc/menuentry.inc.php
index 9736b7bb..9d9d4163 100644
--- a/modules-available/serversetup-bwlp/inc/menuentry.inc.php
+++ b/modules-available/serversetup-bwlp/inc/menuentry.inc.php
@@ -162,6 +162,7 @@ class MenuEntry
*/
public static function filterKeyName($keyName)
{
+ $data = self::getKeyArray();
if (isset($data[$keyName]))
return $keyName;
return '';
diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php
index 061abfd5..00b658c4 100644
--- a/modules-available/serversetup-bwlp/page.inc.php
+++ b/modules-available/serversetup-bwlp/page.inc.php
@@ -187,25 +187,11 @@ class Page_ServerSetup extends Page
$menu['timeout'] = round($menu['timeoutms'] / 1000);
$menu['entries'] = Database::queryAll("SELECT menuentryid, entryid, hotkey, title, hidden, sortval, plainpass FROM
serversetup_menuentry WHERE menuid = :id ORDER BY sortval ASC", compact('id'));
- $keyList = array_map(function ($item) { return ['key' => $item]; }, MenuEntry::getKeyList());
- $entryList = Database::queryAll("SELECT entryid, title, hotkey FROM serversetup_bootentry ORDER BY title ASC");
+ $menu['keys'] = array_map(function ($item) { return ['key' => $item]; }, MenuEntry::getKeyList());
+ $menu['entrylist'] = Database::queryAll("SELECT entryid, title, hotkey FROM serversetup_bootentry ORDER BY title ASC");
foreach ($menu['entries'] as &$entry) {
$entry['isdefault'] = ($entry['menuentryid'] == $menu['defaultentryid']);
- $entry['keys'] = $keyList;
- foreach ($entry['keys'] as &$key) {
- if ($key['key'] === $entry['hotkey']) {
- $key['selected'] = 'selected'; // TODO: plainpass only when permissions
- }
- }
- $entry['entrylist'] = $entryList;
- foreach ($entry['entrylist'] as &$item) {
- if ($item['entryid'] == $entry['entryid']) {
- $item['selected'] = 'selected';
- }
- if (empty($item['title'])) {
- $item['title'] = $item['entryid'];
- }
- }
+ // TODO: plainpass only when permissions
}
// TODO: Make assigned locations editable
Permission::addGlobalTags($menu['perms'], 0, ['ipxe.menu.edit']);
@@ -303,7 +289,7 @@ class Page_ServerSetup extends Page
'menuid' => $id,
'title' => IPxe::sanitizeIpxeString(Request::post('title', '', 'string')),
'timeoutms' => abs(Request::post('timeoutms', 0, 'int') * 1000),
- 'defaultentryid' => Request::post('defaultentry', false, 'int'),
+ 'defaultentryid' => Request::post('defaultentry', null, 'int'),
]);
if (User::hasPermission('ipxe.menu.edit', 0)) {
Database::exec('UPDATE serversetup_menu SET isdefault = (menuid = :menuid)', ['menuid' => $id]);
@@ -313,15 +299,38 @@ class Page_ServerSetup extends Page
$entries = Request::post('entry', false, 'array');
foreach ($entries as $key => $entry) {
+ if (!isset($entry['sortval'])) {
+ error_log(print_r($entry, true));
+ continue;
+ }
+ // Fallback defaults
+ $entry += [
+ 'entryid' => null,
+ 'title' => '',
+ 'hidden' => 0,
+ 'plainpass' => '',
+ ];
$params = [
- 'entryid' => $entry['entryid'], // TODO validate
- 'hotkey' => MenuEntry::filterKeyName($entry['hotkey']),
'title' => IPxe::sanitizeIpxeString($entry['title']),
- 'hidden' => (int)$entry['hidden'],
'sortval' => (int)$entry['sortval'],
- 'plainpass' => $entry['plainpass'],
'menuid' => $menu['menuid'],
];
+ if (empty($entry['entryid'])) {
+ // Spacer
+ $params += [
+ 'entryid' => null,
+ 'hotkey' => '',
+ 'hidden' => 0, // Doesn't make any sense
+ 'plainpass' => '', // Doesn't make any sense
+ ];
+ } else {
+ $params += [
+ 'entryid' => $entry['entryid'], // TODO validate?
+ 'hotkey' => MenuEntry::filterKeyName($entry['hotkey']),
+ 'hidden' => (int)$entry['hidden'], // TODO (needs hotkey to make sense)
+ 'plainpass' => $entry['plainpass'],
+ ];
+ }
if (is_numeric($key)) {
$keepIds[] = $key;
$params['menuentryid'] = $key;
diff --git a/modules-available/serversetup-bwlp/templates/menu-edit.html b/modules-available/serversetup-bwlp/templates/menu-edit.html
index 4fabd11c..603c7425 100644
--- a/modules-available/serversetup-bwlp/templates/menu-edit.html
+++ b/modules-available/serversetup-bwlp/templates/menu-edit.html
@@ -1,5 +1,8 @@
| {{lang_editMenuHead}}+ + +
{{title}}
@@ -57,14 +60,15 @@
{{#entries}}
-
|
- |
+
@@ -73,11 +77,7 @@
{{#entryid}}
- |
-
|
{{#entryid}}
- |
{{/entryid}}
-
|
|
+ + | + +
+
+
+
+
+ |
+
+
+ |
+ + + | +
+ |
+ + + | +
{{lang_bootentryTitle}} | +Hotkey | +{{lang_edit}} | +{{lang_delete}} | +
---|---|---|---|
+ {{title}} + | ++ {{hotkey}} + | ++ {{#allowEdit}} + + + + {{/allowEdit}} + | ++ {{#allowDelete}} + + {{/allowDelete}} + | +
- | - | {{lang_entryId}} | ++ | + | {{lang_entryId}} | {{lang_title}} | -{{lang_hotkey}} | -{{lang_password}} | -- | + | {{lang_hotkey}} | +{{lang_password}} | ++ |
---|
{{lang_name}} | +{{lang_systemmodel}} | {{lang_count}} | {{lang_override}} |
---|
{{lang_bootentryTitle}} | -Hotkey | +{{lang_hotkey}} | +{{lang_refCount}} | {{lang_edit}} | {{lang_delete}} | {{hotkey}} | ++ {{refs}} + | {{#allowEdit}} diff --git a/modules-available/serversetup-bwlp/templates/ipxe-new-boot-entry.html b/modules-available/serversetup-bwlp/templates/ipxe-new-boot-entry.html index fe496029..7e82b5cc 100644 --- a/modules-available/serversetup-bwlp/templates/ipxe-new-boot-entry.html +++ b/modules-available/serversetup-bwlp/templates/ipxe-new-boot-entry.html @@ -14,7 +14,7 @@ | {{#entries}} -
---|---|---|---|---|---|
diff --git a/modules-available/serversetup-bwlp/templates/menu-list.html b/modules-available/serversetup-bwlp/templates/menu-list.html
index 67365a33..545f22a9 100644
--- a/modules-available/serversetup-bwlp/templates/menu-list.html
+++ b/modules-available/serversetup-bwlp/templates/menu-list.html
@@ -1,5 +1,9 @@
{{lang_listOfMenus}}++ {{lang_menuListIntro}} + +
|