From ec0f80fee927ca572671ac7c733b960fb027e91f Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 5 Nov 2014 13:05:07 +0100 Subject: Split mapping from Access and Helper classes into it's own. Fully test them, too. remove unused methods split mapping methods off from Access class fix DB query handling move 'clear mapping' methods from static helper to new mapping class add tests test directly with DB finishing tests and fix return value from setDNbyUUID add corresponding class for groups and make abstract test class neutral. helper tests is now obsolete as the tested functions were moved to the new mapper class. add missing info to PHPDoc add unmap method fix namespaces fix test inheritance PHPDoc and a small code restructure for scrutinizer, no effective changes PostgreSQL does not accept LIMIT in DELETE queries phpdoc fixes, no code changes --- apps/user_ldap/ajax/clearMappings.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'apps/user_ldap/ajax/clearMappings.php') 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())); } -- cgit v1.2.3