backport 3.0.1 bug fixes REL_3-0 REL_3-0-1
authorchriskl <chriskl>
Wed, 13 Aug 2003 03:58:25 +0000 (03:58 +0000)
committerchriskl <chriskl>
Wed, 13 Aug 2003 03:58:25 +0000 (03:58 +0000)
13 files changed:
HISTORY
classes/database/ADODB_base.php
classes/database/Postgres.php
classes/database/Postgres71.php
classes/database/Postgres73.php
classes/database/Postgres74.php
constraints.php
indexes.php
libraries/lib.inc.php
rules.php
tblexport.php
tblproperties.php
triggers.php

diff --git a/HISTORY b/HISTORY
index 0d33c78d9807d57b2a44ffd5e72ed81027ea047d..073973c41f4cb9fb592971a548667476cf1ece28 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -1,39 +1,16 @@
 phpPgAdmin History
 ------------------
 
-Version 3.1
------------
+Version 3.0.1
+-------------
 
-Features:
-* Turkish update from Devrim Gunduz
-* 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
-* Allow revoking GRANT OPTION with CASCADE option for 7.4
-* Display new PostgreSQL 7.4 grant options and grantor in privileges
-* Find object feature
-* Support for domains in 7.3 and domain constraints and alter domain in 7.4
-* Add/drop users to/from groups
-* Alter (rename) triggers
-* Pop-up SQL window from Mark Gibson
-* Superusers can always see all databases
-* Default database encoding for languages
-* Convert our images to PNG format
-* Allow creating tables WITHOUT OIDS
-* Show boolean values as TRUE or FALSE when viewing data
-* Allow renaming table and changing table owner
-* Refresh feature on table browse
-* Support better formatted view dumps in 7.4
-* When browsing data, numeric types are aligned right
-* Ability to create unique and partial indexes
-
-Bug Fixes:
+Bug Fixes
 * Lots of NULL value in table dump fixes (XML format changed slightly)
-* Boolean default values and general boolean field handling fixes
 * Support zero column tables
 * Correctly display the contents of bytea fields
-* Consider information_schema to be a system object
-* Remember fields if index creation fails
+* Error in ADODB_base.php
+* Fix saving and loading function volatility
+* Don't list domains under types
 
 Version 3.0
 -----------
index 6993ed8823e2ef306fcfedf34e18d4a7a1a47e91..ff092a4f4d86cf7d553bcfb0fd4366fef01ef121 100644 (file)
@@ -3,7 +3,7 @@
 /*
  * Parent class of all ADODB objects.
  *
- * $Id: ADODB_base.php,v 1.14 2003/07/31 01:17:05 chriskl Exp $
+ * $Id: ADODB_base.php,v 1.13.2.1 2003/08/13 03:58:25 chriskl Exp $
  */
 
 include_once('libraries/errorhandler.inc.php');
index cc4e19f946e039c69c3fd5283d228b7a7dc39d80..81cd5cc5f608dca2e568209c1cbdd08f04a6ef0c 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.138 2003/08/12 08:18:54 chriskl Exp $
+ * $Id: Postgres.php,v 1.126.2.1 2003/08/13 03:58:25 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -200,7 +200,7 @@ class Postgres extends BaseDB {
        function &getDatabases() {
                global $conf;
 
-               if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser($_SESSION['webdbUsername'])) {
+               if (isset($conf['owned_only']) && $conf['owned_only']) {
                        $username = $_SESSION['webdbUsername'];
                        $this->clean($username);
                        $clause = " AND pu.usename='{$username}'";
@@ -348,20 +348,11 @@ class Postgres extends BaseDB {
                        case 'bool':
                        case 'boolean':
                                if ($value !== null && $value == '') $value = null;
-                               elseif ($value == 'true') $value = 't';
-                               elseif ($value == 'false') $value = 'f';
-                               
-                               // If value is null, 't' or 'f'...
-                               if ($value === null || $value == 't' || $value == 'f') {
-                                       echo "<select name=\"", htmlspecialchars($name), "\">\n";
-                                       echo "<option value=\"\"", ($value === null) ? ' selected' : '', "></option>\n";
-                                       echo "<option value=\"t\"", ($value == 't') ? ' selected' : '', ">{$lang['strtrue']}</option>\n";
-                                       echo "<option value=\"f\"", ($value == 'f') ? ' selected' : '', ">{$lang['strfalse']}</option>\n";
-                                       echo "</select>\n";
-                               }
-                               else {
-                                       echo "<input name=\"", htmlspecialchars($name), "\" value=\"", htmlspecialchars($value), "\" size=\"35\" />\n";
-                               }                               
+                               echo "<select name=\"", htmlspecialchars($name), "\">\n";
+                               echo "<option value=\"\"", ($value === null) ? ' selected' : '', "></option>\n";
+                               echo "<option value=\"t\"", ($value == 't') ? ' selected' : '', ">{$lang['strtrue']}</option>\n";
+                               echo "<option value=\"f\"", ($value == 'f') ? ' selected' : '', ">{$lang['strfalse']}</option>\n";
+                               echo "</select>\n";
                                break;
                        case 'text':
                        case 'bytea':
@@ -393,10 +384,8 @@ class Postgres extends BaseDB {
                                        return 'TRUE';
                                elseif ($value == 'f')
                                        return 'FALSE';
-                               elseif ($value == '')
-                                       return 'NULL';
                                else
-                                       return $value;
+                                       return "''";
                                break;          
                        default:
                                // Checking variable fields is difficult as there might be a size
@@ -490,18 +479,6 @@ class Postgres extends BaseDB {
 
        // Table functions
 
-       /**
-        * Returns table information
-        * @param $table The name of the table
-        * @return A recordset
-        */
-       function &getTable($table) {
-               $this->clean($table);
-               
-               $sql = "SELECT tablename, tableowner FROM pg_tables WHERE tablename='{$table}'";
-               return $this->selectSet($sql);
-       }
-
        /**
         * Return all tables in current database
         * @return All tables, sorted alphabetically 
@@ -621,14 +598,13 @@ class Postgres extends BaseDB {
         * @param $length An array of field lengths
         * @param $notnull An array of not null
         * @param $default An array of default values
-        * @param $withoutoids True if WITHOUT OIDS, false otherwise
         * @return 0 success
         * @return -1 no fields supplied
         */
-       function createTable($name, $fields, $field, $type, $length, $notnull, $default, $withoutoids) {
+       function createTable($name, $fields, $field, $type, $length, $notnull, $default) {
                // @@ NOTE: $default field not being cleaned - how on earth DO we clean it??
                $this->fieldClean($name);
-
+       
                $found = false;
                $sql = "CREATE TABLE \"{$name}\" (";
                
@@ -673,57 +649,8 @@ class Postgres extends BaseDB {
                
                $sql .= ")";
                
-               // WITHOUT OIDS
-               if ($this->hasWithoutOIDs() && $withoutoids)
-                       $sql .= ' WITHOUT OIDS';
-               
                return $this->execute($sql);
        }       
-
-       /**
-        * Alters a table
-        * @param $table The name of the table
-        * @param $name The new name for the table
-        * @param $owner The new owner for the table     
-        * @return 0 success
-        * @return -1 transaction error
-        * @return -2 owner error
-        * @return -3 rename error
-        */
-       function alterTable($table, $name, $owner) {
-               $this->fieldClean($table);
-               $this->fieldClean($name);
-               $this->fieldClean($owner);
-
-               $status = $this->beginTransaction();
-               if ($status != 0) {
-                       $this->rollbackTransaction();
-                       return -1;
-               }
-               
-               // Owner
-               if ($this->hasAlterTableOwner() && $owner != '') {
-                       $sql = "ALTER TABLE \"{$table}\" OWNER TO \"{$owner}\"";
-       
-                       $status = $this->execute($sql);
-                       if ($status != 0) {
-                               $this->rollbackTransaction();
-                               return -2;
-                       }
-               }
-
-               // Rename (only if name has changed)
-               if ($name != $table) {
-                       $sql = "ALTER TABLE \"{$table}\" RENAME TO \"{$name}\"";
-                       $status = $this->execute($sql);
-                       if ($status != 0) {
-                               $this->rollbackTransaction();
-                               return -3;
-                       }
-               }
-                               
-               return $this->endTransaction();
-       }
        
        /**
         * Removes a table from the database
@@ -1349,23 +1276,16 @@ class Postgres extends BaseDB {
         * @param $table The table on which to add the index
         * @param $columns An array of columns that form the index
         * @param $type The index type
-        * @param $unique True if unique, false otherwise
-        * @param $where Index predicate ('' for none)
         * @return 0 success
         */
-       function createIndex($name, $table, $columns, $type, $unique, $where) {
+       function createIndex($name, $table, $columns, $type) {
                $this->fieldClean($name);
                $this->fieldClean($table);
                $this->arrayClean($columns);
 
-               $sql = "CREATE";
-               if ($unique) $sql .= " UNIQUE";
-               $sql .= " INDEX \"{$name}\" ON \"{$table}\" USING {$type} ";
+               $sql = "CREATE INDEX \"{$name}\" ON \"{$table}\" USING {$type} ";
                $sql .= "(\"" . implode('","', $columns) . "\")";
-
-               if ($this->hasPartialIndexes() && trim($where) != '') {
-                       $sql .= " WHERE ({$where})";
-               }
+                       
 
                return $this->execute($sql);
        }
@@ -1722,9 +1642,9 @@ class Postgres extends BaseDB {
        }
 
        /**
-        * Return users in a specific group
+        * Return information about a specific group
         * @param $groname The name of the group
-        * @return All users in the group
+        * @return All groups
         */
        function &getGroup($groname) {
                $this->clean($groname);
@@ -1744,6 +1664,7 @@ class Postgres extends BaseDB {
                return $this->selectSet($sql);
        }
 
+       
        /**
         * Creates a new group
         * @param $groname The name of the group
@@ -1775,36 +1696,6 @@ class Postgres extends BaseDB {
                
                return $this->execute($sql);
        }
-
-       /**
-        * Adds a group member
-        * @param $groname The name of the group
-        * @param $user The name of the user to add to the group
-        * @return 0 success
-        */
-       function addGroupMember($groname, $user) {
-               $this->fieldClean($groname);
-               $this->fieldClean($user);
-               
-               $sql = "ALTER GROUP \"{$groname}\" ADD USER \"{$user}\"";
-
-               return $this->execute($sql);
-       }
-       
-       /**
-        * Removes a group member
-        * @param $groname The name of the group
-        * @param $user The name of the user to remove from the group
-        * @return 0 success
-        */
-       function dropGroupMember($groname, $user) {
-               $this->fieldClean($groname);
-               $this->fieldClean($user);
-               
-               $sql = "ALTER GROUP \"{$groname}\" DROP USER \"{$user}\"";
-
-               return $this->execute($sql);
-       }
        
        // Type functions
 
@@ -2015,7 +1906,7 @@ class Postgres extends BaseDB {
 
                return $this->selectSet($sql);
        }
-       
+
        /**
         * Creates a trigger
         * @param $tgname The name of the trigger to create
@@ -2059,50 +1950,47 @@ class Postgres extends BaseDB {
        // Privilege functions
 
        /**
-        * Internal function used for parsing ACLs
-        * @param $acl The ACL to parse (of type aclitem[])
+        * Grabs an array of users and their privileges for an object,
+        * given its type.
+        * @param $object The name of the object whose privileges are to be retrieved
+        * @param $type The type of the object (eg. relation, view or sequence)
         * @return Privileges array
+        * @return -1 invalid type
+        * @return -2 object not found
+        * @return -3 unknown privilege type
         */
-       function _parseACL($acl) {
+       function getPrivileges($object, $type) {
+               $this->clean($object);
+
+               switch ($type) {
+                       case 'table':
+                       case 'view':
+                       case 'sequence':
+                               $sql = "SELECT relacl AS acl FROM pg_class WHERE relname='{$object}'";
+                               break;
+                       default:
+                               return -1;
+               }
+
+               // Fetch the ACL for object
+               $acl = $this->selectField($sql, 'acl');
+               if ($acl == -1) return -2;
+               elseif ($acl == '') return array();
+
                // Take off the first and last characters (the braces)
                $acl = substr($acl, 1, strlen($acl) - 2);
 
-               // Pick out individual ACE's by carefully parsing.  This is necessary in order
-               // to cope with usernames and stuff that contain commas
-               $aces = array();
-               $i = $j = 0;            
-               $in_quotes = false;
-               while ($i < strlen($acl)) {
-                       // If current char is a double quote and it's not escaped, then
-                       // enter quoted bit
-                       $char = substr($acl, $i, 1);
-                       if ($char == '"' && ($i == 0 || substr($acl, $i - 1, 1) != '\\')) 
-                               $in_quotes = !$in_quotes;
-                       elseif ($char == ',' && !$in_quotes) {
-                               // Add text so far to the array
-                               $aces[] = substr($acl, $j, $i - $j);
-                               $j = $i + 1;
-                       }
-                       $i++;
-               }
-               // Add final text to the array
-               $aces[] = substr($acl, $j);
+               // Pick out individual ACE's by exploding on the comma
+               $aces = explode(',', $acl);
 
                // Create the array to be returned
                $temp = array();
 
                // For each ACE, generate an entry in $temp
                foreach ($aces as $v) {
-                       
                        // If the ACE begins with a double quote, strip them off both ends
-                       // and unescape backslashes and double quotes
-                       $unquote = false;
-                       if (strpos($v, '"') === 0) {
-                               $v = substr($v, 1, strlen($v) - 2);
-                               $v = str_replace('\\"', '"', $v);
-                               $v = str_replace('\\\\', '\\', $v);
-                       }
-                       
+                       if (strpos($v, '"') === 0) $v = substr($v, 1, strlen($v) - 2);
+
                        // Figure out type of ACE (public, user or group)
                        if (strpos($v, '=') === 0)
                                $atype = 'public';
@@ -2114,41 +2002,12 @@ class Postgres extends BaseDB {
                        else
                                $atype = 'user';
 
-                       // Break on unquoted equals sign...
-                       $i = 0;         
-                       $in_quotes = false;
-                       $entity = null;
-                       $chars = null;  
-                       while ($i < strlen($v)) {
-                               // If current char is a double quote and it's not escaped, then
-                               // enter quoted bit
-                               $char = substr($v, $i, 1);
-                               $next_char = substr($v, $i + 1, 1);
-                               if ($char == '"' && ($i == 0 || $next_char != '"')) {
-                                       $in_quotes = !$in_quotes;
-                               }
-                               // Skip over escaped double quotes
-                               elseif ($char == '"' && $next_char == '"') {
-                                       $i++;
-                               }
-                               elseif ($char == '=' && !$in_quotes) {
-                                       // Split on current equals sign                                 
-                                       $entity = substr($v, 0, $i);
-                                       $chars = substr($v, $i + 1);
-                                       break;
-                               }
-                               $i++;
-                       }
-                       
-                       // Check for quoting on entity name, and unescape if necessary
-                       if (strpos($entity, '"') === 0) {
-                               $entity = substr($entity, 1, strlen($entity) - 2);
-                               $entity = str_replace('""', '"', $entity);
-                       }
+                       // Separate entity from character list
+                       list ($entity, $chars) = explode('=', $v);
                        
                        // New row to be added to $temp
-                       // (type, grantee, privileges, grantor, grant option?
-                       $row = array($atype, $entity, array(), '', array());
+                       // (type, grantee, privilegs, grantor, grant option
+                       $row = array($atype, $entity, array(), '', false);
 
                        // Loop over chars and add privs to $row
                        for ($i = 0; $i < strlen($chars); $i++) {
@@ -2156,23 +2015,15 @@ class Postgres extends BaseDB {
                                // the privilege
                                $char = substr($chars, $i, 1);
                                if ($char == '*')
-                                       $row[4][] = $this->privmap[substr($chars, $i - 1, 1)];
+                                       $row[4] = true;
                                elseif ($char == '/') {
-                                       $grantor = substr($chars, $i + 1);
-                                       // Check for quoting
-                                       if (strpos($grantor, '"') === 0) {
-                                               $grantor = substr($grantor, 1, strlen($grantor) - 2);
-                                               $grantor = str_replace('""', '"', $grantor);
-                                       }
-                                       $row[3] = $grantor;
+                                       $row[5] = substr($chars, $i + 1);
                                        break;
                                }
-                               else {
-                                       if (!isset($this->privmap[$char]))
-                                               return -3;
-                                       else
-                                               $row[2][] = $this->privmap[$char];
-                               }
+                               if (!isset($this->privmap[$char]))
+                                       return -3;
+                               else
+                                       $row[2][] = $this->privmap[$char];
                        }
                        
                        // Append row to temp
@@ -2182,36 +2033,6 @@ class Postgres extends BaseDB {
                return $temp;
        }
        
-       /**
-        * Grabs an array of users and their privileges for an object,
-        * given its type.
-        * @param $object The name of the object whose privileges are to be retrieved
-        * @param $type The type of the object (eg. relation, view or sequence)
-        * @return Privileges array
-        * @return -1 invalid type
-        * @return -2 object not found
-        * @return -3 unknown privilege type
-        */
-       function getPrivileges($object, $type) {
-               $this->clean($object);
-
-               switch ($type) {
-                       case 'table':
-                       case 'view':
-                       case 'sequence':
-                               $sql = "SELECT relacl AS acl FROM pg_class WHERE relname='{$object}'";
-                               break;
-                       default:
-                               return -1;
-               }
-
-               // Fetch the ACL for object
-               $acl = $this->selectField($sql, 'acl');
-               if ($acl == -1) return -2;
-               elseif ($acl == '' || $acl == null) return array();
-               else return $this->_parseACL($acl);
-       }
-       
        /**
         * Grants a privilege to a user, group or public
         * @param $mode 'GRANT' or 'REVOKE';
@@ -2221,8 +2042,6 @@ 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
-        * @param $cascade True for cascade revoke, false otherwise
         * @return 0 success
         * @return -1 invalid type
         * @return -2 invalid entity
@@ -2230,7 +2049,7 @@ class Postgres extends BaseDB {
         * @return -4 not granting to anything
         * @return -4 invalid mode
         */
-       function setPrivileges($mode, $type, $object, $public, $usernames, $groupnames, $privileges, $grantoption, $cascade) {
+       function setPrivileges($mode, $type, $object, $public, $usernames, $groupnames, $privileges) {
                $this->fieldArrayClean($usernames);
                $this->fieldArrayClean($groupnames);
 
@@ -2240,17 +2059,10 @@ class Postgres extends BaseDB {
                        (!$public && sizeof($usernames) == 0 && sizeof($groupnames) == 0)) return -4;
                if ($mode != 'GRANT' && $mode != 'REVOKE') return -5;
 
-               $sql = $mode;
-
-               // Grant option
-               if ($this->hasGrantOption() && $mode == 'REVOKE' && $grantoption) {
-                       $sql .= ' GRANT OPTION FOR';
-               }               
-
                if (in_array('ALL PRIVILEGES', $privileges))
-                       $sql .= " ALL PRIVILEGES ON";
+                       $sql = "{$mode} ALL PRIVILEGES ON";
                else
-                       $sql .= " " . join(', ', $privileges) . " ON";
+                       $sql = "{$mode} " . join(', ', $privileges) . " ON";
                switch ($type) {
                        case 'table':
                        case 'view':
@@ -2308,16 +2120,6 @@ class Postgres extends BaseDB {
                        }
                }                       
 
-               // Grant option
-               if ($this->hasGrantOption() && $mode == 'GRANT' && $grantoption) {
-                       $sql .= ' WITH GRANT OPTION';
-               }
-               
-               // Cascade revoke
-               if ($this->hasGrantOption() && $mode == 'REVOKE' && $cascade) {
-                       $sql .= ' CASCADE';
-               }
-
                return $this->execute($sql);
        }
  
@@ -2521,7 +2323,6 @@ class Postgres extends BaseDB {
                $temp = array();
 
                // Cachable
-               $f['proiscachable'] = $this->phpBool($f['proiscachable']);
                if ($f['proiscachable'])
                        $temp[] = 'ISCACHABLE';
                else
index f39a5215b3adad77c5751de766ace41bb93a40bf..dc5e0df3c011a6193be61beab4e0a234987e153b 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.37 2003/08/06 07:04:45 chriskl Exp $
+ * $Id: Postgres71.php,v 1.35.2.1 2003/08/13 03:58:26 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -78,7 +78,7 @@ class Postgres71 extends Postgres {
        function &getDatabases() {
                global $conf;
 
-               if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser($_SESSION['webdbUsername'])) {
+               if (isset($conf['owned_only']) && $conf['owned_only']) {
                        $username = $_SESSION['webdbUsername'];
                        $this->clean($username);
                        $clause = " AND pu.usename='{$username}'";
@@ -305,7 +305,6 @@ class Postgres71 extends Postgres {
        function hasAggregates() { return true; }
        function hasRules() { return true; }
        function hasSchemas() { return false; }
-       function hasAlterTableOwner() { return true; }
 
 }
 
index 00b1b28b5d4b43d8e46f13f37cace30edd4f1741..0e61098b343bab21744e34e80a3cd1e0ee1618ef 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.58 2003/08/12 01:33:56 chriskl Exp $
+ * $Id: Postgres73.php,v 1.48.2.1 2003/08/13 03:58:26 chriskl Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -25,6 +25,10 @@ class Postgres73 extends Postgres72 {
        // Max object name length
        var $_maxNameLen = 63;
 
+       // System schema ids and names
+       var $_schemaOIDs = array(11, 99);
+       var $_schemaNames = array('pg_catalog', 'pg_toast');
+
        // List of all legal privileges that can be applied to different types
        // of objects.
        var $privlist = array(
@@ -98,7 +102,7 @@ class Postgres73 extends Postgres72 {
                
                if (!$conf['show_system']) $and = "AND nspname NOT LIKE 'pg_%'";
                else $and = '';
-               $sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
+               $sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_namespace pn, pg_user pu
                        WHERE pn.nspowner = pu.usesysid
                        {$and}ORDER BY nspname";
 
@@ -112,7 +116,7 @@ class Postgres73 extends Postgres72 {
         */
        function &getSchemaByName($schema) {
                $this->clean($schema);
-               $sql = "SELECT * FROM pg_catalog.pg_namespace WHERE nspname='{$schema}'";
+               $sql = "SELECT * FROM pg_namespace WHERE nspname='{$schema}'";
                return $this->selectRow($sql);
        }
 
@@ -155,7 +159,7 @@ class Postgres73 extends Postgres72 {
         * @return All conversions, sorted alphabetically
         */
        function &getConversions() {
-               $sql = "SELECT conname, conowner FROM pg_catalog.pg_conversion ORDER BY conname";
+               $sql = "SELECT conname, conowner FROM pg_conversion ORDER BY conname";
                                  
                return $this->selectSet($sql);
        }
@@ -167,7 +171,7 @@ class Postgres73 extends Postgres72 {
         */
        function &getConversionByName($conversion) {
                $this->clean($conversion);
-               $sql = "SELECT * FROM pg_catalog.pg_conversion WHERE conname='{$conversion}'";
+               $sql = "SELECT * FROM pg_conversion WHERE conname='{$conversion}'";
                return $this->selectRow($sql);
        }
 
@@ -182,8 +186,8 @@ class Postgres73 extends Postgres72 {
        function hasObjectID($table) {
                $this->clean($table);
 
-               $sql = "SELECT relhasoids FROM pg_catalog.pg_class WHERE relname='{$table}' 
-                       AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}')";
+               $sql = "SELECT relhasoids FROM pg_class WHERE relname='{$table}' 
+                       AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname='{$this->_schema}')";
 
                $rs = $this->selectSet($sql);
                if ($rs->recordCount() != 1) return -99;
@@ -210,8 +214,8 @@ class Postgres73 extends Postgres72 {
 
                if (sizeof($atts) == 0) return array();
 
-               $sql = "SELECT attnum, attname FROM pg_catalog.pg_attribute WHERE 
-                       attrelid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}'AND
+               $sql = "SELECT attnum, attname FROM pg_attribute WHERE 
+                       attrelid=(SELECT oid FROM pg_class WHERE relname='{$table}'AND
                        relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}')) 
                        AND attnum IN ('" . join("','", $atts) . "')";
 
@@ -242,8 +246,8 @@ class Postgres73 extends Postgres72 {
                $status = $this->beginTransaction();
                if ($status != 0) return -1;
                
-               $sql = "SELECT indrelid, indkey FROM pg_catalog.pg_index WHERE indisunique AND 
-                       indrelid=(SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}' AND
+               $sql = "SELECT indrelid, indkey FROM pg_index WHERE indisunique AND 
+                       indrelid=(SELECT oid FROM pg_class WHERE relname='{$table}' AND
                        relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}'))";
                $rs = $this->selectSet($sql);
 
@@ -267,26 +271,12 @@ class Postgres73 extends Postgres72 {
                }                       
        }
 
-       /**
-        * Returns table information
-        * @param $table The name of the table
-        * @return A recordset
-        */
-       function &getTable($table) {
-               $this->clean($table);
-               
-               $sql = "SELECT tablename, tableowner FROM pg_catalog.pg_tables
-                       WHERE tablename='{$table}' AND schemaname='{$this->_schema}'";
-                       
-               return $this->selectSet($sql);
-       }
-       
        /**
         * Return all tables in current database
         * @return All tables, sorted alphabetically 
         */
        function &getTables() {
-               $sql = "SELECT tablename, tableowner FROM pg_catalog.pg_tables
+               $sql = "SELECT tablename, tableowner FROM pg_tables
                        WHERE schemaname='{$this->_schema}' ORDER BY tablename";
 
                return $this->selectSet($sql);
@@ -380,7 +370,7 @@ class Postgres73 extends Postgres72 {
         * @return All views
         */
        function getViews() {
-               $sql = "SELECT viewname, viewowner FROM pg_catalog.pg_views
+               $sql = "SELECT viewname, viewowner FROM pg_views
                        WHERE schemaname='{$this->_schema}' ORDER BY viewname";
 
                return $this->selectSet($sql);
@@ -443,25 +433,6 @@ class Postgres73 extends Postgres72 {
                return $this->selectSet($sql);
        }
 
-       /**
-        * Grabs a single trigger
-        * @param $table The name of a table whose triggers to retrieve
-        * @param $trigger The name of the trigger to retrieve
-        * @return A recordset
-        */
-       function &getTrigger($table, $trigger) {
-               $this->clean($table);
-               $this->clean($trigger);
-
-               $sql = "SELECT * FROM pg_catalog.pg_trigger t, pg_catalog.pg_class c
-                                       WHERE t.tgrelid=c.oid
-                                       AND c.relname='{$table}'
-                                       AND t.tgname='{$trigger}'
-                                       AND c.relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}')";
-
-               return $this->selectSet($sql);
-       }
-
        /**
         * Grabs a list of triggers on a table
         * @param $table The name of a table whose triggers to retrieve
@@ -486,23 +457,6 @@ class Postgres73 extends Postgres72 {
 
                return $this->selectSet($sql);
        }
-       
-       /**
-        * Alters a trigger
-        * @param $table The name of the table containing the trigger
-        * @param $trigger The name of the trigger to alter
-        * @param $name The new name for the trigger
-        * @return 0 success
-        */
-       function alterTrigger($table, $trigger, $name) {
-               $this->fieldClean($table);
-               $this->fieldClean($trigger);
-               $this->fieldClean($name);
-               
-               $sql = "ALTER TRIGGER \"{$trigger}\" ON \"{$table}\" RENAME TO \"{$name}\"";
-               
-               return $this->execute($sql);
-       }       
 
        // Function functions
 
@@ -828,8 +782,8 @@ class Postgres73 extends Postgres72 {
                                        pc.oid=pi.indexrelid
                                        AND (pi.indisunique OR pi.indisprimary)
                        ) AS sub
-                       WHERE relid = (SELECT oid FROM pg_catalog.pg_class WHERE relname='{$table}'
-                                       AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace
+                       WHERE relid = (SELECT oid FROM pg_class WHERE relname='{$table}'
+                                       AND relnamespace = (SELECT oid FROM pg_namespace
                                        WHERE nspname='{$this->_schema}'))
                ";
 
@@ -873,22 +827,22 @@ class Postgres73 extends Postgres72 {
                        case 'table':
                        case 'view':
                        case 'sequence':
-                               $sql = "SELECT relacl AS acl FROM pg_catalog.pg_class WHERE relname='{$object}'
-                                               AND relnamespace=(SELECT oid FROM pg_catalog.pg_namespace WHERE nspname='{$this->_schema}')";
+                               $sql = "SELECT relacl AS acl FROM pg_class WHERE relname='{$object}'
+                                               AND relnamespace=(SELECT oid FROM pg_namespace WHERE nspname='{$this->_schema}')";
                                break;
                        case 'database':
-                               $sql = "SELECT datacl AS acl FROM pg_catalog.pg_database WHERE datname='{$object}'";
+                               $sql = "SELECT datacl AS acl FROM pg_database WHERE datname='{$object}'";
                                break;
                        case 'function':
                                // Since we fetch functions by oid, they are already constrained to
                                // the current schema.
-                               $sql = "SELECT proacl AS acl FROM pg_catalog.pg_proc WHERE oid='{$object}'";
+                               $sql = "SELECT proacl AS acl FROM pg_proc WHERE oid='{$object}'";
                                break;
                        case 'language':
-                               $sql = "SELECT lanacl AS acl FROM pg_catalog.pg_language WHERE lanname='{$object}'";
+                               $sql = "SELECT lanacl AS acl FROM pg_language WHERE lanname='{$object}'";
                                break;
                        case 'schema':
-                               $sql = "SELECT nspacl AS acl FROM pg_catalog.pg_namespace WHERE nspname='{$object}'";
+                               $sql = "SELECT nspacl AS acl FROM pg_namespace WHERE nspname='{$object}'";
                                break;
                        default:
                                return -1;
@@ -898,137 +852,62 @@ class Postgres73 extends Postgres72 {
                $acl = $this->selectField($sql, 'acl');
                if ($acl == -1) return -2;
                elseif ($acl == '' || $acl == null) return array();
-               else return $this->_parseACL($acl);
-       }
-       
-       // Domain functions
-       
-       /**
-        * Gets all information for a single domain
-        * @param $domain The name of the domain to fetch
-        * @return A recordset
-        */
-       function &getDomain($domain) {
-               $this->clean($domain);
-               
-               $sql = "
-                       SELECT
-                               t.typname AS domname, 
-                               pg_catalog.format_type(t.typbasetype, t.typtypmod) AS domtype,
-                               t.typnotnull AS domnotnull,
-                               t.typdefault AS domdef,
-                               pg_catalog.pg_get_userbyid(t.typowner) AS domowner
-                       FROM 
-                               pg_catalog.pg_type t
-                       WHERE 
-                               t.typtype = 'd'
-                               AND t.typname = '{$domain}'
-                               AND t.typnamespace = (SELECT oid FROM pg_catalog.pg_namespace
-                                       WHERE nspname = '{$this->_schema}')";
-
-               return $this->selectSet($sql);          
-       }
-       
-       /**
-        * Return all domains in current schema.  Excludes domain constraints.
-        * @return All tables, sorted alphabetically 
-        */
-       function &getDomains() {
-               $sql = "                
-                       SELECT
-                               t.typname AS domname, 
-                               pg_catalog.format_type(t.typbasetype, t.typtypmod) AS domtype,
-                               t.typnotnull AS domnotnull,
-                               t.typdefault AS domdef,
-                               pg_catalog.pg_get_userbyid(t.typowner) AS domowner
-                       FROM 
-                               pg_catalog.pg_type t
-                       WHERE 
-                               t.typtype = 'd'
-                               AND t.typnamespace = (SELECT oid FROM pg_catalog.pg_namespace
-                                       WHERE nspname='{$this->_schema}')
-                       ORDER BY t.typname";
 
-               return $this->selectSet($sql);
-       }
+               // Take off the first and last characters (the braces)
+               $acl = substr($acl, 1, strlen($acl) - 2);
 
-       /**
-        * Creates a domain
-        * @param $domain The name of the domain to create
-        * @param $type The base type for the domain
-        * @param $notnull True for NOT NULL, false otherwise
-        * @param $default Default value for domain     
-        * @param $check A CHECK constraint if there is one
-        * @return 0 success
-        */
-       function createDomain($domain, $type, $notnull, $default, $check) {
-               $this->fieldClean($domain);
-               
-               $sql = "CREATE DOMAIN \"{$domain}\" AS {$type}";
-               if ($notnull) $sql .= ' NOT NULL';
-               if ($default != '') $sql .= " DEFAULT {$default}";
-               if ($this->hasDomainConstraints() && $check != '') $sql .= " CHECK ({$check})";
-
-               return $this->execute($sql);
-       }
-       
-       /**
-        * Drops a domain.
-        * @param $domain The name of the domain to drop
-        * @param $cascade True to cascade drop, false to restrict
-        * @return 0 success
-        */
-       function dropDomain($domain, $cascade) {
-               $this->fieldClean($domain);
-
-               $sql = "DROP DOMAIN \"{$domain}\"";
-               if ($cascade) $sql .= " CASCADE";
+               // Pick out individual ACE's by exploding on the comma
+               $aces = explode(',', $acl);
 
-               return $this->execute($sql);
-       }       
-       
-       // 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) {
-               global $conf;
+               // Create the array to be returned
+               $temp = array();
 
-               // Escape search term for ILIKE match
-               $term = str_replace('_', '\\_', $term);
-               $term = str_replace('%', '\\%', $term);
-               $this->clean($term);
+               // For each ACE, generate an entry in $temp
+               foreach ($aces as $v) {
+                       // If the ACE begins with a double quote, strip them off both ends
+                       if (strpos($v, '"') === 0) $v = substr($v, 1, strlen($v) - 2);
+
+                       // Figure out type of ACE (public, user or group)
+                       if (strpos($v, '=') === 0)
+                               $atype = 'public';
+                       elseif (strpos($v, 'group ') === 0) {
+                               $atype = 'group';
+                               // Tear off 'group' prefix
+                               $v = substr($v, 6);
+                       }
+                       else
+                               $atype = 'user';
 
-               // Exclude system relations if necessary
-               if (!$conf['show_system']) $where = " AND pn.nspname NOT LIKE 'pg_%'";
-               else $where = '';
-               
-               $sql = "
-                       SELECT 'SCHEMA' AS type, oid, NULL AS schemaname, NULL AS relname, nspname AS name 
-                               FROM pg_catalog.pg_namespace pn WHERE nspname ILIKE '%{$term}%' {$where}
-                       UNION ALL
-                       SELECT CASE WHEN relkind='r' THEN 'TABLE' WHEN relkind='v' THEN 'VIEW' WHEN relkind='S' THEN 'SEQUENCE' END, pc.oid,
-                               pn.nspname, NULL, 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}%' {$where}
-                       UNION ALL
-                       SELECT 'COLUMN', NULL, pn.nspname, pc.relname, pa.attname FROM pg_catalog.pg_class pc, pg_catalog.pg_namespace pn,
-                               pg_catalog.pg_attribute pa WHERE pc.relnamespace=pn.oid AND pc.oid=pa.attrelid 
-                               AND pa.attname ILIKE '%{$term}%' {$where}
-                       UNION ALL
-                       SELECT 'FUNCTION', pp.oid, pn.nspname, NULL, pp.proname FROM pg_catalog.pg_proc pp, pg_catalog.pg_namespace pn 
-                               WHERE pp.pronamespace=pn.oid AND proname ILIKE '%{$term}%' {$where}
-                       UNION ALL
-                       SELECT 'TYPE', pt.oid, pn.nspname, NULL, pt.typname FROM pg_catalog.pg_type pt, pg_catalog.pg_namespace pn 
-                               WHERE pt.typnamespace=pn.oid AND typname ILIKE '%{$term}%'
-                               AND (pt.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = pt.typrelid))
-                               {$where}
-                       ORDER BY type, schemaname, relname, name";
+                       // Separate entity from character list
+                       list ($entity, $chars) = explode('=', $v);
                        
-               return $this->selectSet($sql);
-       }       
+                       // New row to be added to $temp
+                       // (type, grantee, privilegs, grantor, grant option
+                       $row = array($atype, $entity, array(), '', false);
+
+                       // Loop over chars and add privs to $row
+                       for ($i = 0; $i < strlen($chars); $i++) {
+                               // Append to row's privs list the string representing
+                               // the privilege
+                               $char = substr($chars, $i, 1);
+                               if ($char == '*')
+                                       $row[4] = true;
+                               elseif ($char == '/') {
+                                       $row[5] = substr($chars, $i + 1);
+                                       break;
+                               }
+                               if (!isset($this->privmap[$char]))
+                                       return -3;
+                               else
+                                       $row[2][] = $this->privmap[$char];
+                       }
+                       
+                       // Append row to temp
+                       $temp[] = $row;
+               }
+
+               return $temp;
+       }
        
        // Capabilities
        function hasSchemas() { return true; }
@@ -1036,8 +915,6 @@ class Postgres73 extends Postgres72 {
        function hasCluster() { return true; }
        function hasDropBehavior() { return true; }
        function hasDropColumn() { return true; }
-       function hasDomains() { return true; }
-       function hasAlterTrigger() { return true; }
 
 }
 
index f48d2af214b60fe3adb0501126cd20d740667df4..691a67392e5b28cea0d518dbdd16957464f87f8f 100644 (file)
@@ -4,7 +4,7 @@
  * A class that implements the DB interface for Postgres
  * Note: This class uses ADODB and returns RecordSets.
  *
- * $Id: Postgres74.php,v 1.11 2003/08/12 01:33:56 chriskl Exp $
+ * $Id: Postgres74.php,v 1.5.2.1 2003/08/13 03:58:26 chriskl Exp $
  */
 
 include_once('classes/database/Postgres73.php');
@@ -17,6 +17,10 @@ class Postgres74 extends Postgres73 {
        // Max object name length
        var $_maxNameLen = 63;
 
+       // System schema ids and names
+       var $_schemaOIDs = array(11, 99);
+       var $_schemaNames = array('pg_catalog', 'pg_toast');
+
        /**
         * Constructor
         * @param $host The hostname to connect to
@@ -28,57 +32,7 @@ class Postgres74 extends Postgres73 {
        function Postgres74($host, $port, $database, $user, $password) {
                $this->Postgres73($host, $port, $database, $user, $password);
        }
-       
-       // Group functions
-       
-       /**
-        * Return users in a specific group
-        * @param $groname The name of the group
-        * @return All users in the group
-        */
-       function &getGroup($groname) {
-               $this->clean($groname);
-
-               $sql = "SELECT s.usename FROM pg_catalog.pg_user s, pg_catalog.pg_group g 
-                                       WHERE g.groname='{$groname}' AND s.usesysid = ANY (g.grolist)
-                                       ORDER BY s.usename";
 
-               return $this->selectSet($sql);
-       }
-       
-       // Schema functions
-       
-       /**
-        * Return all schemas in the current database.  This differs from the version
-        * in 7.3 only in that it considers the information_schema to be a system schema.
-        * @return All schemas, sorted alphabetically
-        */
-       function &getSchemas() {
-               global $conf;
-               
-               if (!$conf['show_system']) $and = "AND nspname NOT LIKE 'pg_%' AND nspname != 'information_schema'";
-               else $and = '';
-               $sql = "SELECT pn.nspname, pu.usename AS nspowner FROM pg_catalog.pg_namespace pn, pg_catalog.pg_user pu
-                       WHERE pn.nspowner = pu.usesysid
-                       {$and}ORDER BY nspname";
-
-               return $this->selectSet($sql);
-       }       
-
-       // View functions
-       
-       /**
-        * Returns all details for a particular view
-        * @param $view The name of the view to retrieve
-        * @return View info
-        */
-       function &getView($view) {
-               $this->clean($view);
-               
-               $sql = "SELECT viewname, viewowner, pg_catalog.pg_get_viewdef(viewname, true) AS definition FROM pg_catalog.pg_views WHERE viewname='$view'";
-
-               return $this->selectSet($sql);
-       }       
 
        // Trigger functions
        
@@ -126,131 +80,9 @@ class Postgres74 extends Postgres73 {
 
                return $this->selectSet($sql);
        }
-       
-       // Domain functions
-       
-       /**
-        * Get domain constraints
-        * @param $domain The name of the domain whose constraints to fetch
-        * @return A recordset
-        */
-       function &getDomainConstraints($domain) {
-               $this->clean($domain);
-               
-               $sql = "
-                       SELECT
-                               conname,
-                               contype,
-                               pg_catalog.pg_get_constraintdef(oid) AS consrc
-                       FROM
-                               pg_catalog.pg_constraint
-                       WHERE
-                               contypid = (SELECT oid FROM pg_catalog.pg_type
-                                                               WHERE typname='{$domain}'
-                                                               AND typnamespace = (SELECT oid FROM pg_catalog.pg_namespace
-                                                                                                                       WHERE nspname = '{$this->_schema}'))
-                       ORDER BY
-                               conname";
-                               
-               return $this->selectSet($sql);
-       }
-       
-       /**
-        * Drop a domain constraint
-        * @param $domain The domain from which to remove the constraint
-        * @param $constraint The constraint to remove
-        * @param $cascade True to cascade, false otherwise
-        * @return 0 success
-        */
-       function dropDomainConstraint($domain, $constraint, $cascade) {
-               $this->fieldClean($domain);
-               $this->fieldClean($constraint);
-               
-               $sql = "ALTER DOMAIN \"{$domain}\" DROP CONSTRAINT \"{$constraint}\"";
-               if ($cascade) $sql .= " CASCADE";
-
-               return $this->execute($sql);
-       }
-
-       /**
-        * Adds a check constraint to a domain
-        * @param $domain The domain to which to add the check
-        * @param $definition The definition of the check
-        * @param $name (optional) The name to give the check, otherwise default name is assigned
-        * @return 0 success
-        */
-       function addDomainCheckConstraint($domain, $definition, $name = '') {
-               $this->fieldClean($domain);
-               $this->fieldClean($name);
-
-               $sql = "ALTER DOMAIN \"{$domain}\" ADD ";
-               if ($name != '') $sql .= "CONSTRAINT \"{$name}\" ";
-               $sql .= "CHECK ({$definition})";
-
-               return $this->execute($sql);
-       }
-       
-       /**
-        * Alters a domain
-        * @param $domain The domain to alter
-        * @param $domdefault The domain default
-        * @param $domnotnull True for NOT NULL, false otherwise
-        * @param $domowner The domain owner
-        * @return 0 success
-        * @return -1 transaction error
-        * @return -2 default error
-        * @return -3 not null error
-        * @return -4 owner error
-        */
-       function alterDomain($domain, $domdefault, $domnotnull, $domowner) {
-               $this->fieldClean($domain);
-               $this->fieldClean($domowner);
-               
-               $status = $this->beginTransaction();
-               if ($status != 0) {
-                       $this->rollbackTransaction();
-                       return -1;
-               }
-               
-               // Default
-               if ($domdefault == '')
-                       $sql = "ALTER DOMAIN \"{$domain}\" DROP DEFAULT";
-               else
-                       $sql = "ALTER DOMAIN \"{$domain}\" SET DEFAULT {$domdefault}";
-               
-               $status = $this->execute($sql);
-               if ($status != 0) {
-                       $this->rollbackTransaction();
-                       return -2;
-               }
-               
-               // NOT NULL
-               if ($domnotnull)
-                       $sql = "ALTER DOMAIN \"{$domain}\" SET NOT NULL";
-               else
-                       $sql = "ALTER DOMAIN \"{$domain}\" DROP NOT NULL";
-
-               $status = $this->execute($sql);
-               if ($status != 0) {
-                       $this->rollbackTransaction();
-                       return -3;
-               }
-               
-               // Owner
-               $sql = "ALTER DOMAIN \"{$domain}\" OWNER TO \"{$domowner}\"";
 
-               $status = $this->execute($sql);
-               if ($status != 0) {
-                       $this->rollbackTransaction();
-                       return -4;
-               }
-               
-               return $this->endTransaction();
-       }       
-        
        // Capabilities
        function hasGrantOption() { return true; }
-       function hasDomainConstraints() { return true; }
        
 }
 
index 486b1a1faf3e13e642ef7cd411a24056ad67d329..50142bebe6fb6960f8266a4b587df6c187f182eb 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List constraints on a table
         *
-        * $Id: constraints.php,v 1.19 2003/07/31 08:28:03 chriskl Exp $
+        * $Id: constraints.php,v 1.18.2.1 2003/08/13 03:58:25 chriskl Exp $
         */
 
        // Include application functions
index 4f39eb99b3cb40c2abf956120ab221b55ae9a439..095964437facb57ae9fc0f8f43da7ea5034f4c8b 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List indexes on a table
         *
-        * $Id: indexes.php,v 1.17 2003/08/12 08:18:53 chriskl Exp $
+        * $Id: indexes.php,v 1.14.2.1 2003/08/13 03:58:25 chriskl Exp $
         */
 
        // Include application functions
                global $PHP_SELF, $lang;
 
                if (!isset($_POST['formIndexName'])) $_POST['formIndexName'] = '';
-               if (!isset($_POST['formIndexType'])) $_POST['formIndexType'] = null;
                if (!isset($_POST['formCols'])) $_POST['formCols'] = '';
-               if (!isset($_POST['formWhere'])) $_POST['formWhere'] = '';              
 
-               echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strindexes']}: {$lang['strcreateindex']} </h2>\n";
+               echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strindexes']} : {$lang['strcreateindex']} </h2>\n";
                $misc->printMsg($msg);
 
                $attrs = &$localData->getTableAttributes($_REQUEST['table']);
                $buttonRemove->set_attribute("onclick", "buttonPressed(this);");                
                $buttonRemove->set_attribute("type", "button");
 
+               $selTypes = new XHTML_select("formIndexType");
+               $selTypes->set_data($localData->typIndexes);
+                               
                echo "<form onsubmit=\"doSelectAll();\" name=\"formIndex\" action=\"$PHP_SELF\" method=\"post\">\n";
 
 
                echo "<table>\n";
                echo "<tr><th class=\"data\" colspan=\"3\">{$lang['strindexname']}</th></tr>";
                echo "<tr>";
-               echo "<td class=\"data1\" colspan=\"3\"><input type=\"text\" name=\"formIndexName\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", 
-                       htmlspecialchars($_POST['formIndexName']), "\" /></td></tr>";
+               echo "<td class=\"data1\" colspan=\"3\"><input type=\"text\" name=\"formIndexName\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" /></td></tr>";
                echo "<tr><th class=\"data\">{$lang['strtablecolumnlist']}</th><th class=\"data\">&nbsp;</th>";
                echo "<th class=\"data\">{$lang['strindexcolumnlist']}</th></tr>\n";
                echo "<tr><td class=\"data1\">" . $selColumns->fetch() . "</td>\n";
                echo "<table> \n";
                echo "<tr>";
                echo "<th class=\"data\">{$lang['strindextype']}</th>";
-               echo "<td class=\"data1\"><select name=\"formIndexType\">";
-               foreach ($localData->typIndexes as $v) {
-                       echo "<option value=\"", htmlspecialchars($v), "\"",
-                               ($v == $_POST['formIndexType']) ? ' selected="selected"' : '', ">", htmlspecialchars($v), "</option>\n";
-               }
-               echo "</select></td></tr>\n";                           
-               echo "</tr>";
-               echo "<tr>";
-               echo "<th class=\"data\">{$lang['strunique']}</th>";
-               echo "<td class=\"data1\"><input type=\"checkbox\" name=\"formUnique\"", (isset($_POST['formUnique']) ? 'checked="checked"' : ''), " /></td>";
+               echo "<td>" . $selTypes->fetch() . "</td>";
                echo "</tr>";
-               if ($data->hasPartialIndexes()) {
-                       echo "<tr>";
-                       echo "<th class=\"data\">{$lang['strwhere']}</th>";
-                       echo "<td class=\"data1\">(<input name=\"formWhere\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", 
-                               htmlspecialchars($_POST['formWhere']), "\" />)</td>";
-                       echo "</tr>";
-               }
                echo "</table>";
+               
 
                echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create_index\" />\n";
                echo $misc->form;
                echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
                echo "<input type=\"submit\" value=\"{$lang['strcreate']}\" />\n";
-               echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
+               echo "<input type=reset value=\"{$lang['strreset']}\" /></p>\n";
                echo "</form>\n";
+               
+               echo "<p><a class=\"navlink\" href=\"$PHP_SELF?{$misc->href}&table=", urlencode($_REQUEST['table']), 
+                       "\">{$lang['strshowallindexes']}</a></p>\n";
        }
 
        /**
                global $localData;
                global $lang;
                
-               // Handle databases that don't have partial indexes
-               if (!isset($_POST['formWhere'])) $_POST['formWhere'] = '';
-               
                // Check that they've given a name and at least one column
                if ($_POST['formIndexName'] == '') doCreateIndex($lang['strindexneedsname']);
-               elseif (!isset($_POST['IndexColumnList']) || $_POST['IndexColumnList'] == '') doCreateIndex($lang['strindexneedscols']);
+               elseif ($_POST['IndexColumnList'] == '') doCreate($lang['strindexneedscols']);
                else {
-                       $status = $localData->createIndex($_POST['formIndexName'], $_POST['table'], $_POST['IndexColumnList'], 
-                               $_POST['formIndexType'], isset($_POST['formUnique']), $_POST['formWhere']);
+                       $status = $localData->createIndex($_POST['formIndexName'], $_POST['table'], $_POST['IndexColumnList'], $_POST['formIndexType']);
                        if ($status == 0)
                                doDefault($lang['strindexcreated']);
                        else
                        if ($localData->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\" /> {$lang['strcascade']}</p>\n";
                        }
-                       echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
-                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+                       echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n";
+                       echo "<input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n";
                        echo "</form>\n";
                }
                else {
        
        switch ($action) {
                case 'save_create_index':
-                       if (isset($_POST['cancel'])) doDefault();
-                       else doSaveCreateIndex();
+                       doSaveCreateIndex();
                        break;
                case 'create_index':
                        doCreateIndex();
                        break;
                case 'drop_index':
-                       if (isset($_POST['drop'])) doDropIndex(false);
+                       if (isset($_POST['yes'])) doDropIndex(false);
                        else doDefault();
                        break;
                case 'confirm_drop_index':
index 79752f65815369d35b7db5a773093165eb4488b8..0772b38d1465d9444b392c0f9e301f82a58318f2 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Function library read in upon startup
         *
-        * $Id: lib.inc.php,v 1.55 2003/08/05 06:04:36 chriskl Exp $
+        * $Id: lib.inc.php,v 1.54.2.1 2003/08/13 03:58:26 chriskl Exp $
         */
        
        // Set error reporting level to max
@@ -13,7 +13,7 @@
        $appName = 'phpPgAdmin';
 
        // Application version
-       $appVersion = '3.1-dev';
+       $appVersion = '3.0.1';
 
 
        // Check to see if the configuration file exists, if not, explain
index e9c0f8325fd84a5fd51d5f6e3803bb1790b12fae..ef1361bdfd89627341f6960cb9ce317d30513aaa 100644 (file)
--- a/rules.php
+++ b/rules.php
@@ -3,7 +3,7 @@
        /**
         * List rules on a table
         *
-        * $Id: rules.php,v 1.13 2003/07/31 08:28:03 chriskl Exp $
+        * $Id: rules.php,v 1.12.2.1 2003/08/13 03:58:25 chriskl Exp $
         */
 
        // Include application functions
index 02b4fbc4b324c8fddefabee1677c797c4c1c4fe3..3e227c24d43166e08506ce5bf82567ab409dc90f 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Does an export to the screen or as a download
         *
-        * $Id: tblexport.php,v 1.8 2003/08/03 03:14:13 chriskl Exp $
+        * $Id: tblexport.php,v 1.7.2.1 2003/08/13 03:58:25 chriskl Exp $
         */
 
        $extensions = array(
index 5844b25c47c82a37df7ea5f2a2123aa4b75a8510..11b8f62a8a759993c66762b64938e9d52249a6c1 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List tables in a database
         *
-        * $Id: tblproperties.php,v 1.19 2003/08/07 06:19:25 chriskl Exp $
+        * $Id: tblproperties.php,v 1.16.2.1 2003/08/13 03:58:25 chriskl Exp $
         */
 
        // Include application functions
        $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
        $PHP_SELF = $_SERVER['PHP_SELF'];
 
-       /** 
-        * Function to save after altering a table
-        */
-       function doSaveAlter() {
-               global $localData, $lang, $_reload_browser;
-
-               // For databases that don't allow owner change
-               if (!isset($_POST['owner'])) $_POST['owner'] = '';
-               
-               $status = $localData->alterTable($_POST['table'], $_POST['name'], $_POST['owner']);
-               if ($status == 0) {
-                       // Jump them to the new table name
-                       $_REQUEST['table'] = $_POST['name'];
-                       // Force a browser reload
-                       $_reload_browser = true;
-                       doDefault($lang['strtablealtered']);
-               }
-               else
-                       doAlter($lang['strtablealteredbad']);
-       }
-
-       /**
-        * Function to allow altering of a table
-        */
-       function doAlter($msg = '') {
-               global $data, $localData, $misc;
-               global $PHP_SELF, $lang;
-               
-               echo "<h2>", $misc->printVal($_REQUEST['database']), ": ", $misc->printVal($_REQUEST['table']), ": {$lang['stralter']}</h2>\n";
-               $misc->printMsg($msg);
-
-               // Fetch table info             
-               $table = &$localData->getTable($_REQUEST['table']);
-               // Fetch all users
-               $users = &$data->getUsers();
-               
-               if ($table->recordCount() > 0) {
-                       
-                       if (!isset($_POST['name'])) $_POST['name'] = $table->f[$data->tbFields['tbname']];
-                       if (!isset($_POST['owner'])) $_POST['owner'] = $table->f[$data->tbFields['tbowner']];
-                       
-                       echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
-                       echo "<table>\n";
-                       echo "<tr><th class=\"data\">{$lang['strname']}</th>\n";
-                       echo "<td class=\"data1\">";
-                       echo "<input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", 
-                               htmlspecialchars($_POST['name']), "\" />\n";
-                       if ($data->hasAlterTableOwner()) {
-                               echo "<tr><th class=\"data\">{$lang['strowner']}</th>\n";
-                               echo "<td class=\"data1\"><select name=\"owner\">";
-                               while (!$users->EOF) {
-                                       $uname = $users->f[$data->uFields['uname']];
-                                       echo "<option value=\"", htmlspecialchars($uname), "\"",
-                                               ($uname == $_POST['owner']) ? ' selected="selected"' : '', ">", htmlspecialchars($uname), "</option>\n";
-                                       $users->moveNext();
-                               }
-                               echo "</select></td></tr>\n";                           
-                       }
-                       echo "</table>\n";
-                       echo "<p><input type=\"hidden\" name=\"action\" value=\"alter\" />\n";
-                       echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
-                       echo $misc->form;
-                       echo "<input type=\"submit\" name=\"alter\" value=\"{$lang['stralter']}\" />\n";
-                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
-                       echo "</form>\n";
-               }
-               else echo "<p>{$lang['strnodata']}</p>\n";
-       }
-       
        function doExport($msg = '') {
                global $data, $localData, $misc;
                global $PHP_SELF, $lang;
                                // Fetch all available types
                                $types = &$localData->getTypes(true);
 
+                               $misc->printTableNav();
                                echo "<h2>", $misc->printVal($_REQUEST['database']), ": ",
                                        $misc->printVal($_REQUEST['table']), ": {$lang['straddcolumn']}</h2>\n";
                                $misc->printMsg($msg);
                                echo "<input type=\"hidden\" name=\"stage\" value=\"2\" />\n";
                                echo $misc->form;
                                echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\">\n";
-                               echo "<p><input type=\"submit\" value=\"{$lang['stradd']}\" />\n";
-                               echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
+                               echo "<p><input type=\"submit\" value=\"{$lang['stradd']}\" /> <input type=\"reset\" value=\"{$lang['strreset']}\" /></p>\n";
                                echo "</form>\n";
 
                                break;
                        case 1:
                                global $lang;
 
+                               $misc->printTableNav();
                                echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtables']}: {$lang['straltercolumn']}: ",
                                        $misc->printVal($_REQUEST['column']), "</h2>\n";
                                $misc->printMsg($msg);
                                        htmlspecialchars($_REQUEST['default']), "\" /></td>";
                                
                                echo "</table>\n";
-                               echo "<p><input type=\"hidden\" name=\"action\" value=\"properties\" />\n";
+                               echo "<input type=\"hidden\" name=\"action\" value=\"properties\" />\n";
                                echo "<input type=\"hidden\" name=\"stage\" value=\"2\" />\n";
                                echo $misc->form;
                                echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
                                echo "<input type=\"hidden\" name=\"column\" value=\"", htmlspecialchars($_REQUEST['column']), "\" />\n";
                                echo "<input type=\"hidden\" name=\"olddefault\" value=\"", htmlspecialchars($_REQUEST['olddefault']), "\" />\n";
-                               echo "<input type=\"submit\" value=\"{$lang['stralter']}\" />\n";
-                               echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
+                               echo "<input type=\"submit\" value=\"{$lang['stralter']}\" /> <input type=\"reset\" value=\"{$lang['strreset']}\" />\n";
                                echo "</form>\n";
                                                                
                                break;
                        if ($localData->hasDropBehavior()) {
                                echo "<p><input type=\"checkbox\" name=\"cascade\"> {$lang['strcascade']}</p>\n";
                        }
-                       echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
-                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+                       echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" /> <input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n";
                        echo "</form>\n";
                }
                else {
                        echo "<td class=\"data{$id}\">", ($attrs->f['attnotnull'] ? 'NOT NULL' : ''), "</td>\n";
                        echo "<td class=\"data{$id}\">", $misc->printVal($attrs->f['adsrc']), "</td>\n";
                        echo "<td class=\"opbutton{$id}\"><a href=\"{$PHP_SELF}?{$misc->href}&table=", urlencode($_REQUEST['table']),
-                               "&column=", urlencode($attrs->f['attname']), "&action=properties\">{$lang['stralter']}</a></td>\n";
+                               "&column=", urlencode($attrs->f['attname']), "&action=properties\">{$lang['strproperties']}</a></td>\n";
                        if ($data->hasDropColumn()) {
                                echo "<td class=\"opbutton{$id}\"><a href=\"{$PHP_SELF}?{$misc->href}&table=", urlencode($_REQUEST['table']),
                                        "&column=", urlencode($attrs->f['attname']), "&action=confirm_drop\">{$lang['strdrop']}</a></td>\n";
                echo "<li><a href=\"tables.php?action=confinsertrow&{$misc->href}&table=", urlencode($_REQUEST['table']),"\">{$lang['strinsert']}</a></li>\n";
                echo "<li><a href=\"tables.php?action=confirm_drop&{$misc->href}&table=", urlencode($_REQUEST['table']),"\">{$lang['strdrop']}</a></li>\n";
                echo "<li><a href=\"{$PHP_SELF}?action=add_column&{$misc->href}&table=", urlencode($_REQUEST['table']),"\">{$lang['straddcolumn']}</a></li>\n";
-               echo "<li><a href=\"{$PHP_SELF}?action=confirm_alter&{$misc->href}&table=", urlencode($_REQUEST['table']),"\">{$lang['stralter']}</a></li>\n";
                echo "</ul>\n";
        }
 
        $misc->printBody();
 
        switch ($action) {
-               case 'alter':
-                       if (isset($_POST['alter'])) doSaveAlter();
-                       else doDefault();
-                       break;
-               case 'confirm_alter':
-                       doAlter();
-                       break;
                case 'export':
                        doExport();
                        break;
                case 'add_column':
-                       if (isset($_POST['cancel'])) doDefault();
-                       else doAddColumn();
+                       doAddColumn();
                        break;
                case 'properties':
-                       if (isset($_POST['cancel'])) doDefault();
-                       else doProperties();
+                       doProperties();
                        break;
                case 'drop':
-                       if (isset($_POST['drop'])) doDrop(false);
+                       if (isset($_POST['yes'])) doDrop(false);
                        else doDefault();
                        break;
                case 'confirm_drop':
index 3a781614c313dd7b57ee316dd8659796a1826be5..85bda303becfc702c9598e06dabba5afaa7c873c 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * List triggers on a table
         *
-        * $Id: triggers.php,v 1.16 2003/07/30 07:02:29 chriskl Exp $
+        * $Id: triggers.php,v 1.15.2.1 2003/08/13 03:58:25 chriskl Exp $
         */
 
        // Include application functions
        $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
        $PHP_SELF = $_SERVER['PHP_SELF'];
 
-       /** 
-        * Function to save after altering a trigger
-        */
-       function doSaveAlter() {
-               global $localData, $lang;
-               
-               $status = $localData->alterTrigger($_POST['table'], $_POST['trigger'], $_POST['name']);
-               if ($status == 0)
-                       doDefault($lang['strtriggeraltered']);
-               else
-                       doAlter($lang['strtriggeralteredbad']);
-       }
-
-       /**
-        * Function to allow altering of a trigger
-        */
-       function doAlter($msg = '') {
-               global $data, $localData, $misc;
-               global $PHP_SELF, $lang;
-               
-               echo "<h2>", $misc->printVal($_REQUEST['database']), ": {$lang['strtriggers']}: ", $misc->printVal($_REQUEST['trigger']), ": {$lang['stralter']}</h2>\n";
-               $misc->printMsg($msg);
-               
-               $triggerdata = &$localData->getTrigger($_REQUEST['table'], $_REQUEST['trigger']);
-               
-               if ($triggerdata->recordCount() > 0) {
-                       
-                       if (!isset($_POST['name'])) $_POST['name'] = $triggerdata->f[$data->tgFields['tgname']];
-                       
-                       echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
-                       echo "<table>\n";
-                       echo "<tr><th class=\"data\">{$lang['strname']}</th>\n";
-                       echo "<td class=\"data1\">";
-                       echo "<input name=\"name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"", 
-                               htmlspecialchars($_POST['name']), "\" />\n";
-                       echo "</table>\n";
-                       echo "<p><input type=\"hidden\" name=\"action\" value=\"alter\" />\n";
-                       echo "<input type=\"hidden\" name=\"table\" value=\"", htmlspecialchars($_REQUEST['table']), "\" />\n";
-                       echo "<input type=\"hidden\" name=\"trigger\" value=\"", htmlspecialchars($_REQUEST['trigger']), "\" />\n";
-                       echo $misc->form;
-                       echo "<input type=\"submit\" name=\"alter\" value=\"{$lang['strok']}\" />\n";
-                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n";
-                       echo "</form>\n";
-               }
-               else echo "<p>{$lang['strnodata']}</p>\n";
-       }
-       
        /**
         * Show confirmation of drop and perform actual drop
         */
                if ($triggers->recordCount() > 0) {
                        echo "<table>\n";
                        echo "<tr><th class=\"data\">{$lang['strname']}</th><th class=\"data\">{$lang['strdefinition']}</th>";
-                       echo "<th class=\"data\" colspan=\"", ($data->hasAlterTrigger() ? 2 : 1), "\">{$lang['stractions']}</th>\n";
+                       echo "<th class=\"data\">{$lang['stractions']}</th>\n";
                        $i = 0;
 
                        while (!$triggers->EOF) {
                                        echo $misc->printVal($triggers->f[$data->tgFields['tgdef']]);
                                else 
                                        echo $misc->printVal($localData->getTriggerDef($triggers->f));
-                               echo "</td>\n";                         
-                               if ($data->hasAlterTrigger()) {
-                                       echo "<td class=\"opbutton{$id}\"><a href=\"$PHP_SELF?action=confirm_alter&{$misc->href}&trigger=", urlencode($triggers->f[$data->tgFields['tgname']]),
-                                               "&table=", urlencode($_REQUEST['table']), "\">{$lang['stralter']}</td>\n";
-                               }
-                               echo "<td class=\"opbutton{$id}\"><a href=\"$PHP_SELF?action=confirm_drop&{$misc->href}&trigger=", urlencode($triggers->f[$data->tgFields['tgname']]),
-                                       "&table=", urlencode($_REQUEST['table']), "\">{$lang['strdrop']}</td>\n";
-                               echo "</tr>\n";
+                               echo "</td>\n<td class=\"opbutton{$id}\">";
+                               echo "<a href=\"$PHP_SELF?action=confirm_drop&{$misc->href}&trigger=", urlencode( $triggers->f[$data->tgFields['tgname']]),
+                                       "&table=", urlencode($_REQUEST['table']), "\">{$lang['strdrop']}</td></tr>\n";
 
                                $triggers->moveNext();
                                $i++;
        $misc->printBody();
 
        switch ($action) {
-               case 'alter':
-                       if (isset($_POST['alter'])) doSaveAlter();
-                       else doDefault();
-                       break;
-               case 'confirm_alter':
-                       doAlter();
-                       break;
                case 'save_create':
                        doSaveCreate();
                        break;