summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-01-24 12:42:28 +0100
committerArthur Schiwon <blizzz@owncloud.com>2013-01-24 12:42:28 +0100
commit96949fc9dd5c50818a8f8bda75a9beb731ac91ae (patch)
tree3817b6eed781cf33e1f865377a3de6a44c2b5bf4
parentb979bf6f1cc2c3b9cf6d7a004edb5cbf9299e08b (diff)
downloadnextcloud-server-96949fc9dd5c50818a8f8bda75a9beb731ac91ae.tar.gz
nextcloud-server-96949fc9dd5c50818a8f8bda75a9beb731ac91ae.zip
LDAP: consolidate config prefix determination, autofill combo box in settings
-rw-r--r--apps/user_ldap/appinfo/app.php20
-rw-r--r--apps/user_ldap/settings.php11
-rw-r--r--apps/user_ldap/templates/settings.php1
3 files changed, 15 insertions, 17 deletions
diff --git a/apps/user_ldap/appinfo/app.php b/apps/user_ldap/appinfo/app.php
index 69860ba1432..79cfab58796 100644
--- a/apps/user_ldap/appinfo/app.php
+++ b/apps/user_ldap/appinfo/app.php
@@ -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
diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php
index f3f0826739f..57d370601cf 100644
--- a/apps/user_ldap/settings.php
+++ b/apps/user_ldap/settings.php
@@ -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)) {
diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php
index 6b95f8660eb..20297c02d39 100644
--- a/apps/user_ldap/templates/settings.php
+++ b/apps/user_ldap/templates/settings.php
@@ -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>