Move schemas into a schemas folder. Avoid database connection on 3 Slony folders...
authorchriskl <chriskl>
Wed, 6 Jul 2005 14:46:23 +0000 (14:46 +0000)
committerchriskl <chriskl>
Wed, 6 Jul 2005 14:46:23 +0000 (14:46 +0000)
BUGS
TODO
classes/Misc.php
classes/plugins/Slony.php
database.php
plugin_slony.php
schemas.php [new file with mode: 0755]

diff --git a/BUGS b/BUGS
index 35bd5a34770f63a910f0b2e5837aedd251b17a35..be27c72f1d909dc086d1b7ab0d575a4bd1f3ee8f 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -24,7 +24,6 @@ Need to fix:
 NEEDS TESTING
 -------------
 
-* Script execution needs to support error handling - make it pass thru adodb layer
 * COPY should work in normal sql screen and sql popup window
 * notice on viewing reports page - does this still occur?
 * highlight things on the info stats page
diff --git a/TODO b/TODO
index 09b8b09462eeff42c259dc36b4cb493935730f7e..41b3a9a4579505f3bd449bb1c4af7bed7c6f941f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -20,6 +20,10 @@ Users
 Groups
 ------
 
+Roles
+-----
+
+* Support for 8.1 roles (removing users and groups)
 
 Permissions
 -----------
index 1f4ecfddbb8b3da8b7998ec91e4f5dfda82513d1..ef78a4b68c60b935c440d6dc3626006bcd2412c9 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.104 2005/06/29 05:15:06 chriskl Exp $
+        * $Id: Misc.php,v 1.105 2005/07/06 14:46:24 chriskl Exp $
         */
         
        class Misc {
                 */
                function getNavTabs($section) {
                        global $data, $lang, $conf;
-                       
-#                      $servervar = isset($_REQUEST['server']) ? 'server=' . urlencode($_REQUEST['server']) : '';
-#                      $databasevar = isset($_REQUEST['database']) ? '&database=' . urlencode($_REQUEST['database']) : '';
-#                      $schemavar = isset($_REQUEST['schema']) ? '&schema=' . urlencode($_REQUEST['schema']) : '';
+
                        $hide_advanced = ($conf['show_advanced'] === false);
                        
                        switch ($section) {
                                        );
 
                                case 'server':
-#                                      $vars = $servervar . $databasevar . '&subject=server';
                                        $server_info = $this->getServerInfo();
                                        $hide_users = !$data->isSuperUser($server_info['username']);
-                                       #$hide_users = false;
                                        return array (
                                                'databases' => array (
                                                        'title' => $lang['strdatabases'],
                                                ),
                                        );
 
-                               case 'database':
-#                                      $vars = $servervar . $databasevar . '&subject=database';
+                               case 'database':                                
                                        $tabs = array (
                                                'schemas' => array (
                                                        'title' => $lang['strschemas'],
-                                                       'url'   => 'database.php',
+                                                       'url'   => 'schemas.php',
                                                        'urlvars' => array('subject' => 'database'),
                                                        'hide'  => (!$data->hasSchemas()),
                                                        'help'  => 'pg.schema',
-                                                       'tree'  => false,
                                                ),
                                                'sql' => array (
                                                        'title' => $lang['strsql'],
                                                        'tree'  => false,
                                                ),
                                        );
-
                                        return $tabs;
                                case 'schema':
-#                                      $vars = $servervar . $databasevar . $schemavar . '&subject=schema';
                                        return array (
                                                'tables' => array (
                                                        'title' => $lang['strtables'],
                                        );
 
                                case 'table':
-#                                      $table = urlencode($_REQUEST['table']);
-#                                      $vars = $servervar . $databasevar . $schemavar . "&table={$table}&subject=table";
                                        return array (
                                                'columns' => array (
                                                        'title' => $lang['strcolumns'],
                                        );
                                
                                case 'view':
-#                                      $view = urlencode($_REQUEST['view']);
-#                                      $vars = $servervar . $databasevar . $schemavar . "&view={$view}&subject=view";
                                        return array (
                                                'columns' => array (
                                                        'title' => $lang['strcolumns'],
                                        );
                                
                                case 'function':
-#                                      $funcnam = urlencode($_REQUEST['function']);
-#                                      $funcoid = urlencode($_REQUEST['function_oid']);
-#                                      $vars = $servervar . $databasevar . $schemavar . "&function={$funcnam}&function_oid={$funcoid}&subject=function";
                                        return array (
                                                'definition' => array (
                                                        'title' => $lang['strdefinition'],
                                        );
                                
                                case 'popup':
-#                                      $vars = $servervar . $databasevar;
                                        return array (
                                                'sql' => array (
                                                        'title' => $lang['strsql'],
index 2687aeb8359d46ea5915c20b67896131e9b7cbb4..0be4165bdc899b61b2190e903b828958938f0956 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * A class that implements the Slony 1.0.x support plugin
  *
- * $Id: Slony.php,v 1.4 2005/06/22 15:03:59 chriskl Exp $
+ * $Id: Slony.php,v 1.5 2005/07/06 14:46:24 chriskl Exp $
  */
 
 include_once('./classes/plugins/Plugin.php');
@@ -22,6 +22,7 @@ class Slony extends Plugin {
         */
        function Slony() {
                $this->Plugin('slony');
+               $this->isEnabled();
        }
 
        /**
index 27194e77666c613eed9e4221bb467f8f69294b61..4a81148df29066c4064f0084ceadbafd0e61ed5e 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.70 2005/06/22 14:21:07 chriskl Exp $
+        * $Id: database.php,v 1.71 2005/07/06 14:46:23 chriskl Exp $
         */
 
        // Include application functions
        
        function doTree() {
                global $misc, $data, $lang, $PHP_SELF, $slony;
-               
-               $schemas = &$data->getSchemas();
-               
-               $reqvars = $misc->getRequestVars('schema');
-               
-               $attrs = array(
-                       'text'   => field('nspname'),
-                       'icon'   => 'folder',
-                       'toolTip'=> field('nspcomment'),
-                       'action' => url('redirect.php',
-                                                       $reqvars,
-                                                       array(
-                                                               'subject' => 'schema',
-                                                               'schema'  => field('nspname')
-                                                       )
-                                               ),
-                       'branch' => url('database.php',
-                                                       $reqvars,
-                                                       array(
-                                                               'action'  => 'subtree',
-                                                               'schema'  => field('nspname')
-                                                       )
-                                               ),
-                       'nofoot' => true
-               );
-               
-               $misc->printTreeXML($schemas, $attrs);
-               
+
+               $reqvars = $misc->getRequestVars('database');
+
                $tabs = $misc->getNavTabs('database');
+               
                // Show slony node if enabled on this database
                if (isset($slony)) {
                        $tabs['slony'] = array (
                                                                        'help'  => ''
                                                                );
                }
-               
+
                $items =& $misc->adjustTabsForTree($tabs);
                
                $attrs = array(
                                                        field('urlvars'),
                                                        array('action' => 'tree')
                                                ),
-                       'nohead' => true
                );
                
                $misc->printTreeXML($items, $attrs);
-               
+
                exit;
        }
        
index fc17917621a491dbea836528edc4d078a1fc4784..a8af29d7f4a857df4bd29f759f76ffe4232d86f1 100755 (executable)
@@ -3,9 +3,19 @@
        /**
         * Slony database tab plugin
         *
-        * $Id: plugin_slony.php,v 1.2 2005/06/16 14:40:10 chriskl Exp $
+        * $Id: plugin_slony.php,v 1.3 2005/07/06 14:46:23 chriskl Exp $
         */
 
+       // Avoid database connections whenever possible
+       switch ($_REQUEST['action']) {
+               case 'clusters_top':
+               case 'nodes_top':
+               case 'sets_top':
+                               $_no_db_connection = true;
+                               break;
+               default:
+       }
+
        // Include application functions
        include_once('./libraries/lib.inc.php');
 
                
                $misc->printTable($clusters, $columns, $actions, $lang['strnoclusters']);
 
-               // XXX: FIX THIS ONCE WE SUPPORT MULTIPLE CLUSTERS
                if ($clusters->recordCount() == 0) {            
                        echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=create_cluster&amp;{$misc->href}\">{$lang['strinitcluster']}</a></p>\n";
                }
diff --git a/schemas.php b/schemas.php
new file mode 100755 (executable)
index 0000000..402b3be
--- /dev/null
@@ -0,0 +1,160 @@
+<?php
+
+       /**
+        * Manage schemas in a database
+        *
+        * $Id: schemas.php,v 1.1 2005/07/06 14:46:24 chriskl Exp $
+        */
+
+       // Include application functions
+       include_once('./libraries/lib.inc.php');
+       
+       $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
+       if (!isset($msg)) $msg = '';
+       $PHP_SELF = $_SERVER['PHP_SELF'];
+
+       /**
+        * Show default list of schemas in the database
+        */
+       function doDefault($msg = '') {
+               global $data, $misc, $conf;
+               global $PHP_SELF, $lang;
+               
+               $misc->printTrail('database');
+               $misc->printTabs('database','schemas');
+               $misc->printMsg($msg);
+               
+               // Check that the DB actually supports schemas
+               if ($data->hasSchemas()) {
+                       $schemas = &$data->getSchemas();
+
+                       $columns = array(
+                               'schema' => array(
+                                       'title' => $lang['strschema'],
+                                       'field' => 'nspname',
+                               ),
+                               'owner' => array(
+                                       'title' => $lang['strowner'],
+                                       'field' => 'nspowner',
+                               ),
+                               'actions' => array(
+                                       'title' => $lang['stractions'],
+                               ),
+                               'comment' => array(
+                                       'title' => $lang['strcomment'],
+                                       'field' => 'nspcomment',
+                               ),
+                       );
+                       
+                       $actions = array(
+                               'properties' => array(
+                                       'title' => $lang['strproperties'],
+                                       'url'   => "redirect.php?subject=schema&amp;{$misc->href}&amp;",
+                                       'vars'  => array('schema' => 'nspname'),
+                               ),
+                               'drop' => array(
+                                       'title' => $lang['strdrop'],
+                                       'url'   => "{$PHP_SELF}?action=confirm_drop&amp;{$misc->href}&amp;",
+                                       'vars'  => array('schema' => 'nspname'),
+                               ),
+                               'privileges' => array(
+                                       'title' => $lang['strprivileges'],
+                                       'url'   => "privileges.php?subject=schema&amp;{$misc->href}&amp;",
+                                       'vars'  => array('schema' => 'nspname'),
+                               ),
+                               'alter' => array(
+                                       'title' => $lang['stralter'],
+                                       'url'   => "{$PHP_SELF}?action=alter_schema&amp;{$misc->href}&amp;",
+                                       'vars'  => array('schema' => 'nspname'),
+                               ),
+                       );
+                       
+                       $misc->printTable($schemas, $columns, $actions, $lang['strnoschemas']);
+
+                       echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=create&amp;{$misc->href}\">{$lang['strcreateschema']}</a></p>\n";
+               } else {
+                       // If the database does not support schemas...
+                       echo "<p>{$lang['strnoschemas']}</p>\n";
+               }
+       }
+
+       /**
+        * Generate XML for the browser tree.
+        */
+       function doTree() {
+               global $misc, $data, $lang, $PHP_SELF, $slony;
+               
+               $schemas = &$data->getSchemas();
+               
+               $reqvars = $misc->getRequestVars('schema');
+               
+               $attrs = array(
+                       'text'   => field('nspname'),
+                       'icon'   => 'folder',
+                       'toolTip'=> field('nspcomment'),
+                       'action' => url('redirect.php',
+                                                       $reqvars,
+                                                       array(
+                                                               'subject' => 'schema',
+                                                               'schema'  => field('nspname')
+                                                       )
+                                               ),
+                       'branch' => url('database.php',
+                                                       $reqvars,
+                                                       array(
+                                                               'action'  => 'subtree',
+                                                               'schema'  => field('nspname')
+                                                       )
+                                               ),
+               );
+               
+               $misc->printTreeXML($schemas, $attrs);
+               
+               exit;
+       }
+       
+       function doSubTree() {
+               global $misc, $data, $lang;
+               
+               $tabs = $misc->getNavTabs('schema');
+               
+               $items =& $misc->adjustTabsForTree($tabs);
+               
+               $reqvars = $misc->getRequestVars('schema');
+               
+               $attrs = array(
+                       'text'   => noEscape(field('title')),
+                       'icon'   => field('icon', 'folder'),
+                       'action' => url(field('url'),
+                                                       $reqvars,
+                                                       field('urlvars', array())
+                                               ),
+                       'branch' => url(field('url'),
+                                                       $reqvars,
+                                                       field('urlvars'),
+                                                       array('action' => 'tree')
+                                               )
+               );
+               
+               $misc->printTreeXML($items, $attrs);
+               exit;
+       }
+       
+       if ($action == 'tree') doTree();
+       if ($action == 'subtree') doSubTree();
+       
+       $misc->printHeader($lang['strschemas']);
+       $misc->printBody();
+
+       switch ($action) {
+               case 'tree':
+                       doTree();
+                       break;
+               default:
+                       doDefault();
+                       break;
+       }       
+
+       $misc->printFooter();
+
+?>