From 7c6a5773ee09440e987ebfa8eefa5a7e35868f08 Mon Sep 17 00:00:00 2001 From: chriskl Date: Mon, 28 Jul 2003 07:50:31 +0000 Subject: [PATCH] allow granting WITH GRANT OPTION for 7.4. More Find stuff - it's still incomplete though. --- HISTORY | 1 + classes/Misc.php | 3 +- classes/database/Postgres.php | 10 ++++- database.php | 75 ++++++++++++++++++++++++++++++++++- lang/english.php | 3 +- lang/recoded/english.php | 3 +- privileges.php | 17 ++++++-- 7 files changed, 102 insertions(+), 10 deletions(-) diff --git a/HISTORY b/HISTORY index e3371b59..70ffe33a 100644 --- a/HISTORY +++ b/HISTORY @@ -8,6 +8,7 @@ Version 3.1 * Support zero column tables * Add first & last links to nav. Double number of pages shown. * German update from Markus Bertheau +* Allow granting privileges WITH GRANT OPTION for 7.4 * Display new PostgreSQL 7.4 grant options and grantor in privileges Version 3.0 diff --git a/classes/Misc.php b/classes/Misc.php index 122d2173..91598481 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.36 2003/07/25 08:39:25 chriskl Exp $ + * $Id: Misc.php,v 1.37 2003/07/28 07:50:32 chriskl Exp $ */ class Misc { @@ -275,6 +275,7 @@ echo "{$lang['strprivileges']}\n"; } echo "{$lang['strsql']}\n"; + echo "{$lang['strfind']}\n"; echo "{$lang['stradmin']}\n"; //echo "{$lang['strexport']}\n"; echo "\n"; diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index a1e318a1..9fb06414 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.126 2003/06/21 09:54:37 chriskl Exp $ + * $Id: Postgres.php,v 1.127 2003/07/28 07:50:32 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -2039,6 +2039,7 @@ class Postgres extends BaseDB { * @param $usernames The array of usernames to grant privs to. * @param $groupnames The array of group names to grant privs to. * @param $privileges The array of privileges to grant (eg. ('SELECT', 'ALL PRIVILEGES', etc.) ) + * @param $grantoption True if has grant option, false otherwise * @return 0 success * @return -1 invalid type * @return -2 invalid entity @@ -2046,7 +2047,7 @@ class Postgres extends BaseDB { * @return -4 not granting to anything * @return -4 invalid mode */ - function setPrivileges($mode, $type, $object, $public, $usernames, $groupnames, $privileges) { + function setPrivileges($mode, $type, $object, $public, $usernames, $groupnames, $privileges, $grantoption) { $this->fieldArrayClean($usernames); $this->fieldArrayClean($groupnames); @@ -2117,6 +2118,11 @@ class Postgres extends BaseDB { } } + // Grant option + if ($this->hasGrantOption() && $mode == 'GRANT' && $grantoption) { + $sql .= ' WITH GRANT OPTION'; + } + return $this->execute($sql); } diff --git a/database.php b/database.php index 7f07fff5..f9e4fb80 100755 --- a/database.php +++ b/database.php @@ -3,7 +3,7 @@ /** * Manage schemas within a database * - * $Id: database.php,v 1.15 2003/05/19 15:08:09 chriskl Exp $ + * $Id: database.php,v 1.16 2003/07/28 07:50:31 chriskl Exp $ */ // Include application functions @@ -13,6 +13,75 @@ if (!isset($msg)) $msg = ''; $PHP_SELF = $_SERVER['PHP_SELF']; + /** + * Searches for a named database object + */ + function doFind($confirm = true, $msg = '') { + global $PHP_SELF, $data, $localData, $misc; + global $lang; + + if (!isset($_GET['term'])) $_GET['term'] = ''; + + $misc->printDatabaseNav(); + echo "

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

\n"; + $misc->printMsg($msg); + + echo "
\n"; + echo "

_maxNameLen}\" />\n"; + echo "\n"; + echo $misc->form; + echo "\n"; + echo "

\n"; + + if ($_GET['term'] != '') { + $rs = &$localData->findObject($_GET['term']); + if ($rs->recordCount() > 0) { + $curr = ''; + while (!$rs->EOF) { + if ($rs->f['type'] != $curr) { + if ($curr != '') echo "\n"; + $curr = $rs->f['type']; + echo "

"; + switch ($curr) { + case 'SCHEMA': + echo $lang['strschemas']; + break; + case 'TABLE': + echo $lang['strtables']; + break; + case 'VIEW': + echo $lang['strviews']; + break; + case 'SEQUENCE': + echo $lang['strsequences']; + break; + } + echo "

"; + echo "\n"; + } + else echo $lang['strnodata']; + } + } + /** * Allow database administration and tuning tasks */ @@ -221,6 +290,10 @@ $misc->printBody(); switch ($action) { + case 'find': + if (isset($_GET['term'])) doFind(false); + else doFind(true); + break; case 'analyze': doAdmin('analyze'); break; diff --git a/lang/english.php b/lang/english.php index 8955a1e4..c0ba682e 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.84 2003/07/28 07:14:08 chriskl Exp $ + * $Id: english.php,v 1.85 2003/07/28 07:50:32 chriskl Exp $ */ // Language and character set @@ -102,6 +102,7 @@ $lang['strcollapse'] = 'Collapse'; $lang['strexplain'] = 'Explain'; $lang['strfind'] = 'Find'; + $lang['stroptions'] = 'Options'; // Error handling $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.'; diff --git a/lang/recoded/english.php b/lang/recoded/english.php index c7f680e6..966d40d8 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.36 2003/07/28 07:14:08 chriskl Exp $ + * $Id: english.php,v 1.37 2003/07/28 07:50:32 chriskl Exp $ */ // Language and character set @@ -102,6 +102,7 @@ $lang['strcollapse'] = 'Collapse'; $lang['strexplain'] = 'Explain'; $lang['strfind'] = 'Find'; + $lang['stroptions'] = 'Options'; // Error handling $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.'; diff --git a/privileges.php b/privileges.php index fde45563..8907cf1d 100644 --- a/privileges.php +++ b/privileges.php @@ -3,7 +3,7 @@ /** * Manage privileges in a database * - * $Id: privileges.php,v 1.16 2003/07/28 07:14:08 chriskl Exp $ + * $Id: privileges.php,v 1.17 2003/07/28 07:50:31 chriskl Exp $ */ // Include application functions @@ -49,7 +49,7 @@ echo "
\n"; echo "\n"; echo "\n"; - echo "\n"; + // Grant option + if ($data->hasGrantOption()) { + echo "\n"; + echo "\n"; + } echo "
{$lang['strusers']}\n"; + echo "
{$lang['stroptions']}\n"; + echo "GRANT OPTION
\n"; + echo "
\n"; echo "\n"; @@ -102,7 +110,8 @@ } else { $status = $localData->setPrivileges(isset($_REQUEST['grant']) ? 'GRANT' : 'REVOKE', $_REQUEST['type'], $_REQUEST['object'], - isset($_REQUEST['public']), $_REQUEST['username'], $_REQUEST['groupname'], array_keys($_REQUEST['privilege'])); + isset($_REQUEST['public']), $_REQUEST['username'], $_REQUEST['groupname'], array_keys($_REQUEST['privilege']), + isset($_REQUEST['grantoption']) && isset($_REQUEST['grant'])); if ($status == 0) doDefault($lang['strgranted']); elseif ($status == -3 || $status == -4) -- 2.39.5