Merge pull request #15773 from owncloud/fix-15766
LDAP Wizard: increasing server numbers and avoid configID collisions, fixes #15766
This commit is contained in:
commit
5fa5f46a88
|
@ -35,14 +35,14 @@ $nk = 's'.str_pad($ln+1, 2, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
$resultData = array('configPrefix' => $nk);
|
$resultData = array('configPrefix' => $nk);
|
||||||
|
|
||||||
|
$newConfig = new \OCA\user_ldap\lib\Configuration($nk, false);
|
||||||
if(isset($_POST['copyConfig'])) {
|
if(isset($_POST['copyConfig'])) {
|
||||||
$originalConfig = new \OCA\user_ldap\lib\Configuration($_POST['copyConfig']);
|
$originalConfig = new \OCA\user_ldap\lib\Configuration($_POST['copyConfig']);
|
||||||
$newConfig = new \OCA\user_ldap\lib\Configuration($nk, false);
|
|
||||||
$newConfig->setConfiguration($originalConfig->getConfiguration());
|
$newConfig->setConfiguration($originalConfig->getConfiguration());
|
||||||
$newConfig->saveConfiguration();
|
|
||||||
} else {
|
} else {
|
||||||
$configuration = new \OCA\user_ldap\lib\Configuration($nk, false);
|
$configuration = new \OCA\user_ldap\lib\Configuration($nk, false);
|
||||||
$resultData['defaults'] = $configuration->getDefaults();
|
$resultData['defaults'] = $configuration->getDefaults();
|
||||||
}
|
}
|
||||||
|
$newConfig->saveConfiguration();
|
||||||
|
|
||||||
OCP\JSON::success($resultData);
|
OCP\JSON::success($resultData);
|
||||||
|
|
|
@ -14,6 +14,9 @@ OCA = OCA || {};
|
||||||
* in the LDAP wizard.
|
* in the LDAP wizard.
|
||||||
*/
|
*/
|
||||||
var WizardTabElementary = OCA.LDAP.Wizard.WizardTabGeneric.subClass({
|
var WizardTabElementary = OCA.LDAP.Wizard.WizardTabGeneric.subClass({
|
||||||
|
/** @property {number} */
|
||||||
|
_configChooserNextServerNumber: 1,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initializes the instance. Always call it after initialization.
|
* initializes the instance. Always call it after initialization.
|
||||||
*
|
*
|
||||||
|
@ -24,7 +27,7 @@ OCA = OCA || {};
|
||||||
tabIndex = 0;
|
tabIndex = 0;
|
||||||
this._super(tabIndex, tabID);
|
this._super(tabIndex, tabID);
|
||||||
this.isActive = true;
|
this.isActive = true;
|
||||||
this.configChooserID = '#ldap_serverconfig_chooser';
|
this.$configChooser = $('#ldap_serverconfig_chooser');
|
||||||
|
|
||||||
var items = {
|
var items = {
|
||||||
ldap_host: {
|
ldap_host: {
|
||||||
|
@ -88,7 +91,7 @@ OCA = OCA || {};
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
getConfigID: function() {
|
getConfigID: function() {
|
||||||
return $(this.configChooserID).val();
|
return this.$configChooser.val();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,9 +207,17 @@ OCA = OCA || {};
|
||||||
*/
|
*/
|
||||||
onNewConfiguration: function(view, result) {
|
onNewConfiguration: function(view, result) {
|
||||||
if(result.isSuccess === true) {
|
if(result.isSuccess === true) {
|
||||||
$(view.configChooserID + ' option:selected').removeAttr('selected');
|
console.log('new config');
|
||||||
var html = '<option value="'+result.configPrefix+'" selected="selected">'+t('user_ldap','{nthServer}. Server', {nthServer: $(view.configChooserID + ' option').length + 1})+'</option>';
|
var nthServer = view._configChooserNextServerNumber;
|
||||||
$(view.configChooserID + ' option:last').after(html);
|
view.$configChooser.find('option:selected').removeAttr('selected');
|
||||||
|
var html = '<option value="'+result.configPrefix+'" selected="selected">'+t('user_ldap','{nthServer}. Server', {nthServer: nthServer})+'</option>';
|
||||||
|
if(view.$configChooser.find('option:last').length > 0) {
|
||||||
|
view.$configChooser.find('option:last').after(html);
|
||||||
|
} else {
|
||||||
|
view.$configChooser.html(html);
|
||||||
|
}
|
||||||
|
|
||||||
|
view._configChooserNextServerNumber++;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -222,16 +233,16 @@ OCA = OCA || {};
|
||||||
if(view.getConfigID() === result.configPrefix) {
|
if(view.getConfigID() === result.configPrefix) {
|
||||||
// if the deleted value is still the selected one (99% of
|
// if the deleted value is still the selected one (99% of
|
||||||
// the cases), remove it from the list and load the topmost
|
// the cases), remove it from the list and load the topmost
|
||||||
$(view.configChooserID + ' option:selected').remove();
|
view.$configChooser.find('option:selected').remove();
|
||||||
$(view.configChooserID + ' option:first').select();
|
view.$configChooser.find('option:first').select();
|
||||||
if($(view.configChooserID + ' option').length < 2) {
|
if(view.$configChooser.find(' option').length < 1) {
|
||||||
view.configModel.newConfig(false);
|
view.configModel.newConfig(false);
|
||||||
} else {
|
} else {
|
||||||
view.configModel.load(view.getConfigID());
|
view.configModel.load(view.getConfigID());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// otherwise just remove the entry
|
// otherwise just remove the entry
|
||||||
$(view.configChooserID + ' option[value=' + result.configPrefix + ']').remove();
|
view.$configChooser.find('option[value=' + result.configPrefix + ']').remove();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
OC.Notification.showTemporary(result.errorMessage);
|
OC.Notification.showTemporary(result.errorMessage);
|
||||||
|
@ -303,9 +314,10 @@ OCA = OCA || {};
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_enableConfigChooser: function() {
|
_enableConfigChooser: function() {
|
||||||
|
this._configChooserNextServerNumber = this.$configChooser.find(' option').length + 1;
|
||||||
var view = this;
|
var view = this;
|
||||||
$(this.configChooserID).change(function(){
|
this.$configChooser.change(function(){
|
||||||
var value = $(view.configChooserID + ' option:selected:first').attr('value');
|
var value = view.$configChooser.find(' option:selected:first').attr('value');
|
||||||
view.configModel.load(value);
|
view.configModel.load(value);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue