aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-08-24 21:37:00 +0200
committerGitHub <noreply@github.com>2018-08-24 21:37:00 +0200
commitc850b3ac20793d5ce4fcbf9b6ba5188333910f32 (patch)
tree4d60182782f60912a3014735e66ad80fb386dac2 /apps/user_ldap
parentede9e38be7706555e2be52e416e07241fe243247 (diff)
parent7807add02d3a7b2a91de5c22ad9a6e75c34c470f (diff)
downloadnextcloud-server-c850b3ac20793d5ce4fcbf9b6ba5188333910f32.tar.gz
nextcloud-server-c850b3ac20793d5ce4fcbf9b6ba5188333910f32.zip
Merge pull request #10820 from nextcloud/fix/noid/emptydefaultprefix
[LDAP] The WebUI Wizard also should not assign empty config IDs
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/Settings/Admin.php12
-rw-r--r--apps/user_ldap/templates/part.wizard-server.php15
-rw-r--r--apps/user_ldap/tests/Settings/AdminTest.php6
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 33a86ad72d2..bf5bbef2f90 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 9803fb3cd3c..5b607f7be86 100644
--- a/apps/user_ldap/templates/part.wizard-server.php
+++ b/apps/user_ldap/templates/part.wizard-server.php
@@ -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>
diff --git a/apps/user_ldap/tests/Settings/AdminTest.php b/apps/user_ldap/tests/Settings/AdminTest.php
index 8161896e719..84004b9d465 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();