From bae954a7972c84cfd71ced68173bde0e3b36a2eb Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 18 May 2012 17:38:22 +0200 Subject: LDAP: only check once for name conflicts on update. Set a value on install as well --- apps/user_ldap/appinfo/update.php | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'apps/user_ldap/appinfo/update.php') diff --git a/apps/user_ldap/appinfo/update.php b/apps/user_ldap/appinfo/update.php index 048d804217b..b3f7a397db9 100644 --- a/apps/user_ldap/appinfo/update.php +++ b/apps/user_ldap/appinfo/update.php @@ -12,22 +12,25 @@ if(!is_null($pw)) { //detect if we can switch on naming guidelines. We won't do it on conflicts. //it's a bit spaghetti, but hey. -$sqlCleanMap = 'DELETE FROM *PREFIX*ldap_user_mapping'; +$state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'doCheck'); +if($state == 'doCheck'){ + $sqlCleanMap = 'DELETE FROM *PREFIX*ldap_user_mapping'; -require_once(OC::$APPSROOT.'/apps/user_ldap/lib_ldap.php'); -require_once(OC::$APPSROOT.'/apps/user_ldap/user_ldap.php'); + require_once(OC::$APPSROOT.'/apps/user_ldap/lib_ldap.php'); + require_once(OC::$APPSROOT.'/apps/user_ldap/user_ldap.php'); -OCP\Config::setSystemValue('ldapIgnoreNamingRules', true); -$LDAP_USER = new OC_USER_LDAP(); -$users_old = $LDAP_USER->getUsers(); -$query = OCP\DB::prepare($sqlCleanMap); -$query->execute(); -OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); -OC_LDAP::init(true); -$users_new = $LDAP_USER->getUsers(); -$query = OCP\DB::prepare($sqlCleanMap); -$query->execute(); -if($users_old !== $users_new) { - //we don't need to check Groups, because they were not supported in 3' OCP\Config::setSystemValue('ldapIgnoreNamingRules', true); + $LDAP_USER = new OC_USER_LDAP(); + $users_old = $LDAP_USER->getUsers(); + $query = OCP\DB::prepare($sqlCleanMap); + $query->execute(); + OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); + OC_LDAP::init(true); + $users_new = $LDAP_USER->getUsers(); + $query = OCP\DB::prepare($sqlCleanMap); + $query->execute(); + if($users_old !== $users_new) { + //we don't need to check Groups, because they were not supported in 3' + OCP\Config::setSystemValue('ldapIgnoreNamingRules', true); + } } \ No newline at end of file -- cgit v1.2.3