summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-07-07 21:17:25 +0200
committerMorris Jobke <hey@morrisjobke.de>2020-07-30 10:21:08 +0200
commit36ee37ec0af53b9b01612b2ce335e5aa9590d024 (patch)
tree5e523263051fe065d9caa02a5d75b6d49a155123 /apps/user_ldap/lib
parent788366500d10a018845390c51e9f60b331e7cc48 (diff)
downloadnextcloud-server-36ee37ec0af53b9b01612b2ce335e5aa9590d024.tar.gz
nextcloud-server-36ee37ec0af53b9b01612b2ce335e5aa9590d024.zip
Migrate OC_Group post_removeFromGroup hook to actual event object
Ref #14552 This adds a BeforeUserRemovedEvent to the LDAP backend because it was missing. It's not really before, but we don't have the before state. Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/user_ldap/lib')
-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);