Fix TemplateGroupEditForm and validation of parent template groups
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 14 Jan 2015 23:37:04 +0000 (00:37 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 14 Jan 2015 23:37:04 +0000 (00:37 +0100)
wcfsetup/install/files/acp/templates/templateGroupAdd.tpl
wcfsetup/install/files/lib/acp/form/TemplateGroupAddForm.class.php
wcfsetup/install/files/lib/acp/form/TemplateGroupEditForm.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 10842d58949a5cb8d89fa5e8365049e4e8d36ba5..5f35c16336787093ae9acbaca89c44d669dbe465 100644 (file)
                                                        <option value="0">{lang}wcf.acp.template.group.default{/lang}</option>
                                                        {htmlOptions options=$availableTemplateGroups selected=$parentTemplateGroupID disableEncoding=true}
                                                </select>
+                                               {if $errorField == 'parentTemplateGroupID'}
+                                                       <small class="innerError">
+                                                               {if $errorType == 'empty'}
+                                                               {lang}wcf.global.form.error.empty{/lang}
+                                                               {else}
+                                                               {lang}wcf.acp.template.group.parentTemplateGroupID.error.{@$errorType}{/lang}
+                                                               {/if}
+                                                       </small>
+                                               {/if}
                                        </dd>
                                </dl>
                        {/if}
index 7cbe21f7a82c1d2b2d7989d9b86ddef9ad4b29d5..26fb7f18c11d685dc6c85f6fc721a35afa634bc1 100644 (file)
@@ -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');
+               }
        }
        
        /**
index 580c5d0c6a183d4e3d9b793af92a8e4f7481537b..bd97f6f67dd20173a672dac1af4494633a65faf9 100644 (file)
@@ -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)) {
index e4e1a8b1a576426a1de17c6512e061d6355982e4..62eff17466a3757fe1656039afbf7903aca33dcb 100644 (file)
@@ -1515,6 +1515,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.template.group.name.error.notUnique"><![CDATA[Der eingegebene Name wird bereits von einer anderen Templategruppe verwendet.]]></item>
                <item name="wcf.acp.template.group.folderName.error.notValid"><![CDATA[Sie haben einen ungültigen Verzeichnis-Namen eingegeben.]]></item>
                <item name="wcf.acp.template.group.folderName.error.notUnique"><![CDATA[Das angegebene Verzeichnis wird bereits von einer anderen Templategruppe verwendet.]]></item>
+               <item name="wcf.acp.template.group.parentTemplateGroupID.error.notValid"><![CDATA[Die ausgewählte übergeordnete Templategruppe ist ungültig.]]></item>
                <item name="wcf.acp.template.group.delete.sure"><![CDATA[Wollen Sie die Templategruppe „{$templateGroup->templateGroupName}“ wirklich löschen?]]></item>
                <item name="wcf.acp.template.source"><![CDATA[Template-Quelltext]]></item>
                <item name="wcf.acp.template.name.error.notUnique"><![CDATA[Der eingegebene Name wird bereits von einem anderen Template verwendet.]]></item>
index 9c870d454385f1a9ee6b09eac7df14116a18c822..bae99b54c82e2d226a6ecc4bf15b421871a68a51 100644 (file)
@@ -1514,6 +1514,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.template.group.name.error.notUnique"><![CDATA[This name is already taken by a different template group.]]></item>
                <item name="wcf.acp.template.group.folderName.error.notValid"><![CDATA[The specified directory is invalid.]]></item>
                <item name="wcf.acp.template.group.folderName.error.notUnique"><![CDATA[The specified directory is already in use by an other template group.]]></item>
+               <item name="wcf.acp.template.group.parentTemplateGroupID.error.notValid"><![CDATA[The specified Parent Template Group is invalid.]]></item>
                <item name="wcf.acp.template.group.delete.sure"><![CDATA[Do you really want to remove the template group “{$templateGroup->templateGroupName}”?]]></item>
                <item name="wcf.acp.template.source"><![CDATA[Template Source Code]]></item>
                <item name="wcf.acp.template.name.error.notUnique"><![CDATA[This name is already taken by a different template]]></item>