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')) {
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
*/
}
}
+ /**
+ * @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
*/
// 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);
}