Fixed editing labels
authorAlexander Ebert <ebert@woltlab.com>
Wed, 5 Oct 2016 11:02:00 +0000 (13:02 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 5 Oct 2016 11:02:00 +0000 (13:02 +0200)
wcfsetup/install/files/lib/acp/form/LabelAddForm.class.php
wcfsetup/install/files/lib/acp/form/LabelEditForm.class.php

index 71a60014f50c374b4d8167d255c3c8686db4a48e..b72207bc41dd4636c9bfce539287fe37f2fc5f5d 100644 (file)
@@ -115,14 +115,7 @@ class LabelAddForm extends AbstractForm {
        public function validate() {
                parent::validate();
                
-               // validate group
-               if (!$this->groupID) {
-                       throw new UserInputException('groupID');
-               }
-               $groups = $this->labelGroupList->getObjects();
-               if (!isset($groups[$this->groupID])) {
-                       throw new UserInputException('groupID', 'invalid');
-               }
+               $this->validateGroup();
                
                // validate label
                if (!I18nHandler::getInstance()->validateValue('label')) {
@@ -150,6 +143,22 @@ class LabelAddForm extends AbstractForm {
                if ($this->showOrder < 0) $this->showOrder = 0;
        }
        
+       /**
+        * Validates selected label group.
+        * 
+        * @throws UserInputException
+        */
+       protected function validateGroup() {
+               // validate group
+               if (!$this->groupID) {
+                       throw new UserInputException('groupID');
+               }
+               $groups = $this->labelGroupList->getObjects();
+               if (!isset($groups[$this->groupID])) {
+                       throw new UserInputException('groupID', 'invalid');
+               }
+       }
+       
        /**
         * @inheritDoc
         */
index 84638c3aa7e11e9ee4c28717b5a440348e8e961c..da34d669de3194ca6f222f762aaee94980f6523d 100644 (file)
@@ -52,6 +52,16 @@ class LabelEditForm extends LabelAddForm {
                }
        }
        
+       /**
+        * @inheritDoc
+        */
+       protected function validateGroup() {
+               // groupID is immutable because altering it would cause issues with objects that are
+               // assigned to them, but the new group is not allowed at their current position
+               
+               // we're not saving the value anyway, therefore we can simply skip the checks
+       }
+       
        /**
         * @inheritDoc
         */
@@ -88,6 +98,8 @@ class LabelEditForm extends LabelAddForm {
                // reset values if non-custom value was choosen
                if ($this->cssClassName != 'custom') $this->customCssClassName = '';
                
+               $this->groupID = $this->labelObj->groupID;
+               
                // show success message
                WCF::getTPL()->assign('success', true);
        }