From 5e1f952e83fbe12ab70ecff635c3a49825920ec0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 15 Jan 2015 00:37:04 +0100 Subject: [PATCH] Fix TemplateGroupEditForm and validation of parent template groups --- .../install/files/acp/templates/templateGroupAdd.tpl | 9 +++++++++ .../files/lib/acp/form/TemplateGroupAddForm.class.php | 4 ++++ .../files/lib/acp/form/TemplateGroupEditForm.class.php | 7 ++----- wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 5 files changed, 17 insertions(+), 5 deletions(-) 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}”?]]> -- 2.20.1