User groups are now properly saved
authorAlexander Ebert <ebert@woltlab.com>
Wed, 25 Jan 2012 21:25:57 +0000 (22:25 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 25 Jan 2012 21:25:57 +0000 (22:25 +0100)
wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserGroupEditForm.class.php
wcfsetup/install/files/lib/system/option/user/group/UserGroupOptionHandler.class.php

index 246d531a45e86fbcff67f04f8d69d68540fd93f5..e234d5279862e3b985d78f059b2607f532d64848 100755 (executable)
@@ -84,6 +84,12 @@ class UserGroupAddForm extends AbstractOptionListForm {
         */
        public $additionalFields = array();
        
+       /**
+        * list of values of group 'Anyone'
+        * @var array
+        */
+       public $defaultValues = array();
+       
        /**
         * @see wcf\page\IPage::readParameters()
         */
index cfa9239b9754504570fbc390cc8ef7f7b375e31e..69f7c0c375e6e4313ab23a23180cc7aefeeade12 100755 (executable)
@@ -60,6 +60,7 @@ class UserGroupEditForm extends UserGroupAddForm {
                }
                
                $this->group = new UserGroupEditor($group);
+               $this->optionHandler->setUserGroup($group);
        }
        
        /**
index 79b8904ca4a2c6e50a60367b1380dede10b03c41..7b1dfbb647ef5a607dfb0304ced92fcf00783403 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\system\option\user\group;
+use wcf\data\user\group\UserGroup;
 use wcf\system\exception\SystemException;
 use wcf\system\option\OptionHandler;
 use wcf\util\ClassUtil;
@@ -15,6 +16,21 @@ use wcf\util\ClassUtil;
  * @category   Community Framework
  */
 class UserGroupOptionHandler extends OptionHandler {
+       /**
+        * user group object
+        * @var wcf\data\user\group\UserGroup
+        */
+       protected $group = null;
+       
+       /**
+        * Sets current user group.
+        * 
+        * @param       wcf\data\user\group\UserGroup   $group
+        */
+       public function setUserGroup(UserGroup $group) {
+               $this->group = $group;
+       }
+       
        /**
         * @see wcf\system\option\OptionHandler::getClassName()
         */
@@ -35,4 +51,22 @@ class UserGroupOptionHandler extends OptionHandler {
                
                return $className;
        }
+       
+       /**
+        * @see wcf\system\option\IOptionHandler::readData()
+        */
+       public function readData() {
+               $defaultGroup = UserGroup::getGroupByType(UserGroup::EVERYONE);
+               foreach ($this->options as $option) {
+                       $this->optionValues[$option->optionName] = $defaultGroup->getGroupOption($option->optionName);
+                       
+                       // use group values over default values
+                       if ($this->group !== null) {
+                               $groupValue = $this->group->getGroupOption($option->optionName);
+                               if ($groupValue !== null) {
+                                       $this->optionValues[$option->optionName] = $groupValue;
+                               }
+                       }
+               }
+       }
 }
\ No newline at end of file