Fixed menu items with object id but w/o handler being selectable
authorAlexander Ebert <ebert@woltlab.com>
Mon, 10 Oct 2016 10:25:02 +0000 (12:25 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 10 Oct 2016 10:25:02 +0000 (12:25 +0200)
Fixes #2101

wcfsetup/install/files/acp/templates/menuItemAdd.tpl
wcfsetup/install/files/lib/acp/form/MenuItemAddForm.class.php

index 6ddef7700619f7151eb6ba99de6e4cb6119fe9be..86b4f716d9b07b30013a2e12b878e5d99d410c4e 100644 (file)
                                        <option value="0">{lang}wcf.global.noSelection{/lang}</option>
                                        
                                        {foreach from=$pageNodeList item=pageNode}
-                                               <option value="{@$pageNode->pageID}"{if $pageNode->pageID == $pageID} selected{/if} data-identifier="{@$pageNode->identifier}">{if $pageNode->getDepth() > 1}{@"&nbsp;&nbsp;&nbsp;&nbsp;"|str_repeat:($pageNode->getDepth() - 1)}{/if}{$pageNode->name}</option>
+                                               {if !$pageNode->requireObjectID || $pageHandlers[$pageNode->pageID]|isset}
+                                                       <option value="{@$pageNode->pageID}"{if $pageNode->pageID == $pageID} selected{/if} data-identifier="{@$pageNode->identifier}">{if $pageNode->getDepth() > 1}{@"&nbsp;&nbsp;&nbsp;&nbsp;"|str_repeat:($pageNode->getDepth() - 1)}{/if}{$pageNode->name}</option>
+                                               {/if}
                                        {/foreach}
                                </select>
                                {if $errorField == 'pageID'}
index ab23759a0bf05db82dc3c75761f7d985c523fc73..57421cbcb8663219a725fae133ce999742a866d9 100644 (file)
@@ -197,15 +197,21 @@ class MenuItemAddForm extends AbstractForm {
                        }
                        
                        // validate page object id
-                       if (isset($this->pageHandlers[$page->pageID])) {
-                               if ($this->pageHandlers[$page->pageID] && !$this->pageObjectID) {
-                                       throw new UserInputException('pageObjectID');
+                       if ($page->requireObjectID) {
+                               if (isset($this->pageHandlers[$page->pageID])) {
+                                       if ($this->pageHandlers[$page->pageID] && !$this->pageObjectID) {
+                                               throw new UserInputException('pageObjectID');
+                                       }
+                                       
+                                       /** @var ILookupPageHandler $handler */
+                                       $handler = $page->getHandler();
+                                       if ($this->pageObjectID && !$handler->isValid($this->pageObjectID)) {
+                                               throw new UserInputException('pageObjectID', 'invalid');
+                                       }
                                }
-                               
-                               /** @var ILookupPageHandler $handler */
-                               $handler = $page->getHandler();
-                               if ($this->pageObjectID && !$handler->isValid($this->pageObjectID)) {
-                                       throw new UserInputException('pageObjectID', 'invalid');
+                               else {
+                                       // page requires an object id, but no handler is registered
+                                       throw new UserInputException('pageID', 'invalid');
                                }
                        }
                }