From 16d196e986cbb30d15e7495fcfa8515dfb323da3 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 24 Aug 2021 23:23:55 +0200 Subject: [PATCH] Prevent the menu item itself being selected as its parent item See https://community.woltlab.com/thread/291999-men%C3%BCpunkt-verschwindet-wenn-%C3%BCbergeordneter-men%C3%BCpunkt-der-gleiche-ist/ --- .../install/files/acp/templates/menuItemAdd.tpl | 8 +++++++- .../files/lib/acp/form/MenuItemEditForm.class.php | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/acp/templates/menuItemAdd.tpl b/wcfsetup/install/files/acp/templates/menuItemAdd.tpl index acf5734293..c99a7396d9 100644 --- a/wcfsetup/install/files/acp/templates/menuItemAdd.tpl +++ b/wcfsetup/install/files/acp/templates/menuItemAdd.tpl @@ -71,7 +71,13 @@ {foreach from=$menuItemNodeList item=menuItemNode} - + {/foreach} {if $errorField == 'parentItemID'} diff --git a/wcfsetup/install/files/lib/acp/form/MenuItemEditForm.class.php b/wcfsetup/install/files/lib/acp/form/MenuItemEditForm.class.php index 03b11f02c3..2cfc6fd1a1 100644 --- a/wcfsetup/install/files/lib/acp/form/MenuItemEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/MenuItemEditForm.class.php @@ -8,6 +8,7 @@ use wcf\data\menu\Menu; use wcf\data\page\PageNodeTree; use wcf\form\AbstractForm; use wcf\system\exception\IllegalLinkException; +use wcf\system\exception\UserInputException; use wcf\system\language\I18nHandler; use wcf\system\page\handler\ILookupPageHandler; use wcf\system\WCF; @@ -69,6 +70,18 @@ class MenuItemEditForm extends MenuItemAddForm } } + /** + * @inheritDoc + */ + public function validate() + { + parent::validate(); + + if ($this->parentItemID == $this->itemID) { + throw new UserInputException('parentItemID'); + } + } + /** * @inheritDoc */ -- 2.20.1