From: Alexander Ebert Date: Tue, 24 Aug 2021 21:23:55 +0000 (+0200) Subject: Prevent the menu item itself being selected as its parent item X-Git-Tag: 5.4.5_RC_1~21 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=16d196e986cbb30d15e7495fcfa8515dfb323da3;p=GitHub%2FWoltLab%2FWCF.git 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/ --- 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 */