add method "removeFromGroups()"
authorJoshua Rüsweg <josh@joshsboard.de>
Thu, 1 May 2014 14:28:05 +0000 (16:28 +0200)
committerJoshua Rüsweg <josh@joshsboard.de>
Thu, 1 May 2014 14:28:05 +0000 (16:28 +0200)
As it's not currently with the action can only add users to groups, but can not remove it again, I would propose to add this method in order to create a proper opportunity to remove user from user groups.

wcfsetup/install/files/lib/data/user/UserAction.class.php

index 4e61f3c91ce06a00c8cb6eca7e60255d17faaa7a..cc23dce4e470c558ee8d75467df21dcf2a1ae029 100644 (file)
@@ -329,6 +329,35 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                }
        }
        
+       /**
+        * Add users to given groups.
+        */
+       public function removeFromGroups() {
+               if (empty($this->objects)) {
+                       $this->readObjects();
+               }
+               
+               $groupIDs = $this->parameters['groups'];
+               
+               foreach ($this->objects as $userEditor) {
+                       $userEditor->removeFromGroups($groupIDs);
+               }
+               
+               //reread objects
+               $this->objects = array();
+               UserEditor::resetCache();
+               $this->readObjects();
+               
+               if (MODULE_USER_RANK) {
+                       $action = new UserProfileAction($this->objects, 'updateUserRank');
+                       $action->executeAction();
+               }
+               if (MODULE_USERS_ONLINE) {
+                       $action = new UserProfileAction($this->objects, 'updateUserOnlineMarking');
+                       $action->executeAction();
+               }
+       }
+       
        /**
         * Add users to given groups.
         */