summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-06-25 19:38:54 +0200
committerArthur Schiwon <blizzz@owncloud.com>2014-08-29 11:14:36 +0200
commit371cab367d2b786c0fadb3a76daeb3ba9138e164 (patch)
tree6079217db38894d2581d84a8e3c49ff918e041a4 /apps/user_ldap
parent6958033db9f6bd2ff7e69b05a6cb064206957a65 (diff)
downloadnextcloud-server-371cab367d2b786c0fadb3a76daeb3ba9138e164.tar.gz
nextcloud-server-371cab367d2b786c0fadb3a76daeb3ba9138e164.zip
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
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/ajax/wizard.php1
-rw-r--r--apps/user_ldap/js/ldapFilter.js5
-rw-r--r--apps/user_ldap/js/settings.js18
-rw-r--r--apps/user_ldap/lib/wizard.php5
-rw-r--r--apps/user_ldap/tests/wizard.php14
5 files changed, 30 insertions, 13 deletions
diff --git a/apps/user_ldap/ajax/wizard.php b/apps/user_ldap/ajax/wizard.php
index d5759c597a2..adbcf6ff414 100644
--- a/apps/user_ldap/ajax/wizard.php
+++ b/apps/user_ldap/ajax/wizard.php
@@ -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':
diff --git a/apps/user_ldap/js/ldapFilter.js b/apps/user_ldap/js/ldapFilter.js
index df3bd67aec2..e9f60e7ba3c 100644
--- a/apps/user_ldap/js/ldapFilter.js
+++ b/apps/user_ldap/js/ldapFilter.js
@@ -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. '+
diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js
index 87d755697cb..fd84ca1980b 100644
--- a/apps/user_ldap/js/settings.js
+++ b/apps/user_ldap/js/settings.js
@@ -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();
diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php
index 8e6e47b1f6b..4118b45bc35 100644
--- a/apps/user_ldap/lib/wizard.php
+++ b/apps/user_ldap/lib/wizard.php
@@ -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:
diff --git a/apps/user_ldap/tests/wizard.php b/apps/user_ldap/tests/wizard.php
index d6de83bbdd6..867fba11f27 100644
--- a/apps/user_ldap/tests/wizard.php
+++ b/apps/user_ldap/tests/wizard.php
@@ -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() {