From: Marcel Werk Date: Wed, 8 May 2013 23:11:13 +0000 (+0200) Subject: Small optimization X-Git-Tag: 2.0.0_Beta_1~226 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c2000c5dfda2481f4c775b06ed2f8a83f57ce7c0;p=GitHub%2FWoltLab%2FWCF.git Small optimization --- diff --git a/wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php b/wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php index ec3c10b2e6..a906a6aea3 100755 --- a/wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserAssignToGroupForm.class.php @@ -1,6 +1,7 @@ userID], $this->groupIDs); $groupsIDs = array_unique($groupsIDs); - $userEditor = new UserEditor($user); - $userEditor->addToGroups($groupsIDs, true, false); + $action = new UserAction(array(new UserEditor($user)), 'addToGroups', array( + 'groups' => $groupsIDs, + 'addDefaultGroups' => false + )); + $action->executeAction(); } ClipboardHandler::getInstance()->removeItems($this->objectTypeID); diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index 4ca3e19ed9..0a80ca626d 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -236,11 +236,12 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio $removeGroups = (isset($this->parameters['removeGroups'])) ? $this->parameters['removeGroups'] : array(); $userOptions = (isset($this->parameters['options'])) ? $this->parameters['options'] : array(); + if (!empty($groupIDs)) { + $action = new UserAction($this->objects, 'addToGroups', array('groups' => $groupIDs)); + $action->executeAction(); + } + foreach ($this->objects as $userEditor) { - if (!empty($groupIDs)) { - $userEditor->addToGroups($groupIDs); - } - if (!empty($removeGroups)) { $userEditor->removeFromGroups($removeGroups); } @@ -255,6 +256,22 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio } } + + public function addToGroups() { + if (empty($this->objects)) { + $this->readObjects(); + } + + $groupIDs = $this->parameters['groups']; + $deleteOldGroups = $addDefaultGroups = true; + if (isset($this->parameters['deleteOldGroups'])) $deleteOldGroups = $this->parameters['deleteOldGroups']; + if (isset($this->parameters['addDefaultGroups'])) $addDefaultGroups = $this->parameters['addDefaultGroups']; + + foreach ($this->objects as $userEditor) { + $userEditor->addToGroups($groupIDs, $deleteOldGroups, $addDefaultGroups); + } + } + /** * @see wcf\data\ISearchAction::validateGetSearchResultList() */