Skip to content

Commit

Permalink
[LDAP] The WebUI Wizard also should not assign empty config IDs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
blizzz committed Aug 23, 2018
1 parent 389b981 commit 7c33395
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
12 changes: 11 additions & 1 deletion apps/user_ldap/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public function __construct(IL10N $l) {
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');
Expand All @@ -62,7 +70,9 @@ public function getForm() {
$parameters['wizardControls'] = $wControls;

// assign default values
$config = new Configuration('', false);
if(!isset($config)) {
$config = new Configuration('', false);
}
$defaults = $config->getDefaults();
foreach($defaults as $key => $default) {
$parameters[$key.'_default'] = $default;
Expand Down
15 changes: 5 additions & 10 deletions apps/user_ldap/templates/part.wizard-server.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<fieldset id="ldapWizard1">
<p>
<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
} 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>
Expand Down
6 changes: 2 additions & 4 deletions apps/user_ldap/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ public function setUp() {
* @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();
Expand Down

0 comments on commit 7c33395

Please sign in to comment.