support grant option and grantor for 7.4, also a bit of new find featurediff
authorchriskl <chriskl>
Mon, 28 Jul 2003 07:14:08 +0000 (07:14 +0000)
committerchriskl <chriskl>
Mon, 28 Jul 2003 07:14:08 +0000 (07:14 +0000)
HISTORY
classes/database/Postgres73.php
lang/english.php
lang/recoded/english.php
privileges.php

diff --git a/HISTORY b/HISTORY
index c1e0c23dcab34b300b64a049570d9148943332ce..e3371b590478dea1044d9de52e315c8ac587eb60 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
+* Display new PostgreSQL 7.4 grant options and grantor in privileges
 
 Version 3.0
 -----------
index 04ba5e6dc6601a3b80d151c646fe2d8979700853..8e518384731b87880ce9fa9f7615045d2a5ce50c 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.48 2003/06/21 09:54:37 chriskl Exp $
+ * $Id: Postgres73.php,v 1.49 2003/07/28 07:14:08 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -879,8 +879,8 @@ class Postgres73 extends Postgres72 {
                        list ($entity, $chars) = explode('=', $v);
                        
                        // New row to be added to $temp
-                       // (type, grantee, privilegs, grantor, grant option
-                       $row = array($atype, $entity, array(), '', false);
+                       // (type, grantee, privileges, grantor, grant option?
+                       $row = array($atype, $entity, array(), '', array());
 
                        // Loop over chars and add privs to $row
                        for ($i = 0; $i < strlen($chars); $i++) {
@@ -888,15 +888,17 @@ class Postgres73 extends Postgres72 {
                                // the privilege
                                $char = substr($chars, $i, 1);
                                if ($char == '*')
-                                       $row[4] = true;
+                                       $row[4][] = $this->privmap[substr($chars, $i - 1, 1)];
                                elseif ($char == '/') {
-                                       $row[5] = substr($chars, $i + 1);
+                                       $row[3] = substr($chars, $i + 1);
                                        break;
                                }
-                               if (!isset($this->privmap[$char]))
-                                       return -3;
-                               else
-                                       $row[2][] = $this->privmap[$char];
+                               else {
+                                       if (!isset($this->privmap[$char]))
+                                               return -3;
+                                       else
+                                               $row[2][] = $this->privmap[$char];
+                               }
                        }
                        
                        // Append row to temp
@@ -906,6 +908,30 @@ class Postgres73 extends Postgres72 {
                return $temp;
        }
        
+       // Find object functions
+       
+       /**
+        * Searches all system catalogs to find objects that match a certain name.
+        * @param $term The search term
+        * @return A recordset
+        */
+       function findObject($term) {
+               // Escape search term for LIKE match
+               $term = str_replace('_', '\\_', $term);
+               $term = str_replace('%', '\\%', $term);
+               $this->clean($term);
+               
+               $sql = "
+                       SELECT 'SCHEMA' AS type, NULL AS schemaname, nspname AS name FROM pg_catalog.pg_namespace WHERE nspname ILIKE '%{$term}%'
+                       UNION ALL
+                       SELECT CASE WHEN relkind='r' THEN 'TABLE' WHEN relkind='v' THEN 'VIEW' WHEN relkind='S' THEN 'SEQUENCE' END, 
+                               pn.nspname, pc.relname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn 
+                               WHERE pc.relnamespace=pn.oid AND relkind IN ('r', 'v', 'S') AND relname ILIKE '%{$term}%'
+                       ORDER BY type, name";
+                       
+               return $this->selectSet($sql);
+       }       
+       
        // Capabilities
        function hasSchemas() { return true; }
        function hasConversions() { return true; }
index ab5d8a91bf0db77583c9b9068bf091820e8dd8d9..8955a1e4f94190aa96fc74cb34c882b7afa02d5d 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.83 2003/07/25 08:39:25 chriskl Exp $
+        * $Id: english.php,v 1.84 2003/07/28 07:14:08 chriskl Exp $
         */
 
        // Language and character set
        $lang['strexpand'] = 'Expand';
        $lang['strcollapse'] = 'Collapse';
        $lang['strexplain'] = 'Explain';
+       $lang['strfind'] = 'Find';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strgroupdroppedbad'] = 'Group drop failed.';
        $lang['strmembers'] = 'Members';
 
-       // Privilges
+       // Privileges
        $lang['strprivilege'] = 'Privilege';
        $lang['strprivileges'] = 'Privileges';
        $lang['strnoprivileges'] = 'This object has default owner privileges.';
        $lang['strgrantfailed'] = 'Failed to change privileges.';
        $lang['strgrantbad'] = 'You must specify at least one user or group and at least one privilege.';
        $lang['stralterprivs'] = 'Alter Privileges';
+       $lang['strgrantor'] = 'Grantor';
+       $lang['strasterisk'] = '*';
 
        // Databases
        $lang['strdatabase'] = 'Database';
index 09e891e5db12e888ae8b5c9f5007d4ceffc7c532..c7f680e6593b12da8d260e8236075ebf90b13280 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.35 2003/07/25 08:39:25 chriskl Exp $
+        * $Id: english.php,v 1.36 2003/07/28 07:14:08 chriskl Exp $
         */
 
        // Language and character set
        $lang['strexpand'] = 'Expand';
        $lang['strcollapse'] = 'Collapse';
        $lang['strexplain'] = 'Explain';
+       $lang['strfind'] = 'Find';
 
        // Error handling
        $lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
        $lang['strgroupdroppedbad'] = 'Group drop failed.';
        $lang['strmembers'] = 'Members';
 
-       // Privilges
+       // Privileges
        $lang['strprivilege'] = 'Privilege';
        $lang['strprivileges'] = 'Privileges';
        $lang['strnoprivileges'] = 'This object has default owner privileges.';
        $lang['strgrantfailed'] = 'Failed to change privileges.';
        $lang['strgrantbad'] = 'You must specify at least one user or group and at least one privilege.';
        $lang['stralterprivs'] = 'Alter Privileges';
+       $lang['strgrantor'] = 'Grantor';
+       $lang['strasterisk'] = '*';
 
        // Databases
        $lang['strdatabase'] = 'Database';
index 81cd31e0421e86e94d7e20fd049635e1a38b0777..fde45563d2775ff0eb36d7cfaf0d96f7f2219af9 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Manage privileges in a database
         *
-        * $Id: privileges.php,v 1.15 2003/06/01 11:53:45 chriskl Exp $
+        * $Id: privileges.php,v 1.16 2003/07/28 07:14:08 chriskl Exp $
         */
 
        // Include application functions
                                echo "<th class=\"data\">{$v2}</th>\n";
                        }
                        if ($data->hasGrantOption()) {
-                               echo "<th class=\"data\">Grant Option?</th><th class=\"data\">Grantor</th>";
+                               echo "<th class=\"data\">{$lang['strgrantor']}</th>";
                        }
                        echo "</tr>\n";
 
                                foreach ($data->privlist[$_REQUEST['type']] as $v2) {
                                        // Skip over ALL PRIVILEGES
                                        if ($v2 == 'ALL PRIVILEGES') continue;
+                                       echo "<td class=\"data{$id}\">";
                                        if (in_array($v2, $v[2]))
-                                               echo "<td class=\"data{$id}\">{$lang['stryes']}</td>\n";
+                                               echo $lang['stryes'];
                                        else
-                                               echo "<td class=\"data{$id}\">{$lang['strno']}</td>\n";
+                                               echo $lang['strno'];
+                                       // If we have grant option for this, end mark
+                                       if ($data->hasGrantOption() && in_array($v2, $v[4])) echo $lang['strasterisk'];
+                                       echo "</td>\n";
                                }
                                if ($data->hasGrantOption()) {
-                                       echo "<td class=\"data{$id}\">", ($v[3]) ? $lang['stryes'] : $lang['strno'], "</td>\n";
-                                       echo "<td class=\"data{$id}\">", $misc->printVal($v[4]), "</td>\n";
+                                       echo "<td class=\"data{$id}\">", $misc->printVal($v[3]), "</td>\n";
                                }
                                echo "</tr>\n";
                                $i++;