From 7c814c7f895d8377f729b8fa173e8fe3d7f45f72 Mon Sep 17 00:00:00 2001 From: chriskl Date: Sat, 10 Jul 2004 08:51:01 +0000 Subject: [PATCH] privileges on tablespaces and databases. more help links. switch tablespaces list to use new printTable() function. fix some alignment in table cells --- HISTORY | 1 + all_db.php | 7 +++- classes/database/Postgres.php | 6 +++- classes/database/Postgres71.php | 6 +++- classes/database/Postgres73.php | 5 ++- classes/database/Postgres75.php | 15 +++++++- lang/english.php | 3 +- lang/recoded/english.php | 5 +-- privileges.php | 16 +++++---- tablespaces.php | 62 ++++++++++++++++++++------------- tblproperties.php | 30 ++++++++-------- 11 files changed, 101 insertions(+), 55 deletions(-) diff --git a/HISTORY b/HISTORY index cf137e4e..f958af18 100644 --- 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 diff --git a/all_db.php b/all_db.php index d1fb96a0..7bc032a7 100644 --- a/all_db.php +++ b/all_db.php @@ -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 @@ -178,6 +178,11 @@ 'url' => "{$PHP_SELF}?action=confirm_drop&", 'vars' => array('db' => 'datname'), ), + 'privileges' => array( + 'title' => $lang['strprivileges'], + 'url' => "privileges.php?type=database&", + 'vars' => array('object' => 'datname'), + ) ); if (!$data->hasTablespaces()) unset($columns['tablespace']); diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index 8a4f0ed8..168a68d0 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -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; } diff --git a/classes/database/Postgres71.php b/classes/database/Postgres71.php index b0491add..48042285 100644 --- a/classes/database/Postgres71.php +++ b/classes/database/Postgres71.php @@ -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', diff --git a/classes/database/Postgres73.php b/classes/database/Postgres73.php index 2283c74e..e64a4f4b 100644 --- a/classes/database/Postgres73.php +++ b/classes/database/Postgres73.php @@ -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; } diff --git a/classes/database/Postgres75.php b/classes/database/Postgres75.php index df6d5ca4..f92f85a3 100755 --- a/classes/database/Postgres75.php +++ b/classes/database/Postgres75.php @@ -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; diff --git a/lang/english.php b/lang/english.php index 246bcfc6..b0e85ef7 100755 --- a/lang/english.php +++ b/lang/english.php @@ -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 @@ -617,6 +617,7 @@ $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'; diff --git a/lang/recoded/english.php b/lang/recoded/english.php index 0b4a9590..aa404fd4 100644 --- a/lang/recoded/english.php +++ b/lang/recoded/english.php @@ -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 @@ -617,7 +617,8 @@ $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'; $lang['strtimefmt'] = 'jS M, Y g:iA'; diff --git a/privileges.php b/privileges.php index 4a649947..b9fd4449 100644 --- a/privileges.php +++ b/privileges.php @@ -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 @@ -134,10 +134,6 @@ global $PHP_SELF, $lang; switch ($_REQUEST['type']) { - case 'database': - $misc->printDatabaseNav(); - $name = $_REQUEST['object']; - break; case 'table': $misc->printTableNav(); $name = $_REQUEST['object']; @@ -220,8 +216,9 @@ echo "| href}\">{$lang['strshowallsequences']}

\n"; break; case 'database': - echo "

href}&type={$_REQUEST['type']}&object=", - urlencode($_REQUEST['object']), "\">{$lang['stralterprivs']}

\n"; + echo "

{$lang['stralterprivs']}\n"; + echo "| {$lang['strshowalldatabases']}

\n"; break; case 'function': echo "

href}&type={$_REQUEST['type']}&object=", @@ -234,6 +231,11 @@ echo "| {$lang['strshowallschemas']}

\n"; break; + case 'tablespace': + echo "

{$lang['stralterprivs']}\n"; + echo "| {$lang['strshowalltablespaces']}

\n"; + break; } echo "

\n"; } diff --git a/tablespaces.php b/tablespaces.php index 7ea1487f..7e58f778 100755 --- a/tablespaces.php +++ b/tablespaces.php @@ -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 @@ -182,30 +182,44 @@ $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 "\n"; - echo ""; - echo "\n"; - $i = 0; - while (!$tablespaces->EOF) { - $id = (($i % 2) == 0 ? '1' : '2'); - echo "\n\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\t\n"; - echo "\n"; - $tablespaces->moveNext(); - $i++; - } - echo "
{$lang['strname']}{$lang['strowner']}{$lang['strlocation']}{$lang['stractions']}
", $misc->printVal($tablespaces->f['spcname']), "", $misc->printVal($tablespaces->f['spcowner']), "", $misc->printVal($tablespaces->f['spclocation']), "f['spcname']), "\">{$lang['stralter']}f['spcname']), "\">{$lang['strdrop']}
\n"; - } - else { - echo "

{$lang['strnotablespaces']}

\n"; - } + $actions = array( + 'alter' => array( + 'title' => $lang['stralter'], + 'url' => "{$PHP_SELF}?action=edit&", + 'vars' => array('spcname' => 'spcname') + ), + 'drop' => array( + 'title' => $lang['strdrop'], + 'url' => "{$PHP_SELF}?action=confirm_drop&", + 'vars' => array('spcname' => 'spcname') + ), + 'privileges' => array( + 'title' => $lang['strprivileges'], + 'url' => "privileges.php?type=tablespace&", + 'vars' => array('object' => 'spcname') + ) + ); + + $misc->printTable($tablespaces, $columns, $actions, $lang['strnotablespaces']); echo "

{$lang['strcreatetablespace']}

\n"; diff --git a/tblproperties.php b/tblproperties.php index 1c382b4d..5076b4d6 100644 --- a/tblproperties.php +++ b/tblproperties.php @@ -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 "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['stralter']}

\n"; + $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), $lang['stralter']), 'alter_table'); $misc->printMsg($msg); // Fetch table info @@ -60,12 +60,12 @@ echo "
\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "\n"; if ($data->hasAlterTableOwner() && $data->isSuperUser($_SESSION['webdbUsername'])) { - echo "\n"; + echo "\n"; echo "\n"; } - echo "\n"; + echo "\n"; echo "\n"; @@ -98,7 +98,7 @@ $hasID = $data->hasObjectID($_REQUEST['table']); $misc->printTableNav(); - echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strexport']}

\n"; + $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), $lang['strexport'])); $misc->printMsg($msg); echo "\n"; @@ -152,7 +152,7 @@ global $PHP_SELF, $lang; $misc->printTableNav(); - echo "

", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['strimport']}

\n"; + $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), $lang['strimport'])); $misc->printMsg($msg); // Check that file uploads are enabled @@ -209,8 +209,7 @@ // Fetch all available types $types = &$data->getTypes(true, false, true); - echo "

", $misc->printVal($_REQUEST['database']), ": ", - $misc->printVal($_REQUEST['table']), ": {$lang['straddcolumn']}

\n"; + $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), $lang['straddcolumn']), 'add_column'); $misc->printMsg($msg); echo "\n"; @@ -306,8 +305,8 @@ case 1: global $lang; - echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: {$lang['straltercolumn']}: ", - $misc->printVal($_REQUEST['column']), "

\n"; + $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), + $lang['straltercolumn'], $misc->printVal($_REQUEST['column'])), 'alter_column'); $misc->printMsg($msg); echo "\n"; @@ -453,11 +452,10 @@ global $PHP_SELF, $lang; if ($confirm) { - echo "

", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: ", - $misc->printVal($_REQUEST['table']), ": " , $misc->printVal($_REQUEST['column']), ": {$lang['strdrop']}

\n"; - - echo "

", sprintf($lang['strconfdropcolumn'], $misc->printVal($_REQUEST['column']), - $misc->printVal($_REQUEST['table'])), "

\n"; + $misc->printTitle(array($misc->printVal($_REQUEST['database']), $misc->printVal($_REQUEST['table']), + $misc->printVal($_REQUEST['column']), $lang['strdrop']), 'drop_column'); + echo "

", sprintf($lang['strconfdropcolumn'], $misc->printVal($_REQUEST['column']), + $misc->printVal($_REQUEST['table'])), "

\n"; echo "\n"; -- 2.39.5
{$lang['strname']}
{$lang['strname']}"; echo "_maxNameLen}\" value=\"", htmlspecialchars($_POST['name']), "\" />
{$lang['strowner']}
{$lang['strowner']}
{$lang['strcomment']}
{$lang['strcomment']}"; echo "