Skip to content
Snippets Groups Projects
Commit 96949fc9 authored by Arthur Schiwon's avatar Arthur Schiwon
Browse files

LDAP: consolidate config prefix determination, autofill combo box in settings

parent b979bf6f
No related branches found
No related tags found
No related merge requests found
......@@ -23,26 +23,16 @@
OCP\App::registerAdmin('user_ldap', 'settings');
$query = \OCP\DB::prepare('
SELECT DISTINCT `configkey`
FROM `*PREFIX*appconfig`
WHERE `configkey` LIKE ?
');
$serverConnections = $query->execute(array('%ldap_login_filter'))->fetchAll();
if(count($serverConnections) == 1) {
$prefix = substr($serverConnections[0]['configkey'], 0, strlen($serverConnections[0]['configkey'])- strlen('ldap_login_filter'));
$connector = new OCA\user_ldap\lib\Connection($prefix);
$configPrefixes = OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes();
if(count($configPrefixes) == 1) {
$connector = new OCA\user_ldap\lib\Connection($configPrefixes[0]);
$userBackend = new OCA\user_ldap\USER_LDAP();
$userBackend->setConnector($connector);
$groupBackend = new OCA\user_ldap\GROUP_LDAP();
$groupBackend->setConnector($connector);
} else {
$prefixes = array();
foreach($serverConnections as $serverConnection) {
$prefixes[] = substr($serverConnection['configkey'], 0, strlen($serverConnection['configkey'])- strlen('ldap_login_filter'));
}
$userBackend = new OCA\user_ldap\User_Proxy($prefixes);
$groupBackend = new OCA\user_ldap\Group_Proxy($prefixes);
$userBackend = new OCA\user_ldap\User_Proxy($configPrefixes);
$groupBackend = new OCA\user_ldap\Group_Proxy($configPrefixes);
}
// register user backend
......
......@@ -86,7 +86,16 @@ $tmpl->assign('ldap_cache_ttl', OCP\Config::getAppValue('user_ldap', 'ldap_cache
$hfnr = OCP\Config::getAppValue('user_ldap', 'home_folder_naming_rule', 'opt:username');
$hfnr = ($hfnr == 'opt:username') ? '' : substr($hfnr, strlen('attr:'));
$tmpl->assign('home_folder_naming_rule', $hfnr, '');
$tmpl->assign('serverConfigurationOptions', '', false);
$prefixes = \OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes();
$scoHtml = '';
$i = 1;
$sel = ' selected';
foreach($prefixes as $prefix) {
$scoHtml .= '<option value="'.$prefix.'"'.$sel.'>'.$i++.'. Server</option>';
$sel = '';
}
$tmpl->assign('serverConfigurationOptions', $scoHtml, false);
// assign default values
if(!isset($ldap)) {
......
......@@ -13,7 +13,6 @@
?>
<fieldset id="ldapSettings-1">
<p><label for="ldap_serverconfig_chooser"><?php echo $l->t('Server configuration');?></label><select id="ldap_serverconfig_chooser" name="ldap_serverconfig_chooser">
<option value="" selected><?php echo $l->t('Default (1. Server)');?></option>
<?php echo $_['serverConfigurationOptions']; ?>
<option value="NEW"><?php echo $l->t('Add Server Configuration');?></option>
</select></p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment