/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.100 2005/05/02 15:47:25 chriskl Exp $
+ * $Id: Misc.php,v 1.100.2.1 2005/05/11 15:48:03 chriskl Exp $
*/
class Misc {
case 'database':
# $vars = $servervar . $databasevar . '&subject=database';
- return array (
+ $tabs = array (
'schemas' => array (
'title' => $lang['strschemas'],
'url' => 'database.php',
'hide' => (!$this->isDumpEnabled()),
),
);
-
+ // Add plugin tabs
+ global $plugins;
+ foreach ($plugins as $v) {
+ $tab = $v->getDatabaseTab();
+ if ($tab !== null) {
+ $tabs[$tab['id']] = $tab;
+ }
+ }
+
+ return $tabs;
case 'schema':
# $vars = $servervar . $databasevar . $schemavar . '&subject=schema';
return array (
--- /dev/null
+<?php
+
+/**
+ * A class that implements the plugin system
+ *
+ * $Id: Plugin.php,v 1.1.2.1 2005/05/11 15:48:03 chriskl Exp $
+ */
+
+class Plugin {
+
+ var $tabname = null;
+ var $config = null;
+ var $name = null;
+
+ /**
+ * Constructor
+ */
+ function Plugin($name) {
+ $this->name = $name;
+
+ // Read in configuration
+ if ($this->config !== null) {
+ global $conf;
+ include('./conf/' . $name . '.inc.php');
+ }
+ }
+
+}
+
+?>
--- /dev/null
+<?php
+
+/**
+ * A class that implements the Slony 1.0.x support plugin
+ *
+ * $Id: Slony.php,v 1.1.2.1 2005/05/11 15:48:03 chriskl Exp $
+ */
+
+include_once('./classes/plugins/Plugin.php');
+
+class Slony extends Plugin {
+
+ var $config = 'slony.inc.php';
+
+ /**
+ * Constructor
+ */
+ function Slony() {
+ $this->Plugin('slony');
+ }
+
+ /**
+ * Gets the database tab details
+ * @return array The array of tab details, null for none
+ */
+ function getDatabaseTab() {
+ return array(
+ 'id' => 'slony',
+ 'title' => 'Slony',
+ 'url' => 'plugin_slony.php',
+ 'urlvars' => array('subject' => 'database', 'action' => 'slony'),
+ 'hide' => false
+ );
+ }
+
+ /**
+ * Gets the nodes in this database
+ */
+ function getNodes() {
+ global $data;
+
+ $sql = "SELECT * FROM sl_node ORDER BY no_id";
+
+ return $data->selectSet($sql);
+ }
+
+ /**
+ * Gets a single node
+ */
+ function getNode($no_id) {
+ global $data;
+ $data->clean($no_id);
+
+ $sql = "SELECT * FROM sl_node WHERE no_id='{$no_id}'";
+
+ return $data->selectSet($sql);
+ }
+
+ /**
+ * Gets node listens
+ */
+ function getNodeClients($no_id) {
+ global $data;
+ $data->clean($no_id);
+
+ $sql = "SELECT * FROM sl_path sp, sl_node sn
+ WHERE sp.pa_client=sn.no_id
+ AND pa_server='{$no_id}'
+ ORDER BY sn.no_id";
+
+ return $data->selectSet($sql);
+ }
+}
+
+?>
--- /dev/null
+<?php
+
+ /**
+ * Slony plugin configuration
+ *
+ * $Id: slony.inc.php,v 1.1.2.1 2005/05/11 15:48:03 chriskl Exp $
+ */
+
+ $conf['slony_enabled'] = true;
+
+?>
/**
* Function library read in upon startup
*
- * $Id: lib.inc.php,v 1.94 2005/05/02 15:47:28 chriskl Exp $
+ * $Id: lib.inc.php,v 1.94.2.1 2005/05/11 15:48:03 chriskl Exp $
*/
include_once('decorator.inc.php');
include_once('./lang/translations.php');
}
}
+ // XXX: THIS IS A TEMPORARY HACK TO GET SLONY OBJECT LOADED
+ include('./classes/plugins/Slony.php');
+ $slony = new Slony();
+ $plugins = array(&$slony);
+
?>
--- /dev/null
+<?php
+
+ /**
+ * Slony database tab plugin
+ *
+ * $Id: plugin_slony.php,v 1.1.2.1 2005/05/11 15:48:03 chriskl Exp $
+ */
+
+ // Include application functions
+ include_once('./libraries/lib.inc.php');
+
+ $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
+ $PHP_SELF = $_SERVER['PHP_SELF'];
+
+ function doProperties() {
+ global $slony, $misc;
+ global $lang;
+
+ $misc->printTrail('database');
+ $misc->printTabs('database','slony');
+
+ $clients = $slony->getNodeClients($_REQUEST['no_id']);
+
+ echo "<h3>Clients</h3>\n";
+
+ $columns = array(
+ 'no_id' => array(
+ 'title' => 'Node ID',
+ 'field' => 'no_id'
+ ),
+ 'no_active' => array(
+ 'title' => 'Active',
+ 'field' => 'no_active'
+ ),
+ 'no_spool' => array(
+ 'title' => 'Spool',
+ 'field' => 'no_spool'
+ ),
+ 'pa_conninfo' => array(
+ 'title' => 'Connection',
+ 'field' => 'pa_conninfo'
+ ),
+ 'pa_connretry' => array(
+ 'title' => 'Retry',
+ 'field' => 'pa_connretry'
+ ),
+ 'actions' => array(
+ 'title' => $lang['stractions'],
+ ),
+ 'no_comment' => array(
+ 'title' => $lang['strcomment'],
+ 'field' => 'no_comment'
+ )
+ );
+
+ $actions = array (
+ 'detail' => array(
+ 'title' => $lang['strproperties'],
+ 'url' => "plugin_slony.php?{$misc->href}&action=properties&",
+ 'vars' => array('no_id' => 'no_id')
+ )
+ );
+
+ $misc->printTable($clients, $columns, $actions, 'No nodes found.');
+ }
+
+ /**
+ * List all the information on the table
+ */
+ function doDefault($msg = '') {
+ global $slony, $misc;
+ global $lang;
+
+ $misc->printTrail('database');
+ $misc->printTabs('database','slony');
+ $misc->printMsg($msg);
+
+ $nodes = $slony->getNodes();
+
+ echo "<h3>Nodes</h3>\n";
+
+ $columns = array(
+ 'no_id' => array(
+ 'title' => 'Node ID',
+ 'field' => 'no_id'
+ ),
+ 'no_active' => array(
+ 'title' => 'Active',
+ 'field' => 'no_active'
+ ),
+ 'no_spool' => array(
+ 'title' => 'Spool',
+ 'field' => 'no_spool'
+ ),
+ 'actions' => array(
+ 'title' => $lang['stractions'],
+ ),
+ 'no_comment' => array(
+ 'title' => $lang['strcomment'],
+ 'field' => 'no_comment'
+ )
+ );
+
+ $actions = array (
+ 'detail' => array(
+ 'title' => $lang['strproperties'],
+ 'url' => "plugin_slony.php?{$misc->href}&action=properties&",
+ 'vars' => array('no_id' => 'no_id')
+ )
+ );
+
+ $misc->printTable($nodes, $columns, $actions, 'No nodes found.');
+ }
+
+ $misc->printHeader('Slony');
+ $misc->printBody();
+
+ switch ($action) {
+ case 'properties':
+ doProperties();
+ break;
+ default:
+ doDefault();
+ break;
+ }
+
+ $misc->printFooter();
+
+?>