Merge pull request #10820 from nextcloud/fix/noid/emptydefaultprefix

[LDAP] The WebUI Wizard also should not assign empty config IDs
This commit is contained in:
Morris Jobke 2018-08-24 21:37:00 +02:00 committed by GitHub
commit c850b3ac20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 15 deletions

View File

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

View File

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

View File

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