privileges on tablespaces and databases. more help links. switch tablespaces list...
authorchriskl <chriskl>
Sat, 10 Jul 2004 08:51:01 +0000 (08:51 +0000)
committerchriskl <chriskl>
Sat, 10 Jul 2004 08:51:01 +0000 (08:51 +0000)
HISTORY
all_db.php
classes/database/Postgres.php
classes/database/Postgres71.php
classes/database/Postgres73.php
classes/database/Postgres75.php
lang/english.php
lang/recoded/english.php
privileges.php
tablespaces.php
tblproperties.php

diff --git a/HISTORY b/HISTORY
index cf137e4e8aa607ad796582a6c367a453d91d4c5c..f958af1859e9d9cd3820c14c4b3cf243cd739146 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -9,6 +9,7 @@ Features
 * Use language preferencies from browser (Markus Bertheau, Nicola Soranzo)
 * Tablespace support for 7.5
 * Support cancelling and killing backend processes in 7.5
+* Allow setting privileges on databases
 
 Translations
 * Arabic from Zaki
index d1fb96a02ca791e0a7222b7cb126c8d8a9f91ca2..7bc032a72d49eff310ef28ab13c5e79dcc432d1c 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage databases within a server
         *
-        * $Id: all_db.php,v 1.27 2004/07/09 01:57:58 chriskl Exp $
+        * $Id: all_db.php,v 1.28 2004/07/10 08:51:01 chriskl Exp $
         */
 
        // Include application functions
                                'url'   => "{$PHP_SELF}?action=confirm_drop&amp;",
                                'vars'  => array('db' => 'datname'),
                        ),
+                       'privileges' => array(
+                               'title' => $lang['strprivileges'],
+                               'url'   => "privileges.php?type=database&amp;",
+                               'vars'  => array('object' => 'datname'),
+                       )
                );
                
                if (!$data->hasTablespaces()) unset($columns['tablespace']);
index 8a4f0ed84f551ba20b4c82536f7d57724727c5e0..168a68d0a7da001f4dbdcf581742bba294286525 100755 (executable)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres.php,v 1.230 2004/07/09 01:50:43 chriskl Exp $
+ * $Id: Postgres.php,v 1.231 2004/07/10 08:51:01 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -3258,6 +3258,10 @@ class Postgres extends BaseDB {
                                $this->fieldClean($object);
                                $sql .= " SCHEMA \"{$object}\"";
                                break;
+                       case 'tablespace':
+                               $this->fieldClean($object);
+                               $sql .= " TABLESPACE \"{$object}\"";
+                               break;
                        default:
                                return -1;
                }
index b0491add847e03ca76c6bfebdb26f3bc531d5fe3..480422859e14aa00b8b5cbefa87bd7d5d69342fe 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres71.php,v 1.63 2004/07/08 17:57:31 xzilla Exp $
+ * $Id: Postgres71.php,v 1.64 2004/07/10 08:51:01 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -56,7 +56,11 @@ class Postgres71 extends Postgres {
 
        // Help sub pages (alphabetical order)
        var $help_page = array(
+               'add_column' => 'sql-altertable.html',
+               'alter_column' => 'sql-altertable.html',
+               'alter_table' => 'sql-altertable.html',
                'create_table' => 'sql-createtable.html',
+               'drop_column' => 'sql-altertable.html',
                'drop_table' => 'sql-droptable.html',
                'insert' => 'sql-insert.html',
                'select' => 'sql-select.html',
index 2283c74e9c579035629424db7b71d6a79840b2a6..e64a4f4b36a5d1d96916b1cd50cf166068169185 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.124 2004/07/07 03:00:07 chriskl Exp $
+ * $Id: Postgres73.php,v 1.125 2004/07/10 08:51:01 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -1174,6 +1174,9 @@ class Postgres73 extends Postgres72 {
                        case 'schema':
                                $sql = "SELECT nspacl AS acl FROM pg_catalog.pg_namespace WHERE nspname='{$object}'";
                                break;
+                       case 'tablespace':
+                               $sql = "SELECT spcacl AS acl FROM pg_catalog.pg_tablespace WHERE spcname='{$object}'";
+                               break;
                        default:
                                return -1;
                }
index df6d5ca469834bdeed461271d3421d87562390f1..f92f85a38e78e03deb572a59e2ae97600c1e81fb 100755 (executable)
@@ -3,13 +3,26 @@
 /**
  * PostgreSQL 7.5 support
  *
- * $Id: Postgres75.php,v 1.11 2004/07/09 01:57:58 chriskl Exp $
+ * $Id: Postgres75.php,v 1.12 2004/07/10 08:51:01 chriskl Exp $
  */
 
 include_once('./classes/database/Postgres74.php');
 
 class Postgres75 extends Postgres74 {
 
+       // List of all legal privileges that can be applied to different types
+       // of objects.
+       var $privlist = array(
+               'table' => array('SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'),
+               'view' => array('SELECT', 'RULE', 'ALL PRIVILEGES'),
+               'sequence' => array('SELECT', 'UPDATE', 'ALL PRIVILEGES'),
+               'database' => array('CREATE', 'TEMPORARY', 'ALL PRIVILEGES'),
+               'function' => array('EXECUTE', 'ALL PRIVILEGES'),
+               'language' => array('USAGE', 'ALL PRIVILEGES'),
+               'schema' => array('CREATE', 'USAGE', 'ALL PRIVILEGES'),
+               'tablespace' => array('CREATE', 'ALL PRIVILEGES')
+       );
+
        // Last oid assigned to a system object
        var $_lastSystemOID = 17137;
 
index 246bcfc63cc305ca9e73c7eb82665cbe23f00d54..b0e85ef778f4f50c022b3588ae8f6a10a63c0433 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.152 2004/07/08 03:23:02 chriskl Exp $
+        * $Id: english.php,v 1.153 2004/07/10 08:51:01 chriskl Exp $
         */
 
        // Language and character set
        $lang['strtablespacedroppedbad'] = 'Tablespace drop failed.';
        $lang['strtablespacealtered'] = 'Tablespace altered.';
        $lang['strtablespacealteredbad'] = 'Tablespace alteration failed.';
+       $lang['strshowalltablespaces'] = 'Show all tablespaces';
 
        // Miscellaneous
        $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user "%s", %s';
index 0b4a95908170ae1a7dd9e5b13d253d1910934f49..aa404fd4b1ca1f9e04996673f1939d56b6a90555 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.105 2004/07/08 03:23:02 chriskl Exp $
+        * $Id: english.php,v 1.106 2004/07/10 08:51:02 chriskl Exp $
         */
 
        // Language and character set
        $lang['strtablespacedroppedbad'] = 'Tablespace drop failed.';
        $lang['strtablespacealtered'] = 'Tablespace altered.';
        $lang['strtablespacealteredbad'] = 'Tablespace alteration failed.';
-
+       $lang['strshowalltablespaces'] = 'Show all tablespaces';
+       
        // Miscellaneous
        $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user &quot;%s&quot;, %s';
        $lang['strtimefmt'] = 'jS M, Y g:iA';
index 4a649947a1f75487e09146c98fae98225b84ce11..b9fd44497dbe47314911a4950eca30f3f3c99697 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage privileges in a database
         *
-        * $Id: privileges.php,v 1.24 2004/07/07 02:59:58 chriskl Exp $
+        * $Id: privileges.php,v 1.25 2004/07/10 08:51:01 chriskl Exp $
         */
 
        // Include application functions
                global $PHP_SELF, $lang;
 
                switch ($_REQUEST['type']) {
-                       case 'database':
-                               $misc->printDatabaseNav();
-                               $name = $_REQUEST['object'];
-                               break;
                        case 'table':
                                $misc->printTableNav();
                                $name = $_REQUEST['object'];
                                echo "| <a class=\"navlink\" href=\"sequences.php?{$misc->href}\">{$lang['strshowallsequences']}</a></p>\n";
                                break;
                        case 'database':
-                               echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=alter&amp;{$misc->href}&amp;type={$_REQUEST['type']}&amp;object=",
-                                       urlencode($_REQUEST['object']), "\">{$lang['stralterprivs']}</a></p>\n";
+                               echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=alter&amp;type={$_REQUEST['type']}&amp;object=",
+                                       urlencode($_REQUEST['object']), "\">{$lang['stralterprivs']}</a>\n";
+                               echo "| <a class=\"navlink\" href=\"all_db.php\">{$lang['strshowalldatabases']}</a></p>\n";
                                break;
                        case 'function':
                                echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=alter&amp;{$misc->href}&amp;type={$_REQUEST['type']}&amp;object=",
                                echo "| <a class=\"navlink\" href=\"database.php?database=", urlencode($_REQUEST['database']),
                                        "\">{$lang['strshowallschemas']}</a></p>\n";
                                break;
+                       case 'tablespace':
+                               echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=alter&amp;type={$_REQUEST['type']}&amp;object=",
+                                       urlencode($_REQUEST['object']), "\">{$lang['stralterprivs']}</a>\n";
+                               echo "| <a class=\"navlink\" href=\"tablespaces.php\">{$lang['strshowalltablespaces']}</a></p>\n";
+                               break;
                }
                echo "</p>\n";
        }
index 7ea1487f3ff63625ac5e34e6d464d9365f4ce4cd..7e58f7787fdfc0a060ea70b3d7edd270dbbed0b1 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage tablespaces in a database cluster
         *
-        * $Id: tablespaces.php,v 1.2 2004/07/09 01:50:43 chriskl Exp $
+        * $Id: tablespaces.php,v 1.3 2004/07/10 08:51:01 chriskl Exp $
         */
 
        // Include application functions
                $misc->printMsg($msg);
                
                $tablespaces = &$data->getTablespaces();
+
+               $columns = array(
+                       'database' => array(
+                               'title' => $lang['strname'],
+                               'field' => 'spcname'
+                       ),
+                       'owner' => array(
+                               'title' => $lang['strowner'],
+                               'field' => 'spcowner'
+                       ),
+                       'location' => array(
+                               'title' => $lang['strlocation'],
+                               'field' => 'spclocation'
+                       ),
+                       'actions' => array(
+                               'title' => $lang['stractions']
+                       )
+               );
                
-               if ($tablespaces->recordCount() > 0) {
-                       echo "<table>\n";
-                       echo "<tr><th class=\"data\">{$lang['strname']}</th><th class=\"data\">{$lang['strowner']}</th><th class=\"data\">{$lang['strlocation']}</th>";
-                       echo "<th colspan=\"2\" class=\"data\">{$lang['stractions']}</th></tr>\n";
-                       $i = 0;
-                       while (!$tablespaces->EOF) {
-                               $id = (($i % 2) == 0 ? '1' : '2');
-                               echo "<tr>\n\t<td class=\"data{$id}\">", $misc->printVal($tablespaces->f['spcname']), "</td>\n";
-                               echo "\t<td class=\"data{$id}\">", $misc->printVal($tablespaces->f['spcowner']), "</td>\n";
-                               echo "\t<td class=\"data{$id}\">", $misc->printVal($tablespaces->f['spclocation']), "</td>\n";
-                               echo "\t<td class=\"opbutton{$id}\"><a href=\"$PHP_SELF?action=edit&amp;spcname=",
-                                       urlencode($tablespaces->f['spcname']), "\">{$lang['stralter']}</a></td>\n";
-                               echo "\t<td class=\"opbutton{$id}\"><a href=\"$PHP_SELF?action=confirm_drop&amp;spcname=", 
-                                       urlencode($tablespaces->f['spcname']), "\">{$lang['strdrop']}</a></td>\n";
-                               echo "</tr>\n";
-                               $tablespaces->moveNext();
-                               $i++;
-                       }
-                       echo "</table>\n";
-               }
-               else {
-                       echo "<p>{$lang['strnotablespaces']}</p>\n";
-               }
+               $actions = array(
+                       'alter' => array(
+                               'title' => $lang['stralter'],
+                               'url'   => "{$PHP_SELF}?action=edit&amp;",
+                               'vars'  => array('spcname' => 'spcname')
+                       ),
+                       'drop' => array(
+                               'title' => $lang['strdrop'],
+                               'url'   => "{$PHP_SELF}?action=confirm_drop&amp;",
+                               'vars'  => array('spcname' => 'spcname')
+                       ),
+                       'privileges' => array(
+                               'title' => $lang['strprivileges'],
+                               'url'   => "privileges.php?type=tablespace&amp;",
+                               'vars'  => array('object' => 'spcname')
+                       )
+               );
+                               
+               $misc->printTable($tablespaces, $columns, $actions, $lang['strnotablespaces']);
                
                echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=create\">{$lang['strcreatetablespace']}</a></p>\n";
 
index 1c382b4dfdff839ddd8a55f91b1581313a9decbf..5076b4d6fa9c3a4956b70ee4550ce6a9f4feb57e 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tblproperties.php,v 1.52 2004/07/07 02:59:59 chriskl Exp $
+        * $Id: tblproperties.php,v 1.53 2004/07/10 08:51:01 chriskl Exp $
         */
 
        // Include application functions
@@ -44,7 +44,7 @@
                global $data, $misc;
                global $PHP_SELF, $lang;
                
-               echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['stralter']}</h2>\n";
+               $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), $lang['stralter']), 'alter_table');
                $misc->printMsg($msg);
 
                // Fetch table info             
                        
                        echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
                        echo "<table>\n";
-                       echo "<tr><th class=\"data required\">{$lang['strname']}</th>\n";
+                       echo "<tr><th class=\"data left required\">{$lang['strname']}</th>\n";
                        echo "<td class=\"data1\">";
                        echo "<input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", 
                                htmlspecialchars($_POST['name']), "\" /></td></tr>\n";
                        if ($data->hasAlterTableOwner() && $data->isSuperUser($_SESSION['webdbUsername'])) {
-                               echo "<tr><th class=\"data required\">{$lang['strowner']}</th>\n";
+                               echo "<tr><th class=\"data left required\">{$lang['strowner']}</th>\n";
                                echo "<td class=\"data1\"><select name=\"owner\">";
                                while (!$users->EOF) {
                                        $uname = $users->f['usename'];
@@ -75,7 +75,7 @@
                                }
                                echo "</select></td></tr>\n";                           
                        }
-                       echo "<tr><th class=\"data\">{$lang['strcomment']}</th>\n";
+                       echo "<tr><th class=\"data left\">{$lang['strcomment']}</th>\n";
                        echo "<td class=\"data1\">";
                        echo "<textarea rows=\"3\" cols=\"32\" name=\"comment\" wrap=\"virtual\">",
                                htmlspecialchars($_POST['comment']), "</textarea></td></tr>\n";
@@ -98,7 +98,7 @@
                $hasID = $data->hasObjectID($_REQUEST['table']);
                
                $misc->printTableNav();
-               echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strexport']}</h2>\n";
+               $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), $lang['strexport']));
                $misc->printMsg($msg);
 
                echo "<form action=\"dataexport.php\" method=\"post\">\n";
                global $PHP_SELF, $lang;
 
                $misc->printTableNav();
-               echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strimport']}</h2>\n";
+               $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), $lang['strimport']));
                $misc->printMsg($msg);
 
                // Check that file uploads are enabled
                                // Fetch all available types
                                $types = &$data->getTypes(true, false, true);
 
-                               echo "<h2>", $misc->printVal($_REQUEST['database']), ": ",
-                                       $misc->printVal($_REQUEST['table']), ": {$lang['straddcolumn']}</h2>\n";
+                               $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), $lang['straddcolumn']), 'add_column');
                                $misc->printMsg($msg);
 
                                echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
                        case 1:
                                global $lang;
 
-                               echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: {$lang['straltercolumn']}: ",
-                                       $misc->printVal($_REQUEST['column']), "</h2>\n";
+                               $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), 
+                                       $lang['straltercolumn'], $misc->printVal($_REQUEST['column'])), 'alter_column');
                                $misc->printMsg($msg);
 
                                echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
                global $PHP_SELF, $lang;
 
                if ($confirm) {
-                       echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", 
-                               $misc->printVal($_REQUEST['table']), ": " , $misc->printVal($_REQUEST['column']), ": {$lang['strdrop']}</h2>\n";
-
-                        echo "<p>", sprintf($lang['strconfdropcolumn'], $misc->printVal($_REQUEST['column']),
-                                $misc->printVal($_REQUEST['table'])), "</p>\n";
+                       $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), 
+                               $misc->printVal($_REQUEST['column']), $lang['strdrop']), 'drop_column');
+            echo "<p>", sprintf($lang['strconfdropcolumn'], $misc->printVal($_REQUEST['column']),
+                    $misc->printVal($_REQUEST['table'])), "</p>\n";
                                                                
 
                        echo "<form action=\"$PHP_SELF\" method=\"post\">\n";