/** * @see \wcf\form\IForm::validate() */ 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', 'notValid'); } // validate label if (!I18nHandler::getInstance()->validateValue('label')) { if (I18nHandler::getInstance()->isPlainValue('label')) { throw new UserInputException('label'); } else { throw new UserInputException('label', 'multilingual'); } } // validate class name if (empty($this->cssClassName)) { throw new UserInputException('cssClassName', 'empty'); } else { if (!in_array($this->cssClassName, $this->availableCssClassNames)) { throw new UserInputException('cssClassName', 'notValid'); } else { if ($this->cssClassName == 'custom') { if (!empty($this->customCssClassName) && !Regex::compile('^-?[_a-zA-Z]+[_a-zA-Z0-9-]+$')->match($this->customCssClassName)) { throw new UserInputException('cssClassName', 'notValid'); } } } } }
/** * @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild() */ protected function rebuild(array $parameters) { $data = array('options' => array(), 'groups' => array()); // get label groups $groupList = new LabelGroupList(); $groupList->readObjects(); $groups = $groupList->getObjects(); foreach ($groups as &$group) { $data['groups'][$group->groupID] = new ViewableLabelGroup($group); } unset($group); // get permissions for groups $permissions = ACLHandler::getInstance()->getPermissions(ACLHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.label'), array_keys($data['groups'])); // store options $data['options'] = $permissions['options']->getObjects(); // assign permissions for each label group foreach ($data['groups'] as $groupID => $group) { // group permissions if (isset($permissions['group'][$groupID])) { $group->setGroupPermissions($permissions['group'][$groupID]); } // user permissions if (isset($permissions['user'][$groupID])) { $group->setUserPermissions($permissions['user'][$groupID]); } } if (count($groupList)) { // get labels $labelList = new LabelList(); $labelList->sqlOrderBy = 'label'; $labelList->readObjects(); foreach ($labelList as $label) { $data['groups'][$label->groupID]->addLabel($label); } } return $data; }