Skip to content

Commit 7807add

Browse files
committed
[LDAP] The WebUI Wizard also should not assign empty config IDs
With 689df9a 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>
1 parent c0f48a7 commit 7807add

3 files changed

Lines changed: 18 additions & 15 deletions

File tree

apps/user_ldap/lib/Settings/Admin.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ public function __construct(IL10N $l) {
4949
public function getForm() {
5050
$helper = new Helper(\OC::$server->getConfig());
5151
$prefixes = $helper->getServerConfigurationPrefixes();
52+
if(count($prefixes) === 0) {
53+
$newPrefix = $helper->getNextServerConfigurationPrefix();
54+
$config = new Configuration($newPrefix, false);
55+
$config->setConfiguration($config->getDefaults());
56+
$config->saveConfiguration();
57+
$prefixes[] = $newPrefix;
58+
}
59+
5260
$hosts = $helper->getServerConfigurationHosts();
5361

5462
$wControls = new Template('user_ldap', 'part.wizardcontrols');
@@ -62,7 +70,9 @@ public function getForm() {
6270
$parameters['wizardControls'] = $wControls;
6371

6472
// assign default values
65-
$config = new Configuration('', false);
73+
if(!isset($config)) {
74+
$config = new Configuration('', false);
75+
}
6676
$defaults = $config->getDefaults();
6777
foreach($defaults as $key => $default) {
6878
$parameters[$key.'_default'] = $default;

apps/user_ldap/templates/part.wizard-server.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
<fieldset id="ldapWizard1">
22
<p>
33
<select id="ldap_serverconfig_chooser" name="ldap_serverconfig_chooser">
4-
<?php if(count($_['serverConfigurationPrefixes']) === 0 ) {
4+
<?php
5+
$i = 1;
6+
$sel = ' selected';
7+
foreach($_['serverConfigurationPrefixes'] as $prefix) {
58
?>
6-
<option value="" selected><?php p($l->t('1. Server'));?></option>');
9+
<option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($l->t('%s. Server:', array($i++)));?> <?php p(' '.$_['serverConfigurationHosts'][$prefix]); ?></option>
710
<?php
8-
} else {
9-
$i = 1;
10-
$sel = ' selected';
11-
foreach($_['serverConfigurationPrefixes'] as $prefix) {
12-
?>
13-
<option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($l->t('%s. Server:', array($i++)));?> <?php p(' '.$_['serverConfigurationHosts'][$prefix]); ?></option>
14-
<?php
15-
}
1611
}
1712
?>
1813
</select>

apps/user_ldap/tests/Settings/AdminTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ public function setUp() {
5656
* @UseDB
5757
*/
5858
public function testGetForm() {
59-
60-
$helper = new Helper(\OC::$server->getConfig());
61-
$prefixes = $helper->getServerConfigurationPrefixes();
62-
$hosts = $helper->getServerConfigurationHosts();
59+
$prefixes = ['s01'];
60+
$hosts = ['s01' => ''];
6361

6462
$wControls = new Template('user_ldap', 'part.wizardcontrols');
6563
$wControls = $wControls->fetchPage();

0 commit comments

Comments
 (0)