UserGroupOptions now behave the same as back in WCF 1.x
authorAlexander Ebert <ebert@woltlab.com>
Wed, 10 Jul 2013 12:23:10 +0000 (14:23 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 10 Jul 2013 12:23:10 +0000 (14:23 +0200)
14 files changed:
wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php
wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php
wcfsetup/install/files/lib/system/option/user/group/BBCodeSelectUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/BooleanUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/FileSizeUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/IUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/InfiniteIntegerUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/InfiniteInverseIntegerUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/IntegerUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/InverseIntegerUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/TextUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/TextareaUserGroupOptionType.class.php
wcfsetup/install/files/lib/system/option/user/group/UserGroupsUserGroupOptionType.class.php

index 8e70c4b127b1ed9390abddfcfdb6cfa3c4d71fbe..f0118e743840cf5daf51a120ca8a57bdceec98f4 100755 (executable)
@@ -139,17 +139,6 @@ class UserGroupAddForm extends AbstractOptionListForm {
                // 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(
@@ -158,7 +147,7 @@ class UserGroupAddForm extends AbstractOptionListForm {
                                'userOnlineMarking' => $this->userOnlineMarking,
                                'showOnTeamPage' => $this->showOnTeamPage
                        )),
-                       'options' => $saveOptions
+                       'options' => $optionValues
                );
                $this->objectAction = new UserGroupAction(array(), 'create', $data);
                $this->objectAction->executeAction();
index a0993b45942ddda148c517777f59b7a739508787..1b6bae350b059e5244581c103b1369fc08c49a65 100755 (executable)
@@ -124,25 +124,6 @@ class UserGroupEditForm extends UserGroupAddForm {
                
                // 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);
@@ -159,7 +140,7 @@ class UserGroupEditForm extends UserGroupAddForm {
                                'userOnlineMarking' => $this->userOnlineMarking,
                                'showOnTeamPage' => $this->showOnTeamPage
                        ), $this->additionalFields),
-                       'options' => $saveOptions
+                       'options' => $optionValues
                );
                $this->objectAction = new UserGroupAction(array($this->groupID), 'update', $data);
                $this->objectAction->executeAction();
index 0e2b56bfc2c9312dde8ca9b6002395829836dc26..fa89cd68c0588840dd145bf0027b89bfa80f4dd3 100644 (file)
@@ -195,17 +195,6 @@ class UserGroupOptionForm extends AbstractForm {
                        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)) {
index ad24c4549d63d9bc8bbbfa0150782b9eb92276f4..bed95f450305875127858b63aab80cfdfd0a5bc0 100644 (file)
@@ -70,35 +70,6 @@ class BBCodeSelectUserGroupOptionType extends AbstractOptionType implements IUse
                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()
         */
index f260338550da3631895f5716092745e24abf2307..a9f63e126b0491fe49238261ba92c744c6dae778 100644 (file)
@@ -15,13 +15,6 @@ use wcf\system\option\BooleanOptionType;
  * @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()
         */
index 61703b96a861bc75779b8c83d1e5bd9f62a83cef..293b24b0facb6b5bbba9273b036f654c97383e19 100644 (file)
@@ -15,13 +15,6 @@ use wcf\system\option\FileSizeOptionType;
  * @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()
         */
index 44ca6f425f8dfcc4c4fc1d89b5b19c39bb2a3cdc..9eccdd82530c161095fa1860312010f59045c1e9 100644 (file)
@@ -13,16 +13,6 @@ use wcf\system\option\IOptionType;
  * @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.
         * 
index 8e36355e05cc9a3cd2c04067553575bd05499627..f669eedbf2c4b2926d518a2f46efdb898167328d 100644 (file)
@@ -16,13 +16,6 @@ namespace wcf\system\option\user\group;
  * @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()
         */
index 4c8595e666795e39fe71af4676fce9bd8e6d0203..f1d4c1ae2ed78c1ea0b86be9541eec89eb780e84 100644 (file)
@@ -15,13 +15,6 @@ namespace wcf\system\option\user\group;
  * @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()
         */
index 6949cba4f8c2467e7e7d74d86b190de58d5d03d7..39224bbd3330028762fee7288e024e21cd144222 100644 (file)
@@ -15,13 +15,6 @@ use wcf\system\option\IntegerOptionType;
  * @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()
         */
index 3bbb60e699a9f1c4015e347eb3b0b0007947e2df..ae5509865b6f468de3b2632267260015c947aca1 100644 (file)
@@ -15,13 +15,6 @@ use wcf\system\option\IntegerOptionType;
  * @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()
         */
index f2e819a7e4331c544e1bcde78deb92a6c440e036..5334e08bdd6c105d8c2b7f87a80429f302da70d6 100644 (file)
@@ -19,21 +19,6 @@ use wcf\util\StringUtil;
  *             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()
         */
index 0f99bf41709f406cdc43faa9c6d2a07629fa0567..f29d7061a6304f25f939a742528f1d37b586abe0 100644 (file)
@@ -16,21 +16,6 @@ use wcf\util\StringUtil;
  * @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()
         */
index ecc0be2716d6396f5fb20d8ee47a0cdcc2f8510a..ad61f90cd21ca9db81b05306ea623bbfb8c66d0a 100644 (file)
@@ -66,21 +66,6 @@ class UserGroupsUserGroupOptionType extends AbstractOptionType implements IUserG
                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()
         */