diff options
Diffstat (limited to 'apps/user_ldap/lib/helper.php')
-rw-r--r-- | apps/user_ldap/lib/helper.php | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php index 612a088269b..10ed40ebd6a 100644 --- a/apps/user_ldap/lib/helper.php +++ b/apps/user_ldap/lib/helper.php @@ -96,7 +96,38 @@ class Helper { return false; } - if($res->numRows() == 0) { + if($res->numRows() === 0) { + return false; + } + + return true; + } + + /** + * Truncate's the given mapping table + * + * @param string $mapping either 'user' or 'group' + * @return boolean true on success, false otherwise + */ + static public function clearMapping($mapping) { + if($mapping === 'user') { + $table = '`*PREFIX*ldap_user_mapping`'; + } else if ($mapping === 'group') { + $table = '`*PREFIX*ldap_group_mapping`'; + } else { + return false; + } + + if(strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false) { + $query = \OCP\DB::prepare('DELETE FROM '.$table); + } else { + $query = \OCP\DB::prepare('TRUNCATE '.$table); + } + + + $res = $query->execute(); + + if(\OCP\DB::isError($res)) { return false; } |