Merge pull request #200 from owncloud/ldap

LDAP: clear the cache not only when TTL changes, but with every settings...
This commit is contained in:
Lukas Reschke 2012-11-04 11:03:18 -08:00
commit 555dd5c261
1 changed files with 6 additions and 6 deletions

View File

@ -26,16 +26,12 @@ OCP\Util::addscript('user_ldap', 'settings');
OCP\Util::addstyle('user_ldap', 'settings'); OCP\Util::addstyle('user_ldap', 'settings');
if ($_POST) { if ($_POST) {
$clearCache = false;
foreach($params as $param) { foreach($params as $param) {
if(isset($_POST[$param])) { if(isset($_POST[$param])) {
$clearCache = true;
if('ldap_agent_password' == $param) { if('ldap_agent_password' == $param) {
OCP\Config::setAppValue('user_ldap', $param, base64_encode($_POST[$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) { } elseif('home_folder_naming_rule' == $param) {
$value = empty($_POST[$param]) ? 'opt:username' : 'attr:'.$_POST[$param]; $value = empty($_POST[$param]) ? 'opt:username' : 'attr:'.$_POST[$param];
OCP\Config::setAppValue('user_ldap', $param, $value); OCP\Config::setAppValue('user_ldap', $param, $value);
@ -54,6 +50,10 @@ if ($_POST) {
OCP\Config::setAppValue('user_ldap', $param, 0); OCP\Config::setAppValue('user_ldap', $param, 0);
} }
} }
if($clearCache) {
$ldap = new \OCA\user_ldap\lib\Connection('user_ldap');
$ldap->clearCache();
}
} }
// fill template // fill template