summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/ajax
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2018-03-15 14:16:43 +0100
committerArthur Schiwon <blizzz@arthur-schiwon.de>2018-04-05 12:38:39 +0200
commit8fe914f07e1b4d41c02e127e2242e0a770535455 (patch)
treeb101bce725bf2b9a385077008fe4b9999285acb0 /apps/user_ldap/ajax
parentfeef3cbba03c4517b25a60820e8c4534b0a02b67 (diff)
downloadnextcloud-server-8fe914f07e1b4d41c02e127e2242e0a770535455.tar.gz
nextcloud-server-8fe914f07e1b4d41c02e127e2242e0a770535455.zip
LDAP backend to emit announce and revoke signals on mapping changes
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/ajax')
-rw-r--r--apps/user_ldap/ajax/clearMappings.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/apps/user_ldap/ajax/clearMappings.php b/apps/user_ldap/ajax/clearMappings.php
index 01b6b7f0ef2..009a491d349 100644
--- a/apps/user_ldap/ajax/clearMappings.php
+++ b/apps/user_ldap/ajax/clearMappings.php
@@ -33,13 +33,23 @@ use OCA\User_LDAP\Mapping\GroupMapping;
$subject = (string)$_POST['ldap_clear_mapping'];
$mapping = null;
-if($subject === 'user') {
- $mapping = new UserMapping(\OC::$server->getDatabaseConnection());
-} else if($subject === 'group') {
- $mapping = new GroupMapping(\OC::$server->getDatabaseConnection());
-}
try {
- if(is_null($mapping) || !$mapping->clear()) {
+ if($subject === 'user') {
+ $mapping = new UserMapping(\OC::$server->getDatabaseConnection());
+ $result = $mapping->clearCb(
+ function ($uid) {
+ \OC::$server->getUserManager()->emit('\OC\User', 'preRevokeUser', [$uid]);
+ },
+ function ($uid) {
+ \OC::$server->getUserManager()->emit('\OC\User', 'postRevokeUser', [$uid]);
+ }
+ );
+ } else if($subject === 'group') {
+ $mapping = new GroupMapping(\OC::$server->getDatabaseConnection());
+ $result = $mapping->clear();
+ }
+
+ if($mapping === null || !$result) {
$l = \OC::$server->getL10N('user_ldap');
throw new \Exception($l->t('Failed to clear the mappings.'));
}