Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use empty in the future ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it wouldn't be a big array in this case, still you're right.

$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