* Allow users to specify a template database at database creation time
* Support killing processes
* Add ability to create indexes concurrently
+* Allow user to logicaly group their server under custom named node in the browser tree
Bugs
* Fix problems with query tracking on overly long queries
$_no_db_connection = true;
include_once('./libraries/lib.inc.php');
+ if (isset($conf['srv_groups'])) {
+ $treeaction = 'groupstree';
+ }
+ else {
+ $treeaction = 'tree';
+ }
+
// Output header
$misc->printHeader('', '
<script src="xloadtree/xtree2.js" type="text/javascript"></script>
return false;
};
*/
-var tree = new WebFXLoadTree("<?php echo $lang['strservers']; ?>", "servers.php?action=tree", "servers.php");
+var tree = new WebFXLoadTree("<?php echo $lang['strservers']; ?>", "servers.php?action=<?php echo $treeaction ?>", "servers.php");
tree.write();
tree.setExpanded(true);
return escapeshellcmd($str);
}
+ /**
+ * Get list of servers' groups if existing in the conf
+ * @return a recordset of servers' groups
+ */
+ function getServersGroups() {
+ global $conf, $lang;
+ $grps = array();
+
+ foreach ($conf['srv_groups'] as $i => $group) {
+ $grps[$i] = array(
+ 'id' => $i,
+ 'desc' => $group['desc'],
+ );
+ }
+
+ $grps['all'] = array(
+ 'id' => 'all',
+ 'desc' => $lang['strallservers'],
+ );
+
+ include_once('./classes/ArrayRecordSet.php');
+ return new ArrayRecordSet($grps);
+ }
+
+
/**
* Get list of servers
* @param $recordset return as RecordSet suitable for printTable if true,
* otherwise just return an array.
+ * @param $group a group name to filter the returned servers using $conf[srv_groups]
*/
- function getServers($recordset = false) {
+ 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);
+ }
+
foreach($conf['servers'] as $idx => $info) {
- $server_id = $info['host'].':'.$info['port'].':'.$info['sslmode'];
-
- if (!isset($srvs[$server_id])) {
- $srvs[$server_id] = $info;
+ if (($group === false)
+ or (isset($group[$idx]))
+ or ($group === 'all')
+ ) {
+ $server_id = $info['host'].':'.$info['port'].':'.$info['sslmode'];
+
+ if (!isset($srvs[$server_id])) {
+ $srvs[$server_id] = $info;
+ }
+ $srvs[$server_id]['id'] = $server_id;
}
- $srvs[$server_id]['id'] = $server_id;
}
function _cmp_desc($a, $b) {
//$conf['servers'][1]['pg_dumpall_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe';
//$conf['servers'][1]['slony_support'] = false;
//$conf['servers'][1]['slony_sql'] = 'C:\\Program Files\\PostgreSQL\\8.0\\share';
+
+
+ // Example of groups definition.
+ // Groups allow administrators to logicaly group servers together under group nodes in the left browser tree
+ //
+ // The group '0' description
+ //$conf['srv_groups'][0]['desc'] = 'group one';
+ //
+ // Add here servers indexes belonging to the group '0' seperated by comma
+ //$conf['srv_groups'][0]['servers'] = '0,1,2';
+ //
+ // A server can belong to multi groups
+ //$conf['srv_groups'][1]['desc'] = 'group two';
+ //$conf['srv_groups'][1]['servers'] = '3,1';
+
// Default language. E.g.: 'english', 'polish', etc. See lang/ directory
// for all possibilities. If you specify 'auto' (the default) it will use
$lang['strlogindisallowed'] = 'Login disallowed for security reasons.';
$lang['strserver'] = 'Server';
$lang['strservers'] = 'Servers';
+ $lang['strgroupservers'] = 'Servers in group "%s"';
+ $lang['strallservers'] = 'All servers';
$lang['strintroduction'] = 'Introduction';
$lang['strhost'] = 'Host';
$lang['strport'] = 'Port';
$lang['strlogindisallowed'] = 'Login disallowed for security reasons.';
$lang['strserver'] = 'Server';
$lang['strservers'] = 'Servers';
+ $lang['strgroupservers'] = 'Servers in group "%s"';
+ $lang['strallservers'] = 'All servers';
$lang['strintroduction'] = 'Introduction';
$lang['strhost'] = 'Host';
$lang['strport'] = 'Port';
$misc->printTabs('root','servers');
$misc->printMsg($msg);
- $servers = $misc->getServers(true);
+ $group = isset($_GET['group']) ? $_GET['group'] : false;
+
+ $servers = $misc->getServers(true, $group);
function svPre(&$rowdata, $actions) {
$actions['logout']['disable'] = empty($rowdata->fields['username']);
),
);
+ if (($group !== false) and isset($conf['srv_groups'][$group])) {
+ printf("<h2>{$lang['strgroupservers']}</h2>", htmlentities($conf['srv_groups'][$group]['desc']));
+ }
+
$misc->printTable($servers, $columns, $actions, $lang['strnoobjects'], 'svPre');
+
+ if (isset($conf['srv_groups'])) {
+ echo "<br /><ul class=\"navlink\">\n";
+ echo "\t<li><a href=\"servers.php\">{$lang['strallservers']}</a></li>\n";
+ foreach ($conf['srv_groups'] as $id => $grp) {
+ echo "\t<li><a href=\"servers.php?group={$id}\">", htmlentities($grp['desc']), "</a></li>\n";
+ }
+ echo "</ul>\n";
+ }
}
- function doTree() {
+ function doTree($group = false) {
global $misc;
- $servers = $misc->getServers(true);
+ $servers = $misc->getServers(true, $group);
$reqvars = $misc->getRequestVars('server');
exit;
}
- if ($action == 'tree') doTree();
+ function doGroupsTree() {
+ global $misc;
+
+ $groups = $misc->getServersGroups();
+
+ $attrs = array(
+ 'text' => field('desc'),
+ 'icon' => 'Servers',
+ 'action' => url('servers.php',
+ array(
+ 'group' => field('id')
+ )
+ ),
+ 'branch' => url('servers.php',
+ array(
+ 'action' => 'tree',
+ 'group' => field('id')
+ )
+ )
+ );
+
+ $misc->printTreeXML($groups, $attrs);
+ exit;
+ }
+
+ if ($action == 'tree') {
+ if (isset($_GET['group'])) doTree($_GET['group']);
+ else doTree(false);
+ }
+
+ if ($action == 'groupstree') doGroupsTree();
$misc->printHeader($lang['strservers']);
$misc->printBody();
case 'logout':
doLogout();
break;
- case 'tree':
default:
doDefault($msg);
break;