summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-08-07 17:46:00 +0200
committerGitHub <noreply@github.com>2020-08-07 17:46:00 +0200
commit54726d5934c47cd643900bb17e4ccc4f56e946bd (patch)
treef843b700d978034b743f543b5348679b5d85d73a /apps/user_ldap
parent408ed7ebd4c8da989fdbd45024cdec2e52a1f35c (diff)
parent96d418b37950369924b4566d8702e3237b7b187e (diff)
downloadnextcloud-server-54726d5934c47cd643900bb17e4ccc4f56e946bd.tar.gz
nextcloud-server-54726d5934c47cd643900bb17e4ccc4f56e946bd.zip
Merge pull request #21738 from nextcloud/techdebt/14552/migrate-OC_Group-post_removeFromGroup
Migrate OC_Group post_removeFromGroup hook to actual event object
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/Jobs/UpdateGroups.php11
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);