diff options
author | blizzz <blizzz@owncloud.com> | 2014-12-19 18:52:30 +0100 |
---|---|---|
committer | blizzz <blizzz@owncloud.com> | 2014-12-19 18:52:30 +0100 |
commit | ad6814f9207ac50ad9e3e6f157ec9746c81392e9 (patch) | |
tree | 8d896fbde817ce51106eaa525c9d68b6dead3416 /apps/user_ldap/ajax/clearMappings.php | |
parent | f671b232cc122cdb8e993c8b35bd5419b32a9ae4 (diff) | |
parent | ec0f80fee927ca572671ac7c733b960fb027e91f (diff) | |
download | nextcloud-server-ad6814f9207ac50ad9e3e6f157ec9746c81392e9.tar.gz nextcloud-server-ad6814f9207ac50ad9e3e6f157ec9746c81392e9.zip |
Merge pull request #12101 from owncloud/ldap_split_mapping
Ldap split mapping from Access superclass
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())); } |