trigger email detection by Wizard upon any user filter filter change. before it happenend only upon user automatic list filter creation, but not on manual editing
This commit is contained in:
parent
6958033db9
commit
371cab367d
5 changed files with 30 additions and 13 deletions
|
@ -61,6 +61,7 @@ $wizard = new \OCA\user_ldap\lib\Wizard($configuration, $ldapWrapper, $access);
|
|||
switch($action) {
|
||||
case 'guessPortAndTLS':
|
||||
case 'guessBaseDN':
|
||||
case 'detectEmailAttribute':
|
||||
case 'determineGroupMemberAssoc':
|
||||
case 'determineUserObjectClasses':
|
||||
case 'determineGroupObjectClasses':
|
||||
|
|
|
@ -14,7 +14,7 @@ function LdapFilter(target) {
|
|||
}
|
||||
}
|
||||
|
||||
LdapFilter.prototype.compose = function() {
|
||||
LdapFilter.prototype.compose = function(callback) {
|
||||
var action;
|
||||
|
||||
if(this.locked) {
|
||||
|
@ -50,6 +50,9 @@ LdapFilter.prototype.compose = function() {
|
|||
LdapWizard.countGroups();
|
||||
LdapWizard.detectGroupMemberAssoc();
|
||||
}
|
||||
if(typeof callback !== 'undefined') {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
function () {
|
||||
console.log('LDAP Wizard: could not compose filter. '+
|
||||
|
|
|
@ -340,6 +340,14 @@ var LdapWizard = {
|
|||
LdapWizard._countThings('countUsers');
|
||||
},
|
||||
|
||||
detectEmailAttribute: function() {
|
||||
param = 'action=detectEmailAttribute'+
|
||||
'&ldap_serverconfig_chooser='+
|
||||
encodeURIComponent($('#ldap_serverconfig_chooser').val());
|
||||
//runs in the background, no callbacks necessary
|
||||
LdapWizard.ajax(param, LdapWizard.applyChanges, function(){});
|
||||
},
|
||||
|
||||
detectGroupMemberAssoc: function() {
|
||||
param = 'action=determineGroupMemberAssoc'+
|
||||
'&ldap_serverconfig_chooser='+
|
||||
|
@ -577,7 +585,7 @@ var LdapWizard = {
|
|||
postInitUserFilter: function() {
|
||||
if(LdapWizard.userFilterObjectClassesHasRun &&
|
||||
LdapWizard.userFilterAvailableGroupsHasRun) {
|
||||
LdapWizard.userFilter.compose();
|
||||
LdapWizard.userFilter.compose(LdapWizard.detectEmailAttribute);
|
||||
LdapWizard.countUsers();
|
||||
}
|
||||
},
|
||||
|
@ -619,6 +627,7 @@ var LdapWizard = {
|
|||
|
||||
if(triggerObj.id == 'ldap_userlist_filter') {
|
||||
LdapWizard.countUsers();
|
||||
LdapWizard.detectEmailAttribute();
|
||||
} else if(triggerObj.id == 'ldap_group_filter') {
|
||||
LdapWizard.countGroups();
|
||||
LdapWizard.detectGroupMemberAssoc();
|
||||
|
@ -656,9 +665,12 @@ var LdapWizard = {
|
|||
LdapWizard._save($('#'+originalObj)[0], $.trim(values));
|
||||
if(originalObj == 'ldap_userfilter_objectclass'
|
||||
|| originalObj == 'ldap_userfilter_groups') {
|
||||
LdapWizard.userFilter.compose();
|
||||
LdapWizard.userFilter.compose(LdapWizard.detectEmailAttribute);
|
||||
//when user filter is changed afterwards, login filter needs to
|
||||
//be adjusted, too
|
||||
if(!LdapWizard.loginFilter) {
|
||||
LdapWizard.initLoginFilter();
|
||||
}
|
||||
LdapWizard.loginFilter.compose();
|
||||
} else if(originalObj == 'ldap_loginfilter_attributes') {
|
||||
LdapWizard.loginFilter.compose();
|
||||
|
@ -720,7 +732,7 @@ var LdapWizard = {
|
|||
LdapWizard._save({ id: modeKey }, LdapWizard.filterModeAssisted);
|
||||
if(moc.indexOf('user') >= 0) {
|
||||
LdapWizard.blacklistRemove('ldap_userlist_filter');
|
||||
LdapWizard.userFilter.compose();
|
||||
LdapWizard.userFilter.compose(LdapWizard.detectEmailAttribute);
|
||||
} else {
|
||||
LdapWizard.blacklistRemove('ldap_group_filter');
|
||||
LdapWizard.groupFilter.compose();
|
||||
|
|
|
@ -155,7 +155,7 @@ class Wizard extends LDAPUtility {
|
|||
* detects the most often used email attribute for users applying to the
|
||||
* user list filter. If a setting is already present that returns at least
|
||||
* one hit, the detection will be canceled.
|
||||
* @return bool|string
|
||||
* @return WizardResult|bool
|
||||
*/
|
||||
public function detectEmailAttribute() {
|
||||
if(!$this->checkRequirements(array('ldapHost',
|
||||
|
@ -197,7 +197,7 @@ class Wizard extends LDAPUtility {
|
|||
}
|
||||
}
|
||||
|
||||
return $winner;
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -820,7 +820,6 @@ class Wizard extends LDAPUtility {
|
|||
if(empty($filter)) {
|
||||
$filter = '(objectclass=*)';
|
||||
}
|
||||
$this->detectEmailAttribute();
|
||||
break;
|
||||
|
||||
case self::LFILTER_GROUP_LIST:
|
||||
|
|
|
@ -274,8 +274,9 @@ class Test_Wizard extends \PHPUnit_Framework_TestCase {
|
|||
var_dump($filter);
|
||||
}));
|
||||
|
||||
$resultAttribute = $wizard->detectEmailAttribute();
|
||||
$this->assertSame('mailPrimaryAddress', $resultAttribute);
|
||||
$result = $wizard->detectEmailAttribute()->getResultArray();
|
||||
$this->assertSame('mailPrimaryAddress',
|
||||
$result['changes']['ldap_email_attr']);
|
||||
}
|
||||
|
||||
public function testDetectEmailAttributeFind() {
|
||||
|
@ -312,8 +313,9 @@ class Test_Wizard extends \PHPUnit_Framework_TestCase {
|
|||
var_dump($filter);
|
||||
}));
|
||||
|
||||
$resultAttribute = $wizard->detectEmailAttribute();
|
||||
$this->assertSame('mailPrimaryAddress', $resultAttribute);
|
||||
$result = $wizard->detectEmailAttribute()->getResultArray();
|
||||
$this->assertSame('mailPrimaryAddress',
|
||||
$result['changes']['ldap_email_attr']);
|
||||
}
|
||||
|
||||
public function testDetectEmailAttributeFindNothing() {
|
||||
|
@ -350,8 +352,8 @@ class Test_Wizard extends \PHPUnit_Framework_TestCase {
|
|||
var_dump($filter);
|
||||
}));
|
||||
|
||||
$resultAttribute = $wizard->detectEmailAttribute();
|
||||
$this->assertSame('', $resultAttribute);
|
||||
$result = $wizard->detectEmailAttribute();
|
||||
$this->assertSame(false, $result->hasChanges());
|
||||
}
|
||||
|
||||
public function testCumulativeSearchOnAttributeSkipReadDN() {
|
||||
|
|
Loading…
Reference in a new issue