From: Tim Düsterhus Date: Wed, 14 Jan 2015 23:37:04 +0000 (+0100) Subject: Fix TemplateGroupEditForm and validation of parent template groups X-Git-Tag: 2.1.0_Beta_4~94 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5e1f952e83fbe12ab70ecff635c3a49825920ec0;p=GitHub%2FWoltLab%2FWCF.git Fix TemplateGroupEditForm and validation of parent template groups --- diff --git a/wcfsetup/install/files/acp/templates/templateGroupAdd.tpl b/wcfsetup/install/files/acp/templates/templateGroupAdd.tpl index 10842d5894..5f35c16336 100644 --- a/wcfsetup/install/files/acp/templates/templateGroupAdd.tpl +++ b/wcfsetup/install/files/acp/templates/templateGroupAdd.tpl @@ -33,6 +33,15 @@ {htmlOptions options=$availableTemplateGroups selected=$parentTemplateGroupID disableEncoding=true} + {if $errorField == 'parentTemplateGroupID'} + + {if $errorType == 'empty'} + {lang}wcf.global.form.error.empty{/lang} + {else} + {lang}wcf.acp.template.group.parentTemplateGroupID.error.{@$errorType}{/lang} + {/if} + + {/if} {/if} diff --git a/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php index 7cbe21f7a8..26fb7f18c1 100644 --- a/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php @@ -75,6 +75,10 @@ class TemplateGroupAddForm extends AbstractForm { $this->validateName(); $this->validateFolderName(); + + if ($this->parentTemplateGroupID && !isset($this->availableTemplateGroups[$this->parentTemplateGroupID])) { + throw new UserInputException('parentTemplateGroupID', 'notValid'); + } } /** diff --git a/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php b/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php index 580c5d0c6a..bd97f6f67d 100644 --- a/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php @@ -90,12 +90,9 @@ class TemplateGroupEditForm extends TemplateGroupAddForm { * @see \wcf\page\IPage::readData() */ public function readData() { - AbstractForm::readData(); + $this->availableTemplateGroups = TemplateGroup::getSelectList(array($this->templateGroupID), 1); - $templateGroupList = new TemplateGroupList(); - $templateGroupList->getConditionBuilder()->add('templateGroupID <> ?', array($this->templateGroupID)); - $templateGroupList->readObjects(); - $this->availableTemplateGroups = $templateGroupList->getObjects(); + AbstractForm::readData(); // default values if (!count($_POST)) { diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index e4e1a8b1a5..62eff17466 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1515,6 +1515,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + templateGroupName}“ wirklich löschen?]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 9c870d4543..bae99b54c8 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1514,6 +1514,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + templateGroupName}”?]]>