summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchriskl2005-07-06 14:46:23 +0000
committerchriskl2005-07-06 14:46:23 +0000
commit1a063b8022b04afa1f3dfb4929f9081d242f9154 (patch)
tree4e870384d411a747c20e0b8b028acb0d3aec7308
parentc1b818c4444aee974047da2ac227a5d3e3399a39 (diff)
Move schemas into a schemas folder. Avoid database connection on 3 Slony folders for big speedup. Various other things.
-rw-r--r--BUGS1
-rw-r--r--TODO4
-rw-r--r--classes/Misc.php25
-rwxr-xr-xclasses/plugins/Slony.php3
-rwxr-xr-xdatabase.php39
-rwxr-xr-xplugin_slony.php13
-rwxr-xr-xschemas.php160
7 files changed, 188 insertions, 57 deletions
diff --git a/BUGS b/BUGS
index 35bd5a34..be27c72f 100644
--- 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 09b8b094..41b3a9a4 100644
--- a/TODO
+++ b/TODO
@@ -20,6 +20,10 @@ Users
Groups
------
+Roles
+-----
+
+* Support for 8.1 roles (removing users and groups)
Permissions
-----------
diff --git a/classes/Misc.php b/classes/Misc.php
index 1f4ecfdd..ef78a4b6 100644
--- a/classes/Misc.php
+++ b/classes/Misc.php
@@ -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 {
@@ -441,10 +441,7 @@
*/
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) {
@@ -461,10 +458,8 @@
);
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'],
@@ -514,16 +509,14 @@
),
);
- 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'],
@@ -590,10 +583,8 @@
'tree' => false,
),
);
-
return $tabs;
case 'schema':
-# $vars = $servervar . $databasevar . $schemavar . '&subject=schema';
return array (
'tables' => array (
'title' => $lang['strtables'],
@@ -682,8 +673,6 @@
);
case 'table':
-# $table = urlencode($_REQUEST['table']);
-# $vars = $servervar . $databasevar . $schemavar . "&table={$table}&subject=table";
return array (
'columns' => array (
'title' => $lang['strcolumns'],
@@ -738,8 +727,6 @@
);
case 'view':
-# $view = urlencode($_REQUEST['view']);
-# $vars = $servervar . $databasevar . $schemavar . "&view={$view}&subject=view";
return array (
'columns' => array (
'title' => $lang['strcolumns'],
@@ -771,9 +758,6 @@
);
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'],
@@ -797,7 +781,6 @@
);
case 'popup':
-# $vars = $servervar . $databasevar;
return array (
'sql' => array (
'title' => $lang['strsql'],
diff --git a/classes/plugins/Slony.php b/classes/plugins/Slony.php
index 2687aeb8..0be4165b 100755
--- a/classes/plugins/Slony.php
+++ b/classes/plugins/Slony.php
@@ -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();
}
/**
diff --git a/database.php b/database.php
index 27194e77..4a81148d 100755
--- a/database.php
+++ b/database.php
@@ -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
@@ -711,35 +711,11 @@
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 (
@@ -750,7 +726,7 @@
'help' => ''
);
}
-
+
$items =& $misc->adjustTabsForTree($tabs);
$attrs = array(
@@ -765,11 +741,10 @@
field('urlvars'),
array('action' => 'tree')
),
- 'nohead' => true
);
$misc->printTreeXML($items, $attrs);
-
+
exit;
}
diff --git a/plugin_slony.php b/plugin_slony.php
index fc179176..a8af29d7 100755
--- a/plugin_slony.php
+++ b/plugin_slony.php
@@ -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');
@@ -431,7 +441,6 @@
$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
index 00000000..402b3be4
--- /dev/null
+++ b/schemas.php
@@ -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();
+
+?>