diff options
author | ben-denham <bend@catalyst.net.nz> | 2014-03-07 10:10:42 +1300 |
---|---|---|
committer | ben-denham <bend@catalyst.net.nz> | 2014-03-07 10:10:42 +1300 |
commit | ef65381a0b41a1d6519e7d5bf39d3aac75127a1e (patch) | |
tree | 6ab7bbf4ac995e1ea65dee6f439eee599ebb753b | |
parent | 43e79f41f34b71499b9bac85d27b87b53a569da0 (diff) | |
download | nextcloud-server-ef65381a0b41a1d6519e7d5bf39d3aac75127a1e.tar.gz nextcloud-server-ef65381a0b41a1d6519e7d5bf39d3aac75127a1e.zip |
Moved LdapFilter into a separate js file in user_ldap.
-rw-r--r-- | apps/user_ldap/js/ldapFilter.js | 95 | ||||
-rw-r--r-- | apps/user_ldap/js/settings.js | 102 | ||||
-rw-r--r-- | apps/user_ldap/settings.php | 1 |
3 files changed, 96 insertions, 102 deletions
diff --git a/apps/user_ldap/js/ldapFilter.js b/apps/user_ldap/js/ldapFilter.js new file mode 100644 index 00000000000..71f8cd6c7c4 --- /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 0470ee079f9..57f61b7d680 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -138,108 +138,6 @@ var LdapConfiguration = { } }; - -// LdapFilter object. - -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(); - } -} - -// end of LdapFilter object. - - var LdapWizard = { checkPortInfoShown: false, saveBlacklist: {}, 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'); |