From: Matthias Schmidt Date: Mon, 25 Feb 2019 17:49:49 +0000 (+0100) Subject: Add more places where automatic user group assignment is checked X-Git-Tag: 5.2.0_Alpha_1~260 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=afca594ea5de47a0c937799bbee3d25568745b03;p=GitHub%2FWoltLab%2FWCF.git Add more places where automatic user group assignment is checked See #2809 --- diff --git a/wcfsetup/install/files/lib/data/user/UserAction.class.php b/wcfsetup/install/files/lib/data/user/UserAction.class.php index a7714806b7..fe67f7ad93 100644 --- a/wcfsetup/install/files/lib/data/user/UserAction.class.php +++ b/wcfsetup/install/files/lib/data/user/UserAction.class.php @@ -20,6 +20,7 @@ use wcf\system\exception\PermissionDeniedException; use wcf\system\exception\UserInputException; use wcf\system\language\LanguageFactory; use wcf\system\request\RequestHandler; +use wcf\system\user\group\assignment\UserGroupAssignmentHandler; use wcf\system\WCF; use wcf\util\UserRegistrationUtil; @@ -454,11 +455,17 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio if (isset($this->parameters['deleteOldGroups'])) $deleteOldGroups = $this->parameters['deleteOldGroups']; if (isset($this->parameters['addDefaultGroups'])) $addDefaultGroups = $this->parameters['addDefaultGroups']; + $userIDs = []; foreach ($this->getObjects() as $userEditor) { + $userIDs[] = $userEditor->userID; $userEditor->addToGroups($groupIDs, $deleteOldGroups, $addDefaultGroups); } - //reread objects + if (empty($this->parameters['ignoreUserGroupAssignments'])) { + UserGroupAssignmentHandler::getInstance()->checkUsers($userIDs); + } + + // reread objects $this->objects = []; UserEditor::resetCache(); $this->readObjects(); @@ -639,6 +646,12 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio } } + $userIDs = []; + foreach ($this->getObjects() as $user) { + $userIDs[] = $user->userID; + } + UserGroupAssignmentHandler::getInstance()->checkUsers($userIDs); + $this->unmarkItems(); } diff --git a/wcfsetup/install/files/lib/form/RegisterForm.class.php b/wcfsetup/install/files/lib/form/RegisterForm.class.php index 645458873a..dc04cf4e1f 100644 --- a/wcfsetup/install/files/lib/form/RegisterForm.class.php +++ b/wcfsetup/install/files/lib/form/RegisterForm.class.php @@ -23,6 +23,7 @@ use wcf\system\exception\UserInputException; use wcf\system\language\LanguageFactory; use wcf\system\request\LinkHandler; use wcf\system\user\authentication\UserAuthenticationFactory; +use wcf\system\user\group\assignment\UserGroupAssignmentHandler; use wcf\system\user\notification\object\UserRegistrationUserNotificationObject; use wcf\system\user\notification\UserNotificationHandler; use wcf\system\WCF; @@ -437,6 +438,7 @@ class RegisterForm extends UserAddForm { ]; $this->objectAction = new UserAction([], 'create', $data); $result = $this->objectAction->executeAction(); + /** @var User $user */ $user = $result['returnValues']; $userEditor = new UserEditor($user); @@ -455,6 +457,8 @@ class RegisterForm extends UserAddForm { // activation management if (REGISTER_ACTIVATION_METHOD == 0) { $this->message = 'wcf.user.register.success'; + + UserGroupAssignmentHandler::getInstance()->checkUsers([$user->userID]); } else if (REGISTER_ACTIVATION_METHOD == 1) { // registering via 3rdParty leads to instant activation diff --git a/wcfsetup/install/files/lib/system/cronjob/UserGroupAssignmentCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/UserGroupAssignmentCronjob.class.php index b0073b43ae..374d2c12e0 100644 --- a/wcfsetup/install/files/lib/system/cronjob/UserGroupAssignmentCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/UserGroupAssignmentCronjob.class.php @@ -35,7 +35,8 @@ class UserGroupAssignmentCronjob extends AbstractCronjob { $userAction = new UserAction(array_unique($users), 'addToGroups', [ 'addDefaultGroups' => false, 'deleteOldGroups' => false, - 'groups' => [$groupID] + 'groups' => [$groupID], + 'ignoreUserGroupAssignments' => true ]); $userAction->executeAction(); } diff --git a/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php b/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php index 6d43e55f8d..f18e4a97e0 100644 --- a/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/group/assignment/UserGroupAssignmentHandler.class.php @@ -69,7 +69,8 @@ class UserGroupAssignmentHandler extends SingletonFactory { $userAction = new UserAction([$user], 'addToGroups', [ 'addDefaultGroups' => false, 'deleteOldGroups' => false, - 'groups' => $newGroupIDs + 'groups' => $newGroupIDs, + 'ignoreUserGroupAssignments' => true ]); $userAction->executeAction(); }