From 5252fc52edf604eb4ad1256387a3e9512d799d0e Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 1 Nov 2012 16:48:17 +0100 Subject: [PATCH 1/2] LDAP: clear the cache not only when TTL changes, but with every settings update. Fixes #194 --- apps/user_ldap/settings.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index f765151456..ca9855df6c 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -26,16 +26,12 @@ OCP\Util::addscript('user_ldap', 'settings'); OCP\Util::addstyle('user_ldap', 'settings'); if ($_POST) { + $clearCache = false; foreach($params as $param) { if(isset($_POST[$param])) { + $clearCache = true; if('ldap_agent_password' == $param) { OCP\Config::setAppValue('user_ldap', $param, base64_encode($_POST[$param])); - } elseif('ldap_cache_ttl' == $param) { - if(OCP\Config::getAppValue('user_ldap', $param,'') != $_POST[$param]) { - $ldap = new \OCA\user_ldap\lib\Connection('user_ldap'); - $ldap->clearCache(); - OCP\Config::setAppValue('user_ldap', $param, $_POST[$param]); - } } elseif('home_folder_naming_rule' == $param) { $value = empty($_POST[$param]) ? 'opt:username' : 'attr:'.$_POST[$param]; OCP\Config::setAppValue('user_ldap', $param, $value); @@ -54,6 +50,10 @@ if ($_POST) { OCP\Config::setAppValue('user_ldap', $param, 0); } } + if($clearCache){ + $ldap = new \OCA\user_ldap\lib\Connection('user_ldap'); + $ldap->clearCache(); + } } // fill template From df8c67721df1358eab7aa5794ef223a5bc8f0b59 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 2 Nov 2012 09:42:10 +0100 Subject: [PATCH 2/2] code style --- apps/user_ldap/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index ca9855df6c..f9ad2db94a 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -50,7 +50,7 @@ if ($_POST) { OCP\Config::setAppValue('user_ldap', $param, 0); } } - if($clearCache){ + if($clearCache) { $ldap = new \OCA\user_ldap\lib\Connection('user_ldap'); $ldap->clearCache(); }