summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-01-19 12:22:24 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-01-19 12:22:24 +0100
commitd75af7ddd29179a6f22b1ee46efd3c8df9dd09a9 (patch)
treee01af4a5f3404d3a8e93e863d98a53560bc10fc7
parentfa9834372d7e635ce4a69c415423fe2c76b7b5b2 (diff)
parent56ba07aa5cc52cd8a937aa6fb514a82b82385568 (diff)
downloadnextcloud-server-d75af7ddd29179a6f22b1ee46efd3c8df9dd09a9.tar.gz
nextcloud-server-d75af7ddd29179a6f22b1ee46efd3c8df9dd09a9.zip
Merge pull request #13362 from owncloud/fix-11442
LDAP Wizared: update user or group count only, when the multiselect is closed
-rw-r--r--apps/user_ldap/js/experiencedAdmin.js2
-rw-r--r--apps/user_ldap/js/ldapFilter.js32
-rw-r--r--apps/user_ldap/js/settings.js96
3 files changed, 92 insertions, 38 deletions
diff --git a/apps/user_ldap/js/experiencedAdmin.js b/apps/user_ldap/js/experiencedAdmin.js
index 8d138eecc41..7dc5a4e503d 100644
--- a/apps/user_ldap/js/experiencedAdmin.js
+++ b/apps/user_ldap/js/experiencedAdmin.js
@@ -25,7 +25,7 @@ function ExperiencedAdmin(wizard, initialState) {
/**
* toggles whether the admin is an experienced one or not
*
- * @param {boolean} whether the admin is experienced or not
+ * @param {boolean} isExperienced whether the admin is experienced or not
*/
ExperiencedAdmin.prototype.setExperienced = function(isExperienced) {
this._isExperienced = isExperienced;
diff --git a/apps/user_ldap/js/ldapFilter.js b/apps/user_ldap/js/ldapFilter.js
index 0f7d240adac..dc65858217d 100644
--- a/apps/user_ldap/js/ldapFilter.js
+++ b/apps/user_ldap/js/ldapFilter.js
@@ -19,6 +19,8 @@ function LdapFilter(target, determineModeCallback) {
LdapFilter.prototype.activate = function() {
if(this.activated) {
+ // might be necessary, if configuration changes happened.
+ this.findFeatures();
return;
}
this.activated = true;
@@ -70,14 +72,6 @@ LdapFilter.prototype.compose = function(updateCount) {
};
/**
- * this function is triggered after attribute detectors have completed in
- * LdapWizard
- */
-LdapFilter.prototype.afterDetectorsRan = function() {
- this.updateCount();
-};
-
-/**
* this function is triggered after LDAP filters have been composed successfully
* @param {object} result returned by the ajax call
*/
@@ -99,11 +93,15 @@ LdapFilter.prototype.determineMode = function() {
function(result) {
var property = 'ldap' + filter.target + 'FilterMode';
filter.mode = parseInt(result.changes[property], 10);
- if(filter.mode === LdapWizard.filterModeRaw &&
- $('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
+ var rawContainerIsInvisible =
+ $('#raw'+filter.target+'FilterContainer').hasClass('invisible');
+ if ( filter.mode === LdapWizard.filterModeRaw
+ && rawContainerIsInvisible
+ ) {
LdapWizard['toggleRaw'+filter.target+'Filter']();
- } else if(filter.mode === LdapWizard.filterModeAssisted &&
- !$('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
+ } else if ( filter.mode === LdapWizard.filterModeAssisted
+ && !rawContainerIsInvisible
+ ) {
LdapWizard['toggleRaw'+filter.target+'Filter']();
} else {
console.log('LDAP Wizard determineMode: returned mode was »' +
@@ -142,8 +140,15 @@ LdapFilter.prototype.unlock = function() {
}
};
+/**
+ * resets this.foundFeatures so that LDAP queries can be fired again to retrieve
+ * objectClasses, groups, etc.
+ */
+LdapFilter.prototype.reAllowFeatureLookup = function () {
+ this.foundFeatures = false;
+};
+
LdapFilter.prototype.findFeatures = function() {
- //TODO: reset this.foundFeatures when any base DN changes
if(!this.foundFeatures && !this.locked && this.mode === LdapWizard.filterModeAssisted) {
this.foundFeatures = true;
var objcEl, avgrEl;
@@ -167,7 +172,6 @@ LdapFilter.prototype.findFeatures = function() {
/**
* this function is triggered before user and group counts are executed
* resolving the passed status variable will fire up counting
- * @param {object} status an instance of $.Deferred
*/
LdapFilter.prototype.beforeUpdateCount = function() {
var status = $.Deferred();
diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js
index 6db210fe435..b1abb0994ba 100644
--- a/apps/user_ldap/js/settings.js
+++ b/apps/user_ldap/js/settings.js
@@ -149,6 +149,7 @@ var LdapWizard = {
loginFilter: false,
groupFilter: false,
ajaxRequests: {},
+ lastTestSuccessful: true,
ajax: function(param, fnOnSuccess, fnOnError, reqID) {
if(!_.isUndefined(reqID)) {
@@ -207,7 +208,7 @@ var LdapWizard = {
},
basicStatusCheck: function() {
- //criterias to continue from the first tab
+ //criteria to continue from the first tab
// - host, port, user filter, agent dn, password, base dn
var host = $('#ldap_host').val();
var port = $('#ldap_port').val();
@@ -224,7 +225,7 @@ var LdapWizard = {
blacklistAdd: function(id) {
- obj = $('#'+id);
+ var obj = $('#' + id);
if(!(obj[0].hasOwnProperty('multiple') && obj[0]['multiple'] === true)) {
//no need to blacklist multiselect
LdapWizard.saveBlacklist[id] = true;
@@ -242,14 +243,14 @@ var LdapWizard = {
},
checkBaseDN: function() {
- host = $('#ldap_host').val();
- port = $('#ldap_port').val();
- user = $('#ldap_dn').val();
- pass = $('#ldap_agent_password').val();
+ var host = $('#ldap_host').val();
+ var port = $('#ldap_port').val();
+ var user = $('#ldap_dn').val();
+ var pass = $('#ldap_agent_password').val();
//FIXME: determine base dn with anonymous access
if(host && port && user && pass) {
- param = 'action=guessBaseDN'+
+ var param = 'action=guessBaseDN'+
'&ldap_serverconfig_chooser='+
encodeURIComponent($('#ldap_serverconfig_chooser').val());
@@ -276,11 +277,11 @@ var LdapWizard = {
},
checkPort: function() {
- host = $('#ldap_host').val();
- port = $('#ldap_port').val();
+ var host = $('#ldap_host').val();
+ var port = $('#ldap_port').val();
if(host && !port) {
- param = 'action=guessPortAndTLS'+
+ var param = 'action=guessPortAndTLS'+
'&ldap_serverconfig_chooser='+
encodeURIComponent($('#ldap_serverconfig_chooser').val());
@@ -307,7 +308,7 @@ var LdapWizard = {
},
controlBack: function() {
- curTabIndex = $('#ldapSettings').tabs('option', 'active');
+ var curTabIndex = $('#ldapSettings').tabs('option', 'active');
if(curTabIndex == 0) {
return;
}
@@ -316,7 +317,7 @@ var LdapWizard = {
},
controlContinue: function() {
- curTabIndex = $('#ldapSettings').tabs('option', 'active');
+ var curTabIndex = $('#ldapSettings').tabs('option', 'active');
if(curTabIndex == 3) {
return;
}
@@ -529,7 +530,7 @@ var LdapWizard = {
if(type !== 'User' && type !== 'Group') {
return false;
}
- param = 'action=determine'+encodeURIComponent(type)+'ObjectClasses'+
+ var param = 'action=determine'+encodeURIComponent(type)+'ObjectClasses'+
'&ldap_serverconfig_chooser='+
encodeURIComponent($('#ldap_serverconfig_chooser').val());
@@ -571,11 +572,11 @@ var LdapWizard = {
functionalityCheck: function() {
//criteria to enable the connection:
// - host, port, basedn, user filter, login filter
- host = $('#ldap_host').val();
- port = $('#ldap_port').val();
- base = $('#ldap_base').val();
- userfilter = $('#ldap_userlist_filter').val();
- loginfilter = $('#ldap_login_filter').val();
+ var host = $('#ldap_host').val();
+ var port = $('#ldap_port').val();
+ var base = $('#ldap_base').val();
+ var userfilter = $('#ldap_userlist_filter').val();
+ var loginfilter = $('#ldap_login_filter').val();
//FIXME: activates a manually deactivated configuration.
if(host && port && base && userfilter && loginfilter) {
@@ -619,6 +620,7 @@ var LdapWizard = {
LdapWizard.detectorsRunInXPMode = 0;
LdapWizard.instantiateFilters();
LdapWizard.admin.setExperienced($('#ldap_experienced_admin').is(':checked'));
+ LdapWizard.lastTestSuccessful = true;
LdapWizard.basicStatusCheck();
LdapWizard.functionalityCheck();
LdapWizard.isConfigurationActiveControlLocked = false;
@@ -760,7 +762,19 @@ var LdapWizard = {
}
},
- processChanges: function(triggerObj) {
+ /**
+ * allows UserFilter, LoginFilter and GroupFilter to lookup objectClasses
+ * and similar again. This should be called after essential changes, e.g.
+ * Host or BaseDN changes, or positive functionality check
+ *
+ */
+ allowFilterFeatureSearch: function () {
+ LdapWizard.userFilter.reAllowFeatureLookup();
+ LdapWizard.loginFilter.reAllowFeatureLookup();
+ LdapWizard.groupFilter.reAllowFeatureLookup();
+ },
+
+ processChanges: function (triggerObj) {
LdapWizard.hideInfoBox();
if(triggerObj.id === 'ldap_host'
@@ -771,6 +785,7 @@ var LdapWizard = {
if($('#ldap_port').val()) {
//if Port is already set, check BaseDN
LdapWizard.checkBaseDN();
+ LdapWizard.allowFilterFeatureSearch();
}
}
@@ -804,15 +819,33 @@ var LdapWizard = {
LdapWizard._save(inputObj, val);
},
+ /**
+ * updates user or group count on multiSelect close. Resets the event
+ * function subsequently.
+ *
+ * @param {LdapFilter} filter
+ * @param {Object} $multiSelectObj
+ */
+ onMultiSelectClose: function(filter, $multiSelectObj) {
+ filter.updateCount();
+ $multiSelectObj.multiselect({close: function(){}});
+ },
+
saveMultiSelect: function(originalObj, resultObj) {
- values = '';
- for(i = 0; i < resultObj.length; i++) {
+ var values = '';
+ for(var i = 0; i < resultObj.length; i++) {
values = values + "\n" + resultObj[i].value;
}
LdapWizard._save($('#'+originalObj)[0], $.trim(values));
+ var $multiSelectObj = $('#'+originalObj);
+ var updateCount = !$multiSelectObj.multiselect("isOpen");
+ var applyUpdateOnCloseToFilter;
if(originalObj === 'ldap_userfilter_objectclass'
|| originalObj === 'ldap_userfilter_groups') {
- LdapWizard.userFilter.compose(true);
+ LdapWizard.userFilter.compose(updateCount);
+ if(!updateCount) {
+ applyUpdateOnCloseToFilter = LdapWizard.userFilter;
+ }
//when user filter is changed afterwards, login filter needs to
//be adjusted, too
if(!LdapWizard.loginFilter) {
@@ -823,7 +856,19 @@ var LdapWizard = {
LdapWizard.loginFilter.compose();
} else if(originalObj === 'ldap_groupfilter_objectclass'
|| originalObj === 'ldap_groupfilter_groups') {
- LdapWizard.groupFilter.compose(true);
+ LdapWizard.groupFilter.compose(updateCount);
+ if(!updateCount) {
+ applyUpdateOnCloseToFilter = LdapWizard.groupFilter;
+ }
+ }
+
+ if(applyUpdateOnCloseToFilter instanceof LdapFilter) {
+ $multiSelectObj.multiselect({
+ close: function () {
+ LdapWizard.onMultiSelectClose(
+ applyUpdateOnCloseToFilter, $multiSelectObj);
+ }
+ });
}
},
@@ -1002,6 +1047,10 @@ var LdapWizard = {
$('.ldap_config_state_indicator').addClass('ldap_grey');
$('.ldap_config_state_indicator_sign').removeClass('error');
$('.ldap_config_state_indicator_sign').addClass('success');
+ if(!LdapWizard.lastTestSuccessful) {
+ LdapWizard.lastTestSuccessful = true;
+ LdapWizard.allowFilterFeatureSearch();
+ }
},
//onError
function(result) {
@@ -1011,6 +1060,7 @@ var LdapWizard = {
$('.ldap_config_state_indicator').removeClass('ldap_grey');
$('.ldap_config_state_indicator_sign').addClass('error');
$('.ldap_config_state_indicator_sign').removeClass('success');
+ LdapWizard.lastTestSuccessful = false;
}
);
} else {