LDAP: Show Host name in configuration drop down
This commit is contained in:
parent
cbfee81068
commit
479f893f6d
|
@ -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
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue