aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-04-11 13:48:45 +0200
committerArthur Schiwon <blizzz@owncloud.com>2014-04-11 13:48:45 +0200
commit6f1e9f89201d26e679152be93090c8eb8482ff2a (patch)
tree55ac8a8dab09669936329e481c1f02ae0c9668fc /apps/user_ldap
parent36107e1bad9f696be9ac15141b120c7c30ee4e7f (diff)
parent8a8a32cf43efad6fdb2089097cb7fadbe0472456 (diff)
downloadnextcloud-server-6f1e9f89201d26e679152be93090c8eb8482ff2a.tar.gz
nextcloud-server-6f1e9f89201d26e679152be93090c8eb8482ff2a.zip
Merge branch 'ldap-filter-reset-fix' of github.com:ben-denham/core into fix-6651
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/js/ldapFilter.js95
-rw-r--r--apps/user_ldap/js/settings.js90
-rw-r--r--apps/user_ldap/settings.php1
3 files changed, 112 insertions, 74 deletions
diff --git a/apps/user_ldap/js/ldapFilter.js b/apps/user_ldap/js/ldapFilter.js
new file mode 100644
index 00000000000..70f24f0d4a5
--- /dev/null
+++ b/apps/user_ldap/js/ldapFilter.js
@@ -0,0 +1,95 @@
+function LdapFilter(target) {
+ this.locked = true;
+ this.target = false;
+ this.mode = LdapWizard.filterModeAssisted;
+ this.lazyRunCompose = false;
+
+ if( target === 'User' ||
+ target === 'Login' ||
+ target === 'Group') {
+ this.target = target;
+ this.determineMode();
+ }
+}
+
+LdapFilter.prototype.compose = function() {
+ var action;
+
+ if(this.locked) {
+ this.lazyRunCompose = true;
+ return false;
+ }
+
+ if(this.target === 'User') {
+ action = 'getUserListFilter';
+ } else if(this.target === 'Login') {
+ action = 'getUserLoginFilter';
+ } else if(this.target === 'Group') {
+ action = 'getGroupFilter';
+ }
+
+ if(!$('#raw'+this.target+'FilterContainer').hasClass('invisible')) {
+ //Raw filter editing, i.e. user defined filter, don't compose
+ return;
+ }
+
+ var param = 'action='+action+
+ '&ldap_serverconfig_chooser='+
+ encodeURIComponent($('#ldap_serverconfig_chooser').val());
+
+ var filter = this;
+
+ LdapWizard.ajax(param,
+ function(result) {
+ LdapWizard.applyChanges(result);
+ if(filter.target === 'User') {
+ LdapWizard.countUsers();
+ } else if(filter.target === 'Group') {
+ LdapWizard.countGroups();
+ LdapWizard.detectGroupMemberAssoc();
+ }
+ },
+ function (result) {
+ // error handling
+ }
+ );
+}
+
+LdapFilter.prototype.determineMode = function() {
+ var param = 'action=get'+encodeURIComponent(this.target)+'FilterMode'+
+ '&ldap_serverconfig_chooser='+
+ encodeURIComponent($('#ldap_serverconfig_chooser').val());
+
+ var filter = this;
+ LdapWizard.ajax(param,
+ function(result) {
+ property = 'ldap' + filter.target + 'FilterMode';
+ filter.mode = result.changes[property];
+ if(filter.mode === LdapWizard.filterModeRaw
+ && $('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
+ LdapWizard['toggleRaw'+filter.target+'Filter']();
+ } else if(filter.mode === LdapWizard.filterModeAssisted
+ && !$('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
+ LdapWizard['toggleRaw'+filter.target+'Filter']();
+ }
+ filter.unlock();
+ },
+ function (result) {
+ //on error case get back to default i.e. Assisted
+ if(!$('#raw'+filter.target+'FilterContainer').hasClass('invisible')) {
+ LdapWizard['toggleRaw'+filter.target+'Filter']();
+ filter.mode = LdapWizard.filterModeAssisted;
+ }
+ filter.unlock();
+ }
+ );
+
+}
+
+LdapFilter.prototype.unlock = function() {
+ this.locked = false;
+ if(this.lazyRunCompose) {
+ this.lazyRunCompose = false;
+ this.compose();
+ }
+}
diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js
index 792638f2b58..80e08572397 100644
--- a/apps/user_ldap/js/settings.js
+++ b/apps/user_ldap/js/settings.js
@@ -145,6 +145,9 @@ var LdapWizard = {
spinner: '<img class="wizSpinner" src="'+ OC.imagePath('core', 'loading.gif') +'">',
filterModeAssisted: 0,
filterModeRaw: 1,
+ userFilter: false,
+ loginFilter: false,
+ groupFilter: false,
ajax: function(param, fnOnSuccess, fnOnError) {
$.post(
@@ -276,41 +279,6 @@ var LdapWizard = {
}
},
- composeFilter: function(type) {
- subject = type.charAt(0).toUpperCase() + type.substr(1);
- if(!$('#raw'+subject+'FilterContainer').hasClass('invisible')) {
- //Raw filter editing, i.e. user defined filter, don't compose
- return;
- }
-
- if(type == 'user') {
- action = 'getUserListFilter';
- } else if(type == 'login') {
- action = 'getUserLoginFilter';
- } else if(type == 'group') {
- action = 'getGroupFilter';
- }
-
- param = 'action='+action+
- '&ldap_serverconfig_chooser='+
- encodeURIComponent($('#ldap_serverconfig_chooser').val());
-
- LdapWizard.ajax(param,
- function(result) {
- LdapWizard.applyChanges(result);
- if(type == 'user') {
- LdapWizard.countUsers();
- } else if(type == 'group') {
- LdapWizard.countGroups();
- LdapWizard.detectGroupMemberAssoc();
- }
- },
- function (result) {
- // error handling
- }
- );
- },
-
controlBack: function() {
curTabIndex = $('#ldapSettings').tabs('option', 'active');
if(curTabIndex == 0) {
@@ -560,7 +528,7 @@ var LdapWizard = {
},
initGroupFilter: function() {
- LdapWizard.regardFilterMode('Group');
+ LdapWizard.groupFilter = new LdapFilter('Group');
LdapWizard.findObjectClasses('ldap_groupfilter_objectclass', 'Group');
LdapWizard.findAvailableGroups('ldap_groupfilter_groups', 'Groups');
LdapWizard.countGroups();
@@ -569,13 +537,13 @@ var LdapWizard = {
/** init login filter tab section **/
initLoginFilter: function() {
- LdapWizard.regardFilterMode('Login');
+ LdapWizard.loginFilter = new LdapFilter('Login');
LdapWizard.findAttributes();
},
postInitLoginFilter: function() {
if($('#rawLoginFilterContainer').hasClass('invisible')) {
- LdapWizard.composeFilter('login');
+ LdapWizard.loginFilter.compose();
}
},
@@ -601,7 +569,7 @@ var LdapWizard = {
initUserFilter: function() {
LdapWizard.userFilterObjectClassesHasRun = false;
LdapWizard.userFilterAvailableGroupsHasRun = false;
- LdapWizard.regardFilterMode('User');
+ LdapWizard.userFilter = new LdapFilter('User');
LdapWizard.findObjectClasses('ldap_userfilter_objectclass', 'User');
LdapWizard.findAvailableGroups('ldap_userfilter_groups', 'Users');
},
@@ -609,7 +577,7 @@ var LdapWizard = {
postInitUserFilter: function() {
if(LdapWizard.userFilterObjectClassesHasRun
&& LdapWizard.userFilterAvailableGroupsHasRun) {
- LdapWizard.composeFilter('user');
+ LdapWizard.userFilter.compose();
LdapWizard.countUsers();
}
},
@@ -658,7 +626,7 @@ var LdapWizard = {
if(triggerObj.id == 'ldap_loginfilter_username'
|| triggerObj.id == 'ldap_loginfilter_email') {
- LdapWizard.composeFilter('login');
+ LdapWizard.loginFilter.compose();
}
if($('#ldapSettings').tabs('option', 'active') == 0) {
@@ -667,32 +635,6 @@ var LdapWizard = {
}
},
- regardFilterMode: function(subject) {
- param = 'action=get'+encodeURIComponent(subject)+'FilterMode'+
- '&ldap_serverconfig_chooser='+
- encodeURIComponent($('#ldap_serverconfig_chooser').val());
-
- LdapWizard.ajax(param,
- function(result) {
- property = 'ldap' + subject + 'FilterMode';
- mode = result.changes[property];
- if(mode == LdapWizard.filterModeRaw
- && $('#raw'+subject+'FilterContainer').hasClass('invisible')) {
- LdapWizard['toggleRaw'+subject+'Filter']();
- } else if(mode == LdapWizard.filterModeAssisted
- && !$('#raw'+subject+'FilterContainer').hasClass('invisible')) {
- LdapWizard['toggleRaw'+subject+'Filter']();
- }
- },
- function (result) {
- //on error case get back to default i.e. Assisted
- if(!$('#raw'+subject+'FilterContainer').hasClass('invisible')) {
- LdapWizard['toggleRaw'+subject+'Filter']();
- }
- }
- );
- },
-
save: function(inputObj) {
if(LdapWizard.blacklistRemove(inputObj.id)) {
return;
@@ -714,15 +656,15 @@ var LdapWizard = {
LdapWizard._save($('#'+originalObj)[0], $.trim(values));
if(originalObj == 'ldap_userfilter_objectclass'
|| originalObj == 'ldap_userfilter_groups') {
- LdapWizard.composeFilter('user');
+ LdapWizard.userFilter.compose();
//when user filter is changed afterwards, login filter needs to
//be adjusted, too
- LdapWizard.composeFilter('login');
+ LdapWizard.loginFilter.compose();
} else if(originalObj == 'ldap_loginfilter_attributes') {
- LdapWizard.composeFilter('login');
+ LdapWizard.loginFilter.compose();
} else if(originalObj == 'ldap_groupfilter_objectclass'
|| originalObj == 'ldap_groupfilter_groups') {
- LdapWizard.composeFilter('group');
+ LdapWizard.groupFilter.compose();
}
},
@@ -778,10 +720,10 @@ var LdapWizard = {
LdapWizard._save({ id: modeKey }, LdapWizard.filterModeAssisted);
if(moc.indexOf('user') >= 0) {
LdapWizard.blacklistRemove('ldap_userlist_filter');
- LdapWizard.composeFilter('user');
+ LdapWizard.userFilter.compose();
} else {
LdapWizard.blacklistRemove('ldap_group_filter');
- LdapWizard.composeFilter('group');
+ LdapWizard.groupFilter.compose();
}
}
},
@@ -815,7 +757,7 @@ var LdapWizard = {
$('#ldap_loginfilter_username').prop('disabled', property);
LdapWizard._save({ id: 'ldapLoginFilterMode' }, mode);
if(action == 'enable') {
- LdapWizard.composeFilter('login');
+ LdapWizard.loginFilter.compose();
}
},
diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php
index d077eafdde9..6b7d8e6f53e 100644
--- a/apps/user_ldap/settings.php
+++ b/apps/user_ldap/settings.php
@@ -25,6 +25,7 @@
OC_Util::checkAdminUser();
+OCP\Util::addScript('user_ldap', 'ldapFilter');
OCP\Util::addScript('user_ldap', 'settings');
OCP\Util::addScript('core', 'jquery.multiselect');
OCP\Util::addStyle('user_ldap', 'settings');