Add config file 'slony_enabled' option. Try to clean up how slony is started and...
authorchriskl <chriskl>
Wed, 22 Jun 2005 14:21:07 +0000 (14:21 +0000)
committerchriskl <chriskl>
Wed, 22 Jun 2005 14:21:07 +0000 (14:21 +0000)
classes/database/Postgres73.php
classes/database/Postgres80.php
classes/plugins/Slony.php
conf/config.inc.php-dist
database.php
libraries/lib.inc.php

index a445ddeaeee05f4ecf5ef9401113bfd8eb72a0c4..506d719db18b0b8e72a8993f46f27d09c2bb4be1 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres73.php,v 1.144 2005/06/16 14:40:12 chriskl Exp $
+ * $Id: Postgres73.php,v 1.145 2005/06/22 14:21:08 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -116,9 +116,16 @@ class Postgres73 extends Postgres72 {
         * @return All schemas, sorted alphabetically - but with PUBLIC first (if it exists)
         */
        function &getSchemas() {
-               global $conf;
+               global $conf, $slony;
 
-               if (!$conf['show_system']) $and = "AND nspname NOT LIKE 'pg\\\\_%'";
+               if (!$conf['show_system']) {
+                       $and = "AND nspname NOT LIKE 'pg\\\\_%'";
+                       if (isset($slony)) {
+                               $temp = $slony->slony_schema;
+                               $this->clean($temp);
+                               $and .= " AND npsname != '{$temp}'";
+                       }
+               }
                else $and = "AND nspname !~ '^pg_t(emp_[0-9]+|oast)$'";
                $sql = "SELECT pn.nspname, pu.usename AS nspowner, pg_catalog.obj_description(pn.oid, 'pg_namespace') AS nspcomment
                         FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
index 37f5ad16ce148123796f68de902055c5fbbb7167..4dc3e931234cbad33c25a218ec97b13618ebfe11 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * PostgreSQL 8.0 support
  *
- * $Id: Postgres80.php,v 1.14 2005/06/16 14:40:12 chriskl Exp $
+ * $Id: Postgres80.php,v 1.15 2005/06/22 14:21:08 chriskl Exp $
  */
 
 include_once('./classes/database/Postgres74.php');
@@ -140,9 +140,17 @@ class Postgres80 extends Postgres74 {
         * @return All schemas, sorted alphabetically
         */
        function &getSchemas() {
-               global $conf;
-
-               if (!$conf['show_system']) $and = "AND nspname NOT LIKE 'pg\\\\_%' AND nspname != 'information_schema'";
+               global $conf, $slony;
+
+               if (!$conf['show_system']) {
+                       $and = "AND nspname NOT LIKE 'pg\\\\_%' AND nspname != 'information_schema'";
+                       if (isset($slony) && $slony->isEnabled()) {
+                               $temp = $slony->slony_schema;
+                               $this->clean($temp);
+                               $and .= " AND nspname != '{$temp}'";
+                       }                       
+                       
+               }
                else $and = "AND nspname !~ '^pg_t(emp_[0-9]+|oast)$'";
                $sql = "SELECT pn.nspname, pu.usename AS nspowner, pg_catalog.obj_description(pn.oid, 'pg_namespace') AS nspcomment
                         FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
index 3049a606a1d898469c5b12a8b196480335b72d7d..40ea749e1b19b9cf5e566425b7e057d4dff62dd6 100755 (executable)
@@ -3,20 +3,19 @@
 /**
  * A class that implements the Slony 1.0.x support plugin
  *
- * $Id: Slony.php,v 1.2 2005/06/16 14:40:12 chriskl Exp $
+ * $Id: Slony.php,v 1.3 2005/06/22 14:21:08 chriskl Exp $
  */
 
 include_once('./classes/plugins/Plugin.php');
 
 class Slony extends Plugin {
 
-       var $config = 'slony.inc.php';
-       var $category = 'Replication';
        var $slony_version;
        var $slony_schema;
        var $slony_cluster;
        var $slony_owner;
        var $slony_comment;
+       var $enabled = null;
        
        /**
         * Constructor
@@ -32,6 +31,10 @@ class Slony extends Plugin {
         * @return True if Slony is installed, false otherwise.
         */
        function isEnabled() {
+               // Access cache
+               if ($this->enabled !== null) return $enabled;
+               else $this->enabled = false;
+               
                global $data;
                
                // Slony needs schemas
@@ -63,6 +66,7 @@ class Slony extends Plugin {
                        if ($version === -1) return false;
                        else {
                                $this->slony_version = $version;
+                               $this->enabled = true;
                                return true;
                        }
                }
index c3d4d56557fe4ba92a2e371ee507bc9cb182203f..db7418e16be590c0577225cf36f166fd0dc3c91e 100644 (file)
@@ -4,7 +4,7 @@
         * Central phpPgAdmin configuration.  As a user you may modify the
         * settings here for your particular configuration.
         *
-        * $Id: config.inc.php-dist,v 1.41 2005/02/16 10:27:44 jollytoad Exp $
+        * $Id: config.inc.php-dist,v 1.42 2005/06/22 14:21:09 chriskl Exp $
         */
 
        // An example server.  Create as many of these as you wish,
@@ -28,6 +28,9 @@
        $conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump';
        $conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall';
 
+       // Slony (www.slony.info) support?
+       $conf['servers'][0]['slony_support'] = false;
+
        // Example for a second server (PostgreSQL for Windows)
        //$conf['servers'][1]['desc'] = 'Test Server';
        //$conf['servers'][1]['host'] = '127.0.0.1';
@@ -35,6 +38,7 @@
        //$conf['servers'][1]['defaultdb'] = 'template1';
        //$conf['servers'][1]['pg_dump_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dump.exe';
        //$conf['servers'][1]['pg_dumpall_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe';
+       //$conf['servers'][1]['slony_support'] = false;
 
        // Default language for the login screen if there's no translation
        // matching user's browser request. Eg: 'english', 'polish', etc.
         * Don't modify anything below this line *
         *****************************************/
 
-       $conf['version'] = 14;
+       $conf['version'] = 15;
 
 ?>
index 4c9768aaf67b1ed379e95d8301b4b57fba42d623..27194e77666c613eed9e4221bb467f8f69294b61 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.69 2005/06/16 14:40:10 chriskl Exp $
+        * $Id: database.php,v 1.70 2005/06/22 14:21:07 chriskl Exp $
         */
 
        // Include application functions
                $misc->printTreeXML($schemas, $attrs);
                
                $tabs = $misc->getNavTabs('database');
-               $tabs['slony'] = array (
-                                                               'title' => 'Slony',
-                                                               'url'   => 'plugin_slony.php',
-                                                               'urlvars' => array('action' => 'clusters_properties'),
-                                                               'hide'  => false,
-                                                               'help'  => ''
-                                                       );
+               // Show slony node if enabled on this database
+               if (isset($slony)) {
+                       $tabs['slony'] = array (
+                                                                       'title' => 'Slony',
+                                                                       'url'   => 'plugin_slony.php',
+                                                                       'urlvars' => array('action' => 'clusters_properties'),
+                                                                       'hide'  => false,
+                                                                       'help'  => ''
+                                                               );
+               }
                
                $items =& $misc->adjustTabsForTree($tabs);
                
        }
        
        function doSubTree() {
-               global $misc, $data, $lang, $slony;
+               global $misc, $data, $lang;
                
                $tabs = $misc->getNavTabs('schema');
                
index f165a2d12b4f514a7eb108eda27f4c52cc85bb87..a7701d47457c2651ba460749ab98ac6d07b60b0e 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Function library read in upon startup
         *
-        * $Id: lib.inc.php,v 1.97 2005/06/20 16:16:42 jollytoad Exp $
+        * $Id: lib.inc.php,v 1.98 2005/06/22 14:21:09 chriskl Exp $
         */
        include_once('decorator.inc.php');
        include_once('./lang/translations.php');
@@ -38,7 +38,7 @@
        // Configuration file version.  If this is greater than that in config.inc.php, then
        // the app will refuse to run.  This and $conf['version'] should be incremented whenever
        // backwards incompatible changes are made to config.inc.php-dist.
-       $conf['base_version'] = 14;
+       $conf['base_version'] = 15;
 
        // Always include english.php, since it's the master language file
        if (!isset($conf['default_lang'])) $conf['default_lang'] = 'english';
                                $lang['appcharset'] = $dbEncoding;
                }
                
-               // XXX: THIS IS A TEMPORARY HACK TO GET SLONY OBJECT LOADED
-               include('./classes/plugins/Slony.php');
-               $slony = new Slony();
-               if ($slony->isEnabled()) {
-                       $plugins = array(&$slony);
+               // Load Slony if required               
+               if ($_server_info['slony_support']) {
+                       include('./classes/plugins/Slony.php');
+                       $slony = new Slony();
                }
-               else $plugins = array();
-               
        }
 
 ?>