diff options
author | Simon Rettberg | 2018-07-04 13:02:31 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-07-04 13:02:31 +0200 |
commit | 1229906bc79254bc22c9e08e04a025d8bb1d89bf (patch) | |
tree | 830251a21937e5b23266eed199833695a6f16991 /modules-available/serversetup-bwlp/page.inc.php | |
parent | [serversetup-bwlp] Fix hotkey saving, adding new entries (diff) | |
download | slx-admin-1229906bc79254bc22c9e08e04a025d8bb1d89bf.tar.gz slx-admin-1229906bc79254bc22c9e08e04a025d8bb1d89bf.tar.xz slx-admin-1229906bc79254bc22c9e08e04a025d8bb1d89bf.zip |
[serversetup-bwlp] Delete menu entries missing from POST data
Diffstat (limited to 'modules-available/serversetup-bwlp/page.inc.php')
-rw-r--r-- | modules-available/serversetup-bwlp/page.inc.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/modules-available/serversetup-bwlp/page.inc.php b/modules-available/serversetup-bwlp/page.inc.php index 00b658c4..dc53070b 100644 --- a/modules-available/serversetup-bwlp/page.inc.php +++ b/modules-available/serversetup-bwlp/page.inc.php @@ -343,20 +343,24 @@ class Page_ServerSetup extends Page $ret = Database::exec("INSERT INTO serversetup_menuentry (menuid, entryid, hotkey, title, hidden, sortval, plainpass, md5pass) VALUES (:menuid, :entryid, :hotkey, :title, :hidden, :sortval, :plainpass, '')", $params, true); - if ($ret && !empty($entry['plainpass'])) { + if ($ret) { $key = Database::lastInsertId(); - Database::exec('UPDATE serversetup_menuentry SET md5pass = :md5pass WHERE menuentryid = :id', [ - 'md5pass' => IPxe::makeMd5Pass($entry['plainpass'], $key), - 'key' => $id, - ]); + $keepIds[] = (int)$key; + if (!empty($entry['plainpass'])) { + Database::exec('UPDATE serversetup_menuentry SET md5pass = :md5pass WHERE menuentryid = :id', [ + 'md5pass' => IPxe::makeMd5Pass($entry['plainpass'], $key), + 'id' => $key, + ]); + } } } if ($ret === false) { Message::addWarning('error-saving-entry', $entry['title'], Database::lastError()); } - } + Database::exec('DELETE FROM serversetup_menuentry WHERE menuid = :menuid AND menuentryid NOT IN (:keep)', + ['menuid' => $menu['menuid'], 'keep' => $keepIds]); Message::addSuccess('menu-saved'); } |