diff options
Diffstat (limited to 'apps/user_ldap/lib/Jobs/UpdateGroups.php')
-rw-r--r-- | apps/user_ldap/lib/Jobs/UpdateGroups.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/Jobs/UpdateGroups.php b/apps/user_ldap/lib/Jobs/UpdateGroups.php index 58254bf41e9..035caf0c33c 100644 --- a/apps/user_ldap/lib/Jobs/UpdateGroups.php +++ b/apps/user_ldap/lib/Jobs/UpdateGroups.php @@ -44,6 +44,8 @@ use OCA\User_LDAP\LogWrapper; use OCA\User_LDAP\Mapping\GroupMapping; use OCA\User_LDAP\Mapping\UserMapping; use OCA\User_LDAP\User\Manager; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\Group\Events\UserRemovedEvent; use OCP\ILogger; class UpdateGroups extends \OC\BackgroundJob\TimedJob { @@ -94,6 +96,10 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { * @param string[] $groups */ private static function handleKnownGroups($groups) { + $dispatcher = \OC::$server->query(IEventDispatcher::class); + $groupManager = \OC::$server->getGroupManager(); + $userManager = \OC::$server->getUserManager(); + \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – Dealing with known Groups.', ILogger::DEBUG); $query = \OC_DB::prepare(' UPDATE `*PREFIX*ldap_group_members` @@ -105,8 +111,11 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob { $knownUsers = unserialize(self::$groupsFromDB[$group]['owncloudusers']); $actualUsers = self::getGroupBE()->usersInGroup($group); $hasChanged = false; + + $groupObject = $groupManager->get($group); foreach (array_diff($knownUsers, $actualUsers) as $removedUser) { - \OCP\Util::emitHook('OC_User', 'post_removeFromGroup', ['uid' => $removedUser, 'gid' => $group]); + $userObject = $userManager->get($removedUser); + $dispatcher->dispatchTyped(new UserRemovedEvent($groupObject, $userObject)); \OCP\Util::writeLog('user_ldap', 'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".', ILogger::INFO); |