From 89e6c1ce7f901a19467fb5cbc18e8a87ea901482 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 19 Mar 2019 23:52:11 +0100 Subject: [serversetup-bwlp-ipxe] Implement cascaded menus --- modules-available/serversetup-bwlp-ipxe/install.inc.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'modules-available/serversetup-bwlp-ipxe/install.inc.php') diff --git a/modules-available/serversetup-bwlp-ipxe/install.inc.php b/modules-available/serversetup-bwlp-ipxe/install.inc.php index 25579c13..201e0ced 100644 --- a/modules-available/serversetup-bwlp-ipxe/install.inc.php +++ b/modules-available/serversetup-bwlp-ipxe/install.inc.php @@ -25,7 +25,8 @@ $res[] = tableCreate('serversetup_menu', " $res[] = tableCreate('serversetup_menuentry', " `menuentryid` int(11) NOT NULL AUTO_INCREMENT, `menuid` int(11) NOT NULL, - `entryid` varchar(16) CHARACTER SET ascii NULL COMMENT 'If NULL, entry is gap', + `entryid` varchar(16) CHARACTER SET ascii NULL COMMENT 'If NULL, entry is gap or another menu', + `refmenuid` int(11) DEFAULT NULL COMMENT 'If entryid is NULL this can be a ref to another menu', `hotkey` varchar(8) CHARACTER SET ascii NOT NULL, `title` varchar(100) NOT NULL COMMENT 'Sanitize this before insert', `hidden` tinyint(1) NOT NULL, @@ -77,6 +78,18 @@ $res[] = tableAddConstraint('serversetup_menu_location', 'menuid', 'serversetup_ $res[] = tableAddConstraint('serversetup_menu_location', 'defaultentryid', 'serversetup_menuentry', 'menuentryid', 'ON UPDATE CASCADE ON DELETE SET NULL'); +// 2019-03-19 Add refmenuid to have cascaded menus +if (!tableHasColumn('serversetup_menuentry', 'refmenuid')) { + if (Database::exec("ALTER TABLE serversetup_menuentry ADD COLUMN `refmenuid` int(11) DEFAULT NULL COMMENT 'If entryid is NULL this can be a ref to another menu'") !== false) { + $res[] = UPDATE_DONE; + } else { + $res[] = UPDATE_FAILED; + } +} + +$res[] = tableAddConstraint('serversetup_menuentry', 'refmenuid', 'serversetup_menu', 'menuid', + 'ON UPDATE CASCADE ON DELETE SET NULL'); + if (Module::get('location') !== false) { if (!tableExists('location')) { $res[] = UPDATE_RETRY; -- cgit v1.2.3-55-g7522