Fix listing of user group members in ACP
authorMatthias Schmidt <gravatronics@live.com>
Fri, 25 Mar 2016 20:00:37 +0000 (21:00 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 25 Mar 2016 20:00:46 +0000 (21:00 +0100)
wcfsetup/install/files/lib/acp/form/UserSearchForm.class.php
wcfsetup/install/files/lib/system/condition/UserGroupCondition.class.php

index 526d6d34bbd66a84b09bc6a47e6c5f40a6f9acf3..0032d4efc366e71133826278259dff5aeba4eb33 100755 (executable)
@@ -1,10 +1,15 @@
 <?php
 namespace wcf\acp\form;
+use wcf\data\condition\Condition;
+use wcf\data\object\type\ObjectType;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\search\SearchEditor;
+use wcf\data\user\group\UserGroup;
 use wcf\data\user\UserList;
 use wcf\form\AbstractForm;
+use wcf\system\condition\IUserCondition;
 use wcf\system\event\EventHandler;
+use wcf\system\exception\SystemException;
 use wcf\system\exception\UserInputException;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
@@ -79,6 +84,13 @@ class UserSearchForm extends UserOptionListForm {
         */
        public $maxResults = 2000;
        
+       /**
+        * id of the group the users have to belong to
+        * is used on the user group list to show all users of a user group
+        * @var integer
+        */
+       public $groupID = 0;
+       
        /**
         * @see \wcf\page\IPage::readParameters()
         */
@@ -87,13 +99,14 @@ class UserSearchForm extends UserOptionListForm {
                
                // search user from passed groupID by group-view
                if (isset($_GET['groupID'])) {
-                       $this->groupIDs[] = intval($_GET['groupID']);
+                       $this->groupID = intval($_GET['groupID']);
                        
                        // disable check for security token for GET requests
                        $_POST['t'] = WCF::getSession()->getSecurityToken();
                        
                        // do search
                        try {
+                               $this->readData();
                                $this->validate();
                                $this->save();
                        }
@@ -204,8 +217,25 @@ class UserSearchForm extends UserOptionListForm {
                }
                
                foreach ($this->conditions as $conditions) {
-                       foreach ($conditions as $condition) {
-                               $condition->getProcessor()->validate();
+                       /** @var ObjectType $objectType */
+                       foreach ($conditions as $objectType) {
+                               /** @var IUserCondition $processor */
+                               $processor = $objectType->getProcessor();
+                               
+                               // manually inject user group data for listing of group members
+                               if ($this->groupID && $objectType->objectType == 'com.woltlab.wcf.userGroup') {
+                                       $userGroups = UserGroup::getAccessibleGroups([], [UserGroup::EVERYONE, UserGroup::GUESTS]);
+                                       
+                                       uasort($userGroups, function(UserGroup $groupA, UserGroup $groupB) {
+                                               return strcmp($groupA->getName(), $groupB->getName());
+                                       });
+                                       
+                                       $processor->setUserGroups($userGroups);
+                                       $processor->setData(new Condition(null, [
+                                               'conditionData' => serialize(['groupIDs' => [$this->groupID]])
+                                       ]));
+                               }
+                               $processor->validate();
                        }
                }
                
index 4f08f614dccbbbbc5509b2bb6b9fb7decb8b6def..0e6ef75f8e17a7b9ee39cb52e3fd6872e3cc1c10 100644 (file)
@@ -201,6 +201,15 @@ HTML;
                }
        }
        
+       /**
+        * Sets the selectable user groups.
+        * 
+        * @param       UserGroup[]     $userGroups
+        */
+       public function setUserGroups(array $userGroups) {
+               $this->userGroups = $userGroups;
+       }
+       
        /**
         * @see \wcf\system\condition\ICondition::validate()
         */