From: Alexander Ebert Date: Mon, 21 Jul 2014 21:14:43 +0000 (+0200) Subject: Merge pull request #1712 from joshuaruesweg/patch-18 X-Git-Tag: 2.1.0_Alpha_1~548^2~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3a435d47e052e6fc1d6280533e24ac22a2afdd6a;p=GitHub%2FWoltLab%2FWCF.git Merge pull request #1712 from joshuaruesweg/patch-18 add method "removeFromGroups()" --- 3a435d47e052e6fc1d6280533e24ac22a2afdd6a diff --cc wcfsetup/install/files/lib/data/user/UserAction.class.php index c4fc29578b,378f07c937..2c3e8d42ad --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@@ -360,43 -330,37 +363,72 @@@ class UserAction extends AbstractDataba $userEditor->addToLanguages($languageIDs); } } + + // handle user rename + if (count($this->objects) == 1 && !empty($this->parameters['data']['username'])) { + if ($this->objects[0]->username != $this->parameters['data']['username']) { + $userID = $this->objects[0]->userID; + $username = $this->parameters['data']['username']; + + WCF::getDB()->beginTransaction(); + + // update comments + $sql = "UPDATE wcf".WCF_N."_comment + SET username = ? + WHERE userID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($username, $userID)); + + $sql = "UPDATE wcf".WCF_N."_comment_response + SET username = ? + WHERE userID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($username, $userID)); + + // modification log + $sql = "UPDATE wcf".WCF_N."_modification_log + SET username = ? + WHERE userID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($username, $userID)); + + WCF::getDB()->commitTransaction(); + + // fire event to handle other database tables + EventHandler::getInstance()->fireAction($this, 'rename'); + } + } } + /** + * Remove users from 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. */