[LDAP] The WebUI Wizard also should not assign empty config IDs

With 689df9a843 the behaviour to assign only
non-empty config IDs was introduced. Only, this was only effective for CLI
and OCS API.

Related to #3270.

The web UI creates now also a full configuration on first load. This fixes
#5094.

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2018-08-23 13:37:15 +02:00
parent 389b981aa5
commit 7c3339521c
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
3 changed files with 18 additions and 15 deletions

View File

@ -49,6 +49,14 @@ class Admin implements ISettings {
public function getForm() {
$helper = new Helper(\OC::$server->getConfig());
$prefixes = $helper->getServerConfigurationPrefixes();
if(count($prefixes) === 0) {
$newPrefix = $helper->getNextServerConfigurationPrefix();
$config = new Configuration($newPrefix, false);
$config->setConfiguration($config->getDefaults());
$config->saveConfiguration();
$prefixes[] = $newPrefix;
}
$hosts = $helper->getServerConfigurationHosts();
$wControls = new Template('user_ldap', 'part.wizardcontrols');
@ -62,7 +70,9 @@ class Admin implements ISettings {
$parameters['wizardControls'] = $wControls;
// assign default values
if(!isset($config)) {
$config = new Configuration('', false);
}
$defaults = $config->getDefaults();
foreach($defaults as $key => $default) {
$parameters[$key.'_default'] = $default;

View File

@ -1,11 +1,7 @@
<fieldset id="ldapWizard1">
<p>
<select id="ldap_serverconfig_chooser" name="ldap_serverconfig_chooser">
<?php if(count($_['serverConfigurationPrefixes']) === 0 ) {
?>
<option value="" selected><?php p($l->t('1. Server'));?></option>');
<?php
} else {
$i = 1;
$sel = ' selected';
foreach($_['serverConfigurationPrefixes'] as $prefix) {
@ -13,7 +9,6 @@
<option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($l->t('%s. Server:', array($i++)));?> <?php p(' '.$_['serverConfigurationHosts'][$prefix]); ?></option>
<?php
}
}
?>
</select>
<button type="button" id="ldap_action_add_configuration"

View File

@ -56,10 +56,8 @@ class AdminTest extends TestCase {
* @UseDB
*/
public function testGetForm() {
$helper = new Helper(\OC::$server->getConfig());
$prefixes = $helper->getServerConfigurationPrefixes();
$hosts = $helper->getServerConfigurationHosts();
$prefixes = ['s01'];
$hosts = ['s01' => ''];
$wControls = new Template('user_ldap', 'part.wizardcontrols');
$wControls = $wControls->fetchPage();