From 6321e44a035e44176832777585a97cd865be3b65 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 5 Oct 2016 13:02:00 +0200 Subject: [PATCH] Fixed editing labels --- .../files/lib/acp/form/LabelAddForm.class.php | 25 +++++++++++++------ .../lib/acp/form/LabelEditForm.class.php | 12 +++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/wcfsetup/install/files/lib/acp/form/LabelAddForm.class.php b/wcfsetup/install/files/lib/acp/form/LabelAddForm.class.php index 71a60014f5..b72207bc41 100644 --- a/wcfsetup/install/files/lib/acp/form/LabelAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LabelAddForm.class.php @@ -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 */ diff --git a/wcfsetup/install/files/lib/acp/form/LabelEditForm.class.php b/wcfsetup/install/files/lib/acp/form/LabelEditForm.class.php index 84638c3aa7..da34d669de 100644 --- a/wcfsetup/install/files/lib/acp/form/LabelEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LabelEditForm.class.php @@ -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); } -- 2.20.1