Fix a bug with grouping servers feature
authorioguix <ioguix@free.fr>
Sun, 18 Jul 2010 11:45:36 +0000 (13:45 +0200)
committerioguix <ioguix@free.fr>
Sun, 18 Jul 2010 11:45:36 +0000 (13:45 +0200)
  * opened connexions were appearing in every group
  * after connexion/disconnection, stay in the group instead
    of falling back in the 'all' group

classes/Misc.php
servers.php

index ffe00ff60a0e359be57107a3a6d3270238250103..1d459fa2f17a2c9d6724c31d5ca4cd6b3ca9173e 100644 (file)
                 */
                function getServers($recordset = false, $group = false) {
                        global $conf;
-                       
-                       $srvs = isset($_SESSION['webdbLogin']) && is_array($_SESSION['webdbLogin']) ? $_SESSION['webdbLogin'] : array();
-                       
-                       if ($group !== false) {
-                               if ($group !== 'all')
-                                       $group = array_fill_keys(explode(',', $conf['srv_groups'][$group]['servers']), 1);
-                       } 
+
+                       $logins = isset($_SESSION['webdbLogin']) && is_array($_SESSION['webdbLogin']) ? $_SESSION['webdbLogin'] : array();
+                       $srvs = array();
+
+                       if (($group !== false) and ($group !== 'all'))
+                               $group = array_fill_keys(explode(',', $conf['srv_groups'][$group]['servers']), 1);
                        
                        foreach($conf['servers'] as $idx => $info) {
+                               $server_id = $info['host'].':'.$info['port'].':'.$info['sslmode'];
                                if (($group === false) 
                                        or (isset($group[$idx]))
                                        or ($group === 'all')
                                ) {
                                        $server_id = $info['host'].':'.$info['port'].':'.$info['sslmode'];
+                                       
+                                       if (isset($logins[$server_id])) $srvs[$server_id] = $logins[$server_id];
+                                       else $srvs[$server_id] = $info;
 
-                                       if (!isset($srvs[$server_id])) {
-                                               $srvs[$server_id] = $info;
-                                       }
                                        $srvs[$server_id]['id'] = $server_id;
                                }
                        }
index 7790085dba18d23be8e718ca654c203257f0e1fd..83de22a46e786ec391fa1b8c0a69ec2024ad27dc 100644 (file)
@@ -76,6 +76,7 @@
                
                if (($group !== false) and isset($conf['srv_groups'][$group])) {
                        printf("<h2>{$lang['strgroupservers']}</h2>", htmlentities($conf['srv_groups'][$group]['desc']));
+                       $actions['logout']['url'] .= "group=" . htmlentities($group) . "&amp;";
                }
                
                $misc->printTable($servers, $columns, $actions, $lang['strnoobjects'], 'svPre');