LDAP: Show Host name in configuration drop down

This commit is contained in:
Arthur Schiwon 2013-08-15 15:55:06 +02:00
parent cbfee81068
commit 479f893f6d
3 changed files with 31 additions and 1 deletions

View File

@ -70,6 +70,34 @@ class Helper {
return $prefixes;
}
/**
*
* @brief determines the host for every configured connection
* @return an array with configprefix as keys
*
*/
static public function getServerConfigurationHosts() {
$referenceConfigkey = 'ldap_host';
$query = '
SELECT DISTINCT `configkey`, `configvalue`
FROM `*PREFIX*appconfig`
WHERE `appid` = \'user_ldap\'
AND `configkey` LIKE ?
';
$query = \OCP\DB::prepare($query);
$configHosts = $query->execute(array('%'.$referenceConfigkey))->fetchAll();
$result = array();
foreach($configHosts as $configHost) {
$len = strlen($configHost['configkey']) - strlen($referenceConfigkey);
$prefix = substr($configHost['configkey'], 0, $len);
$result[$prefix] = $configHost['configvalue'];
}
return $result;
}
/**
* @brief deletes a given saved LDAP/AD server configuration.
* @param string the configuration prefix of the config to delete

View File

@ -44,7 +44,9 @@ OCP\Util::addstyle('user_ldap', 'settings');
$tmpl = new OCP\Template('user_ldap', 'settings');
$prefixes = \OCA\user_ldap\lib\Helper::getServerConfigurationPrefixes();
$hosts = \OCA\user_ldap\lib\Helper::getServerConfigurationHosts();
$tmpl->assign('serverConfigurationPrefixes', $prefixes);
$tmpl->assign('serverConfigurationHosts', $hosts);
// assign default values
if(!isset($ldap)) {

View File

@ -24,7 +24,7 @@
$sel = ' selected';
foreach($_['serverConfigurationPrefixes'] as $prefix) {
?>
<option value="<?php p($prefix); ?>"<?php p($sel); ?>><?php p($i++); ?>. Server</option>
<option value="<?php p($prefix); ?>"<?php p($sel); $sel = ''; ?>><?php p($i++); ?>. Server: <?php p($_['serverConfigurationHosts'][$prefix]); ?></option>
<?php
}
}