// get default group
$defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE);
$optionValues = $this->optionHandler->save();
- $saveOptions = array();
- foreach ($this->optionHandler->getCategoryOptions() as $option) {
- $option = $option['object'];
- $defaultValue = $defaultGroup->getGroupOption($option->optionName);
- $typeObject = $this->optionHandler->getTypeObject($option->optionType);
-
- $newValue = $typeObject->diff($defaultValue, $optionValues[$option->optionID]);
- if ($newValue !== null) {
- $saveOptions[$option->optionID] = $newValue;
- }
- }
$data = array(
'data' => array_merge($this->additionalFields, array(
'userOnlineMarking' => $this->userOnlineMarking,
'showOnTeamPage' => $this->showOnTeamPage
)),
- 'options' => $saveOptions
+ 'options' => $optionValues
);
$this->objectAction = new UserGroupAction(array(), 'create', $data);
$this->objectAction->executeAction();
// save group
$optionValues = $this->optionHandler->save();
- $saveOptions = array();
- if ($this->group->groupType == UserGroup::EVERYONE) {
- $saveOptions = $optionValues;
- }
- else {
- // get default group
- $defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE);
- foreach ($this->optionHandler->getCategoryOptions() as $option) {
- $option = $option['object'];
- $defaultValue = $defaultGroup->getGroupOption($option->optionName);
- $typeObject = $this->optionHandler->getTypeObject($option->optionType);
-
- $newValue = $typeObject->diff($defaultValue, $optionValues[$option->optionID]);
- if ($newValue !== null) {
- $saveOptions[$option->optionID] = $newValue;
- }
- }
- }
-
$this->groupName = 'wcf.acp.group.group'.$this->group->groupID;
if (I18nHandler::getInstance()->isPlainValue('groupName')) {
I18nHandler::getInstance()->remove($this->groupName, 1);
'userOnlineMarking' => $this->userOnlineMarking,
'showOnTeamPage' => $this->showOnTeamPage
), $this->additionalFields),
- 'options' => $saveOptions
+ 'options' => $optionValues
);
$this->objectAction = new UserGroupAction(array($this->groupID), 'update', $data);
$this->objectAction->executeAction();
catch (UserInputException $e) {
$this->errorType[$e->getField()] = $e->getType();
}
-
- // check if not editing default value
- if ($groupID != $this->groupEveryone->groupID) {
- $newValue = $this->optionType->diff($this->defaultValue, $optionValue);
- if ($newValue === null) {
- unset($this->values[$groupID]);
- }
- else {
- $this->values[$groupID] = $newValue;
- }
- }
}
if (!empty($this->errorType)) {
asort($this->bbCodes);
}
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::merge()
- */
- public function diff($defaultValue, $groupValue) {
- if ($this->bbCodes === null) {
- $this->loadBBCodeSelection();
- }
-
- if ($defaultValue == 'all') {
- $defaultValue = $this->bbCodes;
- }
- else {
- $defaultValue = explode(',', StringUtil::unifyNewlines($defaultValue));
- }
- if ($groupValue == 'all') {
- $groupValue = $this->bbCodes;
- }
- else {
- $groupValue = explode(',', StringUtil::unifyNewlines($groupValue));
- }
-
- $result = array_diff($groupValue, $defaultValue);
- if (empty($result)) {
- return null;
- }
-
- return implode(',', $result);
- }
-
/**
* @see wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
* @category Community Framework
*/
class BooleanUserGroupOptionType extends BooleanOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::diff()
- */
- public function diff($defaultValue, $groupValue) {
- return $this->merge($defaultValue, $groupValue);
- }
-
/**
* @see wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
* @category Community Framework
*/
class FileSizeUserGroupOptionType extends FileSizeOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::diff()
- */
- public function diff($defaultValue, $groupValue) {
- return $this->merge($defaultValue, $groupValue);
- }
-
/**
* @see wcf\system\option\user.group\IUserGroupOptionType::merge()
*/
* @category Community Framework
*/
interface IUserGroupOptionType extends IOptionType {
- /**
- * Returns the value which results by calculating the difference of the
- * given values.
- *
- * @param mixed $defaultValue
- * @param mixed $groupValue
- * @return mixed
- */
- public function diff($defaultValue, $groupValue);
-
/**
* Returns the value which results by merging or null if nothing should be saved.
*
* @category Community Framework
*/
class InfiniteIntegerUserGroupOptionType extends IntegerUserGroupOptionType {
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::diff()
- */
- public function diff($defaultValue, $groupValue) {
- return $this->merge($defaultValue, $groupValue);
- }
-
/**
* @see wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
* @category Community Framework
*/
class InfiniteInverseIntegerUserGroupOptionType extends InverseIntegerUserGroupOptionType {
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::diff()
- */
- public function diff($defaultValue, $groupValue) {
- return $this->merge($defaultValue, $groupValue);
- }
-
/**
* @see wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
* @category Community Framework
*/
class IntegerUserGroupOptionType extends IntegerOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::diff()
- */
- public function diff($defaultValue, $groupValue) {
- return $this->merge($defaultValue, $groupValue);
- }
-
/**
* @see wcf\system\option\user.group\IUserGroupOptionType::merge()
*/
* @category Community Framework
*/
class InverseIntegerUserGroupOptionType extends IntegerOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::diff()
- */
- public function diff($defaultValue, $groupValue) {
- return $this->merge($defaultValue, $groupValue);
- }
-
/**
* @see wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
* values? what to do?
*/
class TextUserGroupOptionType extends TextOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::diff()
- */
- public function diff($defaultValue, $groupValue) {
- $defaultValue = explode("\n", StringUtil::unifyNewlines($defaultValue));
- $groupValue = explode("\n", StringUtil::unifyNewlines($groupValue));
-
- $result = array_diff($groupValue, $defaultValue);
- if (empty($result)) {
- return null;
- }
-
- return implode("\n", $result);
- }
-
/**
* @see wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
* @category Community Framework
*/
class TextareaUserGroupOptionType extends TextareaOptionType implements IUserGroupOptionType {
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::diff()
- */
- public function diff($defaultValue, $groupValue) {
- $defaultValue = explode("\n", StringUtil::unifyNewlines($defaultValue));
- $groupValue = explode("\n", StringUtil::unifyNewlines($groupValue));
-
- $result = array_diff($groupValue, $defaultValue);
- if (empty($result)) {
- return null;
- }
-
- return implode("\n", $result);
- }
-
/**
* @see wcf\system\option\user\group\IUserGroupOptionType::merge()
*/
return implode(',', $newValue);
}
- /**
- * @see wcf\system\option\user\group\IUserGroupOptionType::diff()
- */
- public function diff($defaultValue, $groupValue) {
- $defaultValue = explode(',', $defaultValue);
- $groupValue = explode(',', $groupValue);
-
- $result = array_diff($groupValue, $defaultValue);
- if (empty($result)) {
- return null;
- }
-
- return implode(',', $result);
- }
-
/**
* @see wcf\system\option\user\group\IUserGroupOptionType::merge()
*/