]> source.dussan.org Git - nextcloud-server.git/commitdiff
Objectlasses, Groups and Attributes are now loaded only in assisted mode and only...
authorArthur Schiwon <blizzz@owncloud.com>
Wed, 8 Oct 2014 09:38:39 +0000 (11:38 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Wed, 8 Oct 2014 09:38:39 +0000 (11:38 +0200)
apps/user_ldap/js/experiencedAdmin.js
apps/user_ldap/js/ldapFilter.js
apps/user_ldap/js/settings.js

index 2d500f301b02a1129c94eec9db4835b6c283cd60..96b4bcad6c971a77239cad84afdbe334d47a6c1f 100644 (file)
@@ -43,12 +43,11 @@ ExperiencedAdmin.prototype.isExperienced = function() {
  */
 ExperiencedAdmin.prototype.enableRawMode = function    () {
        containers = {
-               'toggleRawUserFilter' : '#rawGroupFilterContainer',
+               'toggleRawGroupFilter': '#rawGroupFilterContainer',
                'toggleRawLoginFilter': '#rawLoginFilterContainer',
                'toggleRawUserFilter' : '#rawUserFilterContainer'
        };
 
-//     containers.forEach(function(container, method) {
        for(method in containers) {
                if($(containers[method]).hasClass('invisible')) {
                        this.wizard[method]();
index e9f60e7ba3c9497352f8e7f7542d5e413bbb39ed..cd03ff9b5bf8822bf2d6a0976f7f6519de852d13 100644 (file)
@@ -1,19 +1,30 @@
 /* global LdapWizard */
 
-function LdapFilter(target)  {
+function LdapFilter(target, determineModeCallback)  {
        this.locked = true;
        this.target = false;
        this.mode = LdapWizard.filterModeAssisted;
        this.lazyRunCompose = false;
+       this.determineModeCallback = determineModeCallback;
+       this.foundFeatures = false;
+       this.activated = false;
 
        if( target === 'User' ||
                target === 'Login' ||
                target === 'Group') {
                this.target = target;
-               this.determineMode();
        }
 }
 
+LdapFilter.prototype.activate = function() {
+       if(this.activated) {
+               return;
+       }
+       this.activated = true;
+
+       this.determineMode();
+}
+
 LdapFilter.prototype.compose = function(callback) {
        var action;
 
@@ -82,6 +93,7 @@ LdapFilter.prototype.determineMode = function() {
                                        filter.mode + '« of type ' + typeof filter.mode);
                        }
                        filter.unlock();
+                       filter.determineModeCallback(filter.mode);
                },
                function () {
                        //on error case get back to default i.e. Assisted
@@ -90,10 +102,17 @@ LdapFilter.prototype.determineMode = function() {
                                filter.mode = LdapWizard.filterModeAssisted;
                        }
                        filter.unlock();
+                       filter.determineModeCallback(filter.mode);
                }
        );
 };
 
+LdapFilter.prototype.setMode = function(mode) {
+       if(mode === LdapWizard.filterModeAssisted || mode === LdapWizard.filterModeRaw) {
+               this.mode = mode;
+       }
+}
+
 LdapFilter.prototype.unlock = function() {
        this.locked = false;
        if(this.lazyRunCompose) {
@@ -101,3 +120,23 @@ LdapFilter.prototype.unlock = function() {
                this.compose();
        }
 };
+
+LdapFilter.prototype.findFeatures = function() {
+       if(!this.foundFeatures && !this.locked && this.mode === LdapWizard.filterModeAssisted) {
+               this.foundFeatures = true;
+               if(this.target === 'User') {
+                       objcEl = 'ldap_userfilter_objectclass';
+                       avgrEl = 'ldap_userfilter_groups';
+               } else if (this.target === 'Group') {
+                       objcEl = 'ldap_groupfilter_objectclass';
+                       avgrEl = 'ldap_groupfilter_groups';
+               } else if (this.target === 'Login') {
+                       LdapWizard.findAttributes();
+                       return;
+               } else {
+                       return false;
+               }
+               LdapWizard.findObjectClasses(objcEl, this.target);
+               LdapWizard.findAvailableGroups(avgrEl, this.target + "s");
+       }
+}
index 5982d65ad6c2d0f85607244fc98bc9a009c1146c..cf7223d3fa028b67efaefa33f716c6bc144af6ed 100644 (file)
@@ -530,23 +530,21 @@ var LdapWizard = {
        isConfigurationActiveControlLocked: true,
 
        init: function() {
+               LdapWizard.instantiateFilters();
                LdapWizard.basicStatusCheck();
                LdapWizard.functionalityCheck();
                LdapWizard.isConfigurationActiveControlLocked = false;
        },
 
        initGroupFilter: function() {
-               LdapWizard.groupFilter = new LdapFilter('Group');
-               LdapWizard.findObjectClasses('ldap_groupfilter_objectclass', 'Group');
-               LdapWizard.findAvailableGroups('ldap_groupfilter_groups', 'Groups');
+               LdapWizard.groupFilter.activate();
                LdapWizard.countGroups();
        },
 
        /** init login filter tab section **/
 
        initLoginFilter: function() {
-               LdapWizard.loginFilter = new LdapFilter('Login');
-               LdapWizard.findAttributes();
+               LdapWizard.loginFilter.activate();
        },
 
        postInitLoginFilter: function() {
@@ -571,15 +569,30 @@ var LdapWizard = {
 
        /** init user filter tab section **/
 
+       instantiateFilters: function() {
+               delete LdapWizard.userFilter;
+               LdapWizard.userFilter = new LdapFilter('User', function(mode) {
+                       LdapWizard.userFilter.findFeatures();
+               });
+
+               delete LdapWizard.loginFilter;
+               LdapWizard.loginFilter = new LdapFilter('Login', function(mode) {
+                       LdapWizard.loginFilter.findFeatures();
+               });
+
+               delete LdapWizard.groupFilter;
+               LdapWizard.groupFilter = new LdapFilter('Group', function(mode) {
+                       LdapWizard.groupFilter.findFeatures();
+               });
+       },
+
        userFilterObjectClassesHasRun: false,
        userFilterAvailableGroupsHasRun: false,
 
        initUserFilter: function() {
                LdapWizard.userFilterObjectClassesHasRun = false;
                LdapWizard.userFilterAvailableGroupsHasRun = false;
-               LdapWizard.userFilter = new LdapFilter('User');
-               LdapWizard.findObjectClasses('ldap_userfilter_objectclass', 'User');
-               LdapWizard.findAvailableGroups('ldap_userfilter_groups', 'Users');
+               LdapWizard.userFilter.activate();
        },
 
        postInitUserFilter: function() {
@@ -713,9 +726,12 @@ var LdapWizard = {
        },
 
        toggleRawFilter: function(container, moc, mg, stateVar, modeKey) {
+               var isUser = moc.indexOf('user') >= 0;
+               var filter = isUser ? LdapWizard.userFilter : LdapWizard.groupFilter;
                //moc = multiselect objectclass
                //mg = mutliselect groups
                if($(container).hasClass('invisible')) {
+                       filter.setMode(LdapWizard.filterModeRaw);
                        $(container).removeClass('invisible');
                        $(moc).multiselect('disable');
                        if($(mg).multiselect().attr('disabled') == 'disabled') {
@@ -726,11 +742,13 @@ var LdapWizard = {
                        $(mg).multiselect('disable');
                        LdapWizard._save({ id: modeKey }, LdapWizard.filterModeRaw);
                } else {
+                       filter.setMode(LdapWizard.filterModeAssisted);
+                       filter.findFeatures();
                        $(container).addClass('invisible');
                        $(mg).multiselect(LdapWizard[stateVar]);
                        $(moc).multiselect('enable');
                        LdapWizard._save({ id: modeKey }, LdapWizard.filterModeAssisted);
-                       if(moc.indexOf('user') >= 0) {
+                       if(isUser) {
                                LdapWizard.blacklistRemove('ldap_userlist_filter');
                                LdapWizard.userFilter.compose(LdapWizard.detectEmailAttribute);
                        } else {
@@ -764,6 +782,8 @@ var LdapWizard = {
                        property = false;
                        mode = LdapWizard.filterModeAssisted;
                }
+               LdapWizard.loginFilter.setMode(mode);
+               LdapWizard.loginFilter.findFeatures();
                $('#ldap_loginfilter_attributes').multiselect(action);
                $('#ldap_loginfilter_email').prop('disabled', property);
                $('#ldap_loginfilter_username').prop('disabled', property);
@@ -837,6 +857,7 @@ $(document).ready(function() {
        LdapWizard.initMultiSelect($('#ldap_groupfilter_objectclass'),
                                                           'ldap_groupfilter_objectclass',
                                                           t('user_ldap', 'Select object classes'));
+
        $('.lwautosave').change(function() { LdapWizard.save(this); });
        $('#toggleRawUserFilter').click(LdapWizard.toggleRawUserFilter);
        $('#toggleRawGroupFilter').click(LdapWizard.toggleRawGroupFilter);