Merge pull request #5532 from owncloud/ldap_fixes

Ldap fixes
This commit is contained in:
Thomas Müller 2013-10-24 23:24:39 -07:00
commit 5fd1f552a3
3 changed files with 46 additions and 13 deletions

View file

@ -272,13 +272,8 @@ var LdapWizard = {
if(curTabIndex == 0) {
return;
}
if(curTabIndex == 1) {
$('.ldap_action_back').addClass('invisible');
}
$('#ldapSettings').tabs('option', 'active', curTabIndex - 1);
if(curTabIndex == 3) {
$('.ldap_action_continue').removeClass('invisible');
}
LdapWizard.controlUpdate(curTabIndex - 1);
},
controlContinue: function() {
@ -287,12 +282,26 @@ var LdapWizard = {
return;
}
$('#ldapSettings').tabs('option', 'active', 1 + curTabIndex);
if(curTabIndex == 2) {
//now last tab
$('.ldap_action_continue').addClass('invisible');
}
if(curTabIndex == 0) {
LdapWizard.controlUpdate(curTabIndex + 1);
},
controlUpdate: function(nextTabIndex) {
if(nextTabIndex == 0) {
$('.ldap_action_back').addClass('invisible');
$('.ldap_action_continue').removeClass('invisible');
} else
if(nextTabIndex == 1) {
$('.ldap_action_back').removeClass('invisible');
$('.ldap_action_continue').removeClass('invisible');
} else
if(nextTabIndex == 2) {
$('.ldap_action_continue').removeClass('invisible');
$('.ldap_action_back').removeClass('invisible');
} else
if(nextTabIndex == 3) {
//now last tab
$('.ldap_action_back').removeClass('invisible');
$('.ldap_action_continue').addClass('invisible');
}
},
@ -493,12 +502,21 @@ var LdapWizard = {
},
onTabChange: function(event, ui) {
newTabIndex = 0;
if(ui.newTab[0].id === '#ldapWizard2') {
LdapWizard.initUserFilter();
newTabIndex = 1;
} else if(ui.newTab[0].id === '#ldapWizard3') {
LdapWizard.initLoginFilter();
newTabIndex = 2;
} else if(ui.newTab[0].id === '#ldapWizard4') {
LdapWizard.initGroupFilter();
newTabIndex = 3;
}
curTabIndex = $('#ldapSettings').tabs('option', 'active');
if(curTabIndex >= 0 && curTabIndex <= 3) {
LdapWizard.controlUpdate(newTabIndex);
}
},

View file

@ -241,7 +241,7 @@ class Configuration {
protected function setMultiLine($varname, $value) {
if(empty($value)) {
$value = '';
} else {
} else if (!is_array($value)) {
$value = preg_split('/\r\n|\r|\n/', $value);
if($value === false) {
$value = '';
@ -374,7 +374,7 @@ class Configuration {
'ldap_attributes_for_user_search' => 'ldapAttributesForUserSearch',
'ldap_attributes_for_group_search' => 'ldapAttributesForGroupSearch',
'ldap_expert_username_attr' => 'ldapExpertUsernameAttr',
'ldap_expert_uuid_user_attr' => 'ldapExpertUUIUserDAttr',
'ldap_expert_uuid_user_attr' => 'ldapExpertUUIDUserAttr',
'ldap_expert_uuid_group_attr' => 'ldapExpertUUIDGroupAttr',
'has_memberof_filter_support' => 'hasMemberOfFilterSupport',
);

View file

@ -39,6 +39,8 @@ class Connection extends LDAPUtility {
//settings handler
protected $configuration;
protected $doNotValidate = false;
/**
* @brief Constructor
* @param $configPrefix a string with the prefix for the configkey column (appconfig table)
@ -57,6 +59,8 @@ class Connection extends LDAPUtility {
}
$this->hasPagedResultSupport =
$this->ldap->hasPagedResultSupport();
$this->doNotValidate = !in_array($this->configPrefix,
Helper::getServerConfigurationPrefixes());
}
public function __destruct() {
@ -88,6 +92,7 @@ class Connection extends LDAPUtility {
}
public function __set($name, $value) {
$this->doNotValidate = false;
$before = $this->configuration->$name;
$this->configuration->$name = $value;
$after = $this->configuration->$name;
@ -201,11 +206,13 @@ class Connection extends LDAPUtility {
if(is_null($setParameters)) {
$setParameters = array();
}
$this->doNotValidate = false;
$this->configuration->setConfiguration($config, $setParameters);
if(count($setParameters) > 0) {
$this->configured = $this->validateConfiguration();
}
return $this->configured;
}
@ -401,6 +408,14 @@ class Connection extends LDAPUtility {
* @returns true if configuration seems OK, false otherwise
*/
private function validateConfiguration() {
if($this->doNotValidate) {
//don't do a validation if it is a new configuration with pure
//default values. Will be allowed on changes via __set or
//setConfiguration
return false;
}
// first step: "soft" checks: settings that are not really
// necessary, but advisable. If left empty, give an info message
$this->doSoftValidation();