allow granting WITH GRANT OPTION for 7.4. More Find stuff - it's still incomplete...
authorchriskl <chriskl>
Mon, 28 Jul 2003 07:50:31 +0000 (07:50 +0000)
committerchriskl <chriskl>
Mon, 28 Jul 2003 07:50:31 +0000 (07:50 +0000)
HISTORY
classes/Misc.php
classes/database/Postgres.php
database.php
lang/english.php
lang/recoded/english.php
privileges.php

diff --git a/HISTORY b/HISTORY
index e3371b590478dea1044d9de52e315c8ac587eb60..70ffe33a275af57a69d3248dcb8cbb34e6882863 100644 (file)
--- 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
index 122d21737cb71c29aa9d7e451b79067ed231cf15..91598481f020f3645dd2879d06656024f2018a92 100644 (file)
@@ -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 {
                                echo "<td width=\"20%\"><a href=\"privileges.php?{$vars}&type=database&object=", urlencode($_REQUEST['database']), "\">{$lang['strprivileges']}</a></td>\n";
                        }
                        echo "<td width=\"20%\"><a href=\"database.php?{$vars}&action=sql\">{$lang['strsql']}</a></td>\n";
+                       echo "<td width=\"20%\"><a href=\"database.php?{$vars}&action=find\">{$lang['strfind']}</a></td>\n";
                        echo "<td width=\"20%\"><a href=\"database.php?{$vars}&action=admin\">{$lang['stradmin']}</a></td>\n";
                        //echo "<td width=\"20%\"><a href=\"database.php?{$vars}&action=export\">{$lang['strexport']}</a></td></tr>\n";
                        echo "</tr></table>\n";
index a1e318a1c18337f86eaabcc6a79b92ad3a7a7586..9fb064143d142c975d26db3e732e879dbad8d332 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.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);
        }
  
index 7f07fff5609237533b192f2b7c1891465aa055a8..f9e4fb8090b5fd76d75714f98c0e28435337e9c6 100755 (executable)
@@ -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
        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 "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strfind']}</h2>\n";
+               $misc->printMsg($msg);
+               
+               echo "<form action=\"$PHP_SELF\" method=\"get\">\n";
+               echo "<p><input name=\"term\" value=\"", htmlspecialchars($_GET['term']), 
+                       "\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" />\n";
+               echo "<input type=\"submit\" value=\"{$lang['strfind']}\" />\n";
+               echo $misc->form;
+               echo "<input type=\"hidden\" name=\"action\" value=\"find\" />\n";
+               echo "</form>\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 "</ul>\n";
+                                               $curr = $rs->f['type'];
+                                               echo "<h2>";
+                                               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 "</h2>";
+                                               echo "<ul>\n";
+                                       }
+                                       switch ($curr) {
+                                               case 'SCHEMA':                                          
+                                                       echo "<li>", htmlspecialchars($rs->f['name']), "</li>\n";
+                                                       break;
+                                               case 'TABLE':
+                                                       echo "<li><a href=\"tblproperties.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&table=", urlencode($rs->f['name']), "\">", htmlspecialchars($rs->f['name']), "</a></li>\n";
+                                                       break;
+                                               case 'VIEW':
+                                                       echo "<li><a href=\"views.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&view=", urlencode($rs->f['name']), "\">", htmlspecialchars($rs->f['name']), "</a></li>\n";
+                                                       break;
+                                               case 'SEQUENCE':
+                                                       echo "<li><a href=\"sequences.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&sequence=", urlencode($rs->f['name']), "\">", htmlspecialchars($rs->f['name']), "</a></li>\n";
+                                                       break;
+                                       }
+                                       $rs->moveNext();        
+                               }                       
+                               echo "</ul>\n";
+                       }
+                       else echo $lang['strnodata'];
+               }               
+       }
+       
        /**
         * Allow database administration and tuning tasks
         */
        $misc->printBody();
 
        switch ($action) {
+               case 'find':
+                       if (isset($_GET['term'])) doFind(false);
+                       else doFind(true);
+                       break;
                case 'analyze':
                        doAdmin('analyze');
                        break;
index 8955a1e4f94190aa96fc74cb34c882b7afa02d5d..c0ba682edb07a2a29ee2ba5f35273c2c9a7840e9 100755 (executable)
@@ -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
        $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.';
index c7f680e6593b12da8d260e8236075ebf90b13280..966d40d80d16796c7df0857936dbbac232a99942 100644 (file)
@@ -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
        $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.';
index fde45563d2775ff0eb36d7cfaf0d96f7f2219af9..8907cf1db45f3424faacbaf3f1af86fa5131f9fe 100644 (file)
@@ -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 "<form action=\"$PHP_SELF\" method=\"post\">\n";
                        echo "<table>\n";
                        echo "<tr><th class=\"data\">{$lang['strusers']}</th>\n";
-                       echo "<td class=\"data1\"><select name=\"username[]\" multiple=\"multiple\" size=\"6\">\n";
+                       echo "<td class=\"data1\"><select name=\"username[]\" multiple=\"multiple\" size=\"", min(6, $users->recordCount()), "\">\n";
                        while (!$users->EOF) {
                                $uname = htmlspecialchars($users->f[$data->uFields['uname']]);
                                echo "<option value=\"{$uname}\"",
@@ -62,7 +62,7 @@
                        echo "<input type=\"checkbox\" name=\"public\"", (isset($_REQUEST['public']) ? ' selected="selected"' : ''), " />PUBLIC\n";
                        // Only show groups if there are groups!
                        if ($groups->recordCount() > 0) {
-                               echo "<br /><select name=\"groupname[]\" multiple=\"multiple\" size=\"6\">\n";
+                               echo "<br /><select name=\"groupname[]\" multiple=\"multiple\" size=\"", min(6, $groups->recordCount()), "\">\n";
                                while (!$groups->EOF) {
                                        $gname = htmlspecialchars($groups->f[$data->grpFields['groname']]);
                                        echo "<option value=\"{$gname}\"",
                                                        isset($_REQUEST['privilege'][$v]) ? ' selected="selected"' : '', ">{$v}<br />\n";
                        }
                        echo "</td></tr>\n";
+                       // Grant option
+                       if ($data->hasGrantOption()) {
+                               echo "<tr><th class=\"data\">{$lang['stroptions']}</th>\n";
+                               echo "<td class=\"data1\">\n";
+                               echo "<input type=\"checkbox\" name=\"grantoption\"", 
+                                                       isset($_REQUEST['grantoption']) ? ' selected="selected"' : '', ">GRANT OPTION<br />\n";
+                               echo "</td></tr>\n";
+                       }
                        echo "</table>\n";
 
                        echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n";
                }
                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)