diff options
Diffstat (limited to 'apps/user_ldap/ajax/clearMappings.php')
-rw-r--r-- | apps/user_ldap/ajax/clearMappings.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/apps/user_ldap/ajax/clearMappings.php b/apps/user_ldap/ajax/clearMappings.php index 4e713c59f96..e6f3d32e84f 100644 --- a/apps/user_ldap/ajax/clearMappings.php +++ b/apps/user_ldap/ajax/clearMappings.php @@ -21,15 +21,27 @@ * */ +use OCA\User_LDAP\Mapping\UserMapping; +use OCA\User_LDAP\Mapping\GroupMapping; + // Check user and app status OCP\JSON::checkAdminUser(); OCP\JSON::checkAppEnabled('user_ldap'); OCP\JSON::callCheck(); $subject = $_POST['ldap_clear_mapping']; -if(\OCA\user_ldap\lib\Helper::clearMapping($subject)) { +$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()) { + $l = \OC::$server->getL10N('user_ldap'); + throw new \Exception($l->t('Failed to clear the mappings.')); + } OCP\JSON::success(); -} else { - $l = \OC::$server->getL10N('user_ldap'); - OCP\JSON::error(array('message' => $l->t('Failed to clear the mappings.'))); +} catch (\Exception $e) { + OCP\JSON::error(array('message' => $e->getMessage())); } |