/**
  * @see	wcf\system\option\OptionHandler::getClassName()
  */
 protected function getClassName($type)
 {
     $className = parent::getClassName($type);
     if ($className === null) {
         $className = 'wcf\\system\\option\\user\\group\\' . ucfirst($type) . 'UserGroupOptionType';
         // validate class
         if (!class_exists($className)) {
             return null;
         }
         if (!ClassUtil::isInstanceOf($className, 'wcf\\system\\option\\IOptionType')) {
             throw new SystemException("'" . $className . "' should implement wcf\\system\\option\\IOptionType");
         }
     }
     return $className;
 }
 /**
  * @see	\wcf\system\option\OptionHandler::validateOption()
  */
 protected function validateOption(Option $option)
 {
     parent::validateOption($option);
     if (!$this->isAdmin()) {
         // get type object
         $typeObj = $this->getTypeObject($option->optionType);
         if ($typeObj->compare($this->optionValues[$option->optionName], WCF::getSession()->getPermission($option->optionName)) == 1) {
             throw new UserInputException($option->optionName, 'exceedsOwnPermission');
         }
     } else {
         if ($option->optionName == 'admin.user.accessibleGroups' && $this->group !== null && $this->group->isAdminGroup()) {
             $hasOtherAdminGroup = false;
             foreach (UserGroup::getGroupsByType() as $userGroup) {
                 if ($userGroup->groupID != $this->group->groupID && $userGroup->isAdminGroup()) {
                     $hasOtherAdminGroup = true;
                     break;
                 }
             }
             // prevent users from dropping their own admin state
             if (!$hasOtherAdminGroup) {
                 // get type object
                 $typeObj = $this->getTypeObject($option->optionType);
                 if ($typeObj->compare($this->optionValues[$option->optionName], WCF::getSession()->getPermission($option->optionName)) == -1) {
                     throw new UserInputException($option->optionName, 'cannotDropPrivileges');
                 }
             }
         }
     }
 }
 /**
  * @see	\wcf\system\option\IOptionHandler::readUserInput()
  */
 public function readUserInput(array &$source)
 {
     parent::readUserInput($source);
     // remove 4 byte utf-8 characters (e.g. emoji)
     foreach ($this->rawValues as &$value) {
         if (is_string($value)) {
             $value = MessageUtil::stripCrap($value);
         }
     }
     if ($this->searchMode) {
         $this->optionValues = $this->rawValues;
     }
 }
 /**
  * @see wcf\system\option\OptionHandler::save()
  */
 public function save($categoryName = null, $optionPrefix = null)
 {
     $options = parent::save($categoryName, $optionPrefix);
     // remove options which are not asked during registration
     if ($this->inRegistration && !empty($options)) {
         foreach ($this->options as $option) {
             if (!$option->askDuringRegistration && array_key_exists($option->optionID, $options)) {
                 unset($options[$option->optionID]);
             }
         }
     }
     return $options;
 }
Beispiel #5
0
	/**
	 * @see	wcf\system\option\IOptionHandler::readUserInput()
	 */
	public function readUserInput(array &$source) {
		parent::readUserInput($source);
		
		if ($this->searchMode) {
			$this->optionValues = $this->rawValues;
		}
	}