]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP: Show Host name in configuration drop down
authorArthur Schiwon <blizzz@owncloud.com>
Thu, 15 Aug 2013 13:55:06 +0000 (15:55 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Thu, 15 Aug 2013 13:55:06 +0000 (15:55 +0200)
apps/user_ldap/lib/helper.php
apps/user_ldap/settings.php
apps/user_ldap/templates/settings.php

index f65f466789f880099e0755875f38939c16e75ecf..4c9dd07a12cb8420769d139f7e064f97f054c70f 100644 (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
index 22e2dac6d26bca29705fcb3a3f8bfdf4fe2104de..7169192a18e4a94e4eb3d087e594577aed43a8e5 100644 (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)) {
index c051ea5cfe1f0a11bc8caf759504493513e544d7..e214d57fb1d91a91a637bb34c90c9d330d5c0917 100644 (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
                        }
                }