From b051fb4dd78482a8d51559df09668ae2bb382113 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 20 Mar 2019 15:35:56 +0100 Subject: [serversetup-bwlp-ipxe] Bootentry: add copy button & allow view only --- .../lang/de/template-tags.json | 2 ++ .../lang/en/template-tags.json | 8 ++++-- .../serversetup-bwlp-ipxe/page.inc.php | 16 +++++++---- .../templates/bootentry-list.html | 20 ++++++++++---- .../templates/ipxe-new-boot-entry.html | 32 +++++++++++++--------- 5 files changed, 51 insertions(+), 27 deletions(-) diff --git a/modules-available/serversetup-bwlp-ipxe/lang/de/template-tags.json b/modules-available/serversetup-bwlp-ipxe/lang/de/template-tags.json index 30b46e82..f5356a72 100644 --- a/modules-available/serversetup-bwlp-ipxe/lang/de/template-tags.json +++ b/modules-available/serversetup-bwlp-ipxe/lang/de/template-tags.json @@ -17,10 +17,12 @@ "lang_bootentryTitle": "Men\u00fceintrag", "lang_chooseIP": "Bitte w\u00e4hlen Sie die IP-Adresse, \u00fcber die der Server von den Clients zum Booten angesprochen werden soll.", "lang_commandLine": "Command line", + "lang_copy": "Kopieren", "lang_count": "Anzahl", "lang_createUsbImage": "Bootbaren USB-Stick erstellen", "lang_downloadBootImage": "Boot-Image herunterladen", "lang_downloadRufus": "Rufus herunterladen", + "lang_editBootEntryHead": "Men\u00fceintrag bearbeiten", "lang_editBuiltinWarn": "Achtung! Sie bearbeiten einen der vorgegebenen Eintr\u00e4ge! Bei einem Update k\u00f6nnten Ihre \u00c4nderungen wieder \u00fcberschrieben werden", "lang_editMenuHead": "Men\u00fc bearbeiten", "lang_efiOnly": "Nur EFI", diff --git a/modules-available/serversetup-bwlp-ipxe/lang/en/template-tags.json b/modules-available/serversetup-bwlp-ipxe/lang/en/template-tags.json index ba6d3a85..4bf78a5d 100644 --- a/modules-available/serversetup-bwlp-ipxe/lang/en/template-tags.json +++ b/modules-available/serversetup-bwlp-ipxe/lang/en/template-tags.json @@ -10,17 +10,19 @@ "lang_assignMenuToLocation": "Assign menu to location", "lang_biosOnly": "BIOS only", "lang_bootAddress": "Boot Address of the Server", - "lang_bootEntryData": "Menu entry data", + "lang_bootEntryData": "Menu item data", "lang_bootentryDeleteConfirm": "Are you sure you want to delete this menu item?", "lang_bootentryHead": "Menu items", - "lang_bootentryIntro": "This is where you can add, edit and remove menu items, which can be added to menus. A menu entry is either a combination of a kernel\/image to load (and an optional initrd), or a custom iPXE-script.", + "lang_bootentryIntro": "This is where you can add, edit and remove menu items, which can be added to menus. A menu item is either a combination of a kernel\/image to load (and an optional initrd), or a custom iPXE-script.", "lang_bootentryTitle": "Menu item", "lang_chooseIP": "Please select the IP address that the client server will use to boot.", "lang_commandLine": "Command line", + "lang_copy": "Copy", "lang_count": "Count", "lang_createUsbImage": "Create bootable thumb drive", "lang_downloadBootImage": "Download boot-image", "lang_downloadRufus": "Download Rufus", + "lang_editBootEntryHead": "Edit menu item", "lang_editBuiltinWarn": "WARNING! You're editing a predefined item. Future updates might reset your changes!", "lang_editMenuHead": "Edit menu", "lang_efiOnly": "EFI only", @@ -58,7 +60,7 @@ "lang_ok": "OK", "lang_override": "Override", "lang_pxeMenuContent": "pxelinux.cfg\/ menu definition", - "lang_pxelinuxEntriesOnly": "Import menu entries only, don't create menu", + "lang_pxelinuxEntriesOnly": "Import menu items only, don't create menu", "lang_pxelinuxImport": "Import PXELinux menu", "lang_pxelinuxImportIntro": "Here you can paste a pxelinux menu to convert it to an iPXE menu.", "lang_recompileHint": "Recompile iPXE binaries now. Usually this happens automatically on changes, but if you suspect problems caused by outdated binaries, you can trigger recompilation here.", diff --git a/modules-available/serversetup-bwlp-ipxe/page.inc.php b/modules-available/serversetup-bwlp-ipxe/page.inc.php index 9b97ff01..4061fa2b 100644 --- a/modules-available/serversetup-bwlp-ipxe/page.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/page.inc.php @@ -151,7 +151,7 @@ class Page_ServerSetup extends Page switch (Request::get('show')) { case 'editbootentry': - User::assertPermission('ipxe.bootentry.edit'); + User::assertPermission('ipxe.bootentry.*'); $this->showEditBootEntry(); break; case 'editmenu': @@ -482,7 +482,9 @@ class Page_ServerSetup extends Page } $entry->addFormFields($params); $params['title'] = $row['title']; - $params['oldentryid'] = $params['entryid'] = $row['entryid']; + if (!Request::get('copy')) { + $params['oldentryid'] = $params['entryid'] = $row['entryid']; + } $params['builtin'] = $row['builtin']; if (!is_array($params['entries'])) { $params['entries'] = []; @@ -498,6 +500,7 @@ class Page_ServerSetup extends Page WHERE me.entryid = :entryid', ['entryid' => $row['entryid']]); } + $params['disabled'] = User::hasPermission('ipxe.bootentry.edit') ? '' : 'disabled'; Render::addTemplate('ipxe-new-boot-entry', $params); } @@ -555,8 +558,11 @@ class Page_ServerSetup extends Page Message::addError('main.parameter-missing', 'deleteid'); return; } - Database::exec("DELETE FROM serversetup_bootentry WHERE entryid = :entryid", array("entryid" => $id)); - Message::addSuccess('bootentry-deleted'); + $res = Database::exec("DELETE FROM serversetup_bootentry + WHERE entryid = :entryid AND builtin = 0", array("entryid" => $id)); + if ($res > 0) { + Message::addSuccess('bootentry-deleted'); + } Util::redirect('?do=serversetup&show=bootentry'); } @@ -777,7 +783,7 @@ class Page_ServerSetup extends Page } else { // Edit existing entry $params['oldid'] = $oldEntryId; - Database::exec('UPDATE serversetup_bootentry SET entryid = :entryid, title = :title, data = :data + Database::exec('UPDATE serversetup_bootentry SET entryid = If(builtin = 0, :entryid, entryid), title = :title, data = :data WHERE entryid = :oldid', $params); Message::addSuccess('boot-entry-updated', $newId); } diff --git a/modules-available/serversetup-bwlp-ipxe/templates/bootentry-list.html b/modules-available/serversetup-bwlp-ipxe/templates/bootentry-list.html index 8185ad06..edfc0e5f 100644 --- a/modules-available/serversetup-bwlp-ipxe/templates/bootentry-list.html +++ b/modules-available/serversetup-bwlp-ipxe/templates/bootentry-list.html @@ -12,6 +12,7 @@ {{lang_hotkey}} {{lang_refCount}} {{lang_edit}} + {{#allowEdit}}{{lang_copy}}{{/allowEdit}} {{lang_delete}} @@ -31,17 +32,24 @@ {{refs}} - {{#allowEdit}} - + + + + {{#allowEdit}} + + + - {{/allowEdit}} + {{/allowEdit}} {{#allowEdit}} - + {{^builtin}} + + {{/builtin}} {{/allowEdit}} diff --git a/modules-available/serversetup-bwlp-ipxe/templates/ipxe-new-boot-entry.html b/modules-available/serversetup-bwlp-ipxe/templates/ipxe-new-boot-entry.html index a6955642..c04661f2 100644 --- a/modules-available/serversetup-bwlp-ipxe/templates/ipxe-new-boot-entry.html +++ b/modules-available/serversetup-bwlp-ipxe/templates/ipxe-new-boot-entry.html @@ -1,4 +1,9 @@ +{{^oldentryid}}

{{lang_newBootEntryHead}}

+{{/oldentryid}} +{{#oldentryid}} +

{{lang_editBootEntryHead}}

+{{/oldentryid}} {{#builtin}}
@@ -18,11 +23,11 @@
- +
- +
@@ -31,13 +36,14 @@ - +
- +
@@ -45,7 +51,7 @@ - @@ -62,39 +68,39 @@ - +
- +
+ value="{{commandLine}}" {{disabled}}>
+ name="entry[replace][{{mode}}]" {{replace_checked}} {{disabled}}>
+ name="entry[autoUnload][{{mode}}]" {{autoUnload_checked}} {{disabled}}>
+ name="entry[resetConsole][{{mode}}]" {{resetConsole_checked}} {{disabled}}>
@@ -111,7 +117,7 @@ {{lang_scriptContent}} + name="entry[script]" {{disabled}}>{{entry.script}} @@ -129,7 +135,7 @@
- -- cgit v1.2.3-55-g7522