diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2013-08-15 15:55:06 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2013-08-15 15:55:06 +0200 |
commit | 479f893f6ddef6a102b8f4ff3f68fc0b64838710 (patch) | |
tree | e43275170f0293f100dff28261011465fc9fe6a9 /apps | |
parent | cbfee81068d47d246deac9902f12bf63258a03e0 (diff) | |
download | nextcloud-server-479f893f6ddef6a102b8f4ff3f68fc0b64838710.tar.gz nextcloud-server-479f893f6ddef6a102b8f4ff3f68fc0b64838710.zip |
LDAP: Show Host name in configuration drop down
Diffstat (limited to 'apps')
-rw-r--r-- | apps/user_ldap/lib/helper.php | 28 | ||||
-rw-r--r-- | apps/user_ldap/settings.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/templates/settings.php | 2 |
3 files changed, 31 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php index f65f466789f..4c9dd07a12c 100644 --- a/apps/user_ldap/lib/helper.php +++ b/apps/user_ldap/lib/helper.php @@ -71,6 +71,34 @@ class Helper { } /** + * + * @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 * @return bool true on success, false otherwise diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index 22e2dac6d26..7169192a18e 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -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)) { diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index c051ea5cfe1..e214d57fb1d 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -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 } } |