/* 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;
filter.mode + '« of type ' + typeof filter.mode);
}
filter.unlock();
+ filter.determineModeCallback(filter.mode);
},
function () {
//on error case get back to default i.e. Assisted
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) {
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");
+ }
+}
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() {
/** 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() {
},
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') {
$(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 {
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);
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);