From e7cc4e9d0e9a40274c8e337d0330e19dc450d929 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 10 Dec 2019 15:10:31 +0100 Subject: [serversetup-bwlp-ipxe/minilinux] Add comments, fix minor logic bug Saving a boot entry didn't properly check the validity of a hook's ID, which was broken anyways, so the invalid check didn't uncover that the actual cheking code didn't work either. --- .../inc/bootentryhook.inc.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php') diff --git a/modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php b/modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php index cf180006..73611b0a 100644 --- a/modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/inc/bootentryhook.inc.php @@ -26,6 +26,10 @@ abstract class BootEntryHook */ public abstract function extraFields(); + /** + * @param string $id + * @return bool + */ public abstract function isValidId($id); /** @@ -63,16 +67,30 @@ abstract class BootEntryHook return $this->getBootEntryInternal($data); } - public function setSelected($id) + /** + * @param string $mixed either the plain ID if the entry to be marked as selected, or the JSON string representing + * the entire entry, which must have a key called 'id' that will be used as the ID then. + */ + public function setSelected($mixed) { - $json = @json_decode($id, true); + $json = @json_decode($mixed, true); if (is_array($json)) { $id = $json['id']; $this->data = $json; + } else { + $id = $mixed; } $this->selectedId = $id; } + /** + * @return string ID of entry that was marked as selected by setSelected() + */ + public function getSelected() + { + return $this->selectedId; + } + public function renderExtraFields() { $list = $this->extraFields(); -- cgit v1.2.3-55-g7522