From 7807add02d3a7b2a91de5c22ad9a6e75c34c470f Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 23 Aug 2018 13:37:15 +0200 Subject: [PATCH] [LDAP] The WebUI Wizard also should not assign empty config IDs With 689df9a843dd0505088143de039af775a3f92612 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 --- apps/user_ldap/lib/Settings/Admin.php | 12 +++++++++++- apps/user_ldap/templates/part.wizard-server.php | 15 +++++---------- apps/user_ldap/tests/Settings/AdminTest.php | 6 ++---- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/apps/user_ldap/lib/Settings/Admin.php b/apps/user_ldap/lib/Settings/Admin.php index 33a86ad72d..bf5bbef2f9 100644 --- a/apps/user_ldap/lib/Settings/Admin.php +++ b/apps/user_ldap/lib/Settings/Admin.php @@ -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 - $config = new Configuration('', false); + if(!isset($config)) { + $config = new Configuration('', false); + } $defaults = $config->getDefaults(); foreach($defaults as $key => $default) { $parameters[$key.'_default'] = $default; diff --git a/apps/user_ldap/templates/part.wizard-server.php b/apps/user_ldap/templates/part.wizard-server.php index 9803fb3cd3..5b607f7be8 100644 --- a/apps/user_ldap/templates/part.wizard-server.php +++ b/apps/user_ldap/templates/part.wizard-server.php @@ -1,18 +1,13 @@

diff --git a/apps/user_ldap/tests/Settings/AdminTest.php b/apps/user_ldap/tests/Settings/AdminTest.php index 8161896e71..84004b9d46 100644 --- a/apps/user_ldap/tests/Settings/AdminTest.php +++ b/apps/user_ldap/tests/Settings/AdminTest.php @@ -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();