Allow current database to be at the top
authormr-russ <mr-russ>
Sun, 6 Feb 2005 00:34:19 +0000 (00:34 +0000)
committermr-russ <mr-russ>
Sun, 6 Feb 2005 00:34:19 +0000 (00:34 +0000)
HISTORY
browser.php
classes/database/Postgres.php
classes/database/Postgres71.php
classes/database/Postgres80.php
conf/config.inc.php-dist

diff --git a/HISTORY b/HISTORY
index 7bbe2767124c91ccc901c9c7e58989ee7e6be6d6..c2d0865ada0d0463f2c51fa301ab2d07f20b7c14 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -4,6 +4,9 @@ phpPgAdmin History
 Version 3.6-dev
 ---------------
 
+Features
+* Allow current database to be at the top
+
 Bugs
 * Tree Icons are displayed middle instead of top
 * Ensure login frame is always at top level (Russell Smith)
index 7d1c004b5439cb08db37fce2b1358334e09301ea..9adbab66e6e1591ce9269b3321a53d421f8cb072 100644 (file)
@@ -5,7 +5,7 @@
         * if you click on a database it shows a list of database objects in that
         * database.
         *
-        * $Id: browser.php,v 1.42 2004/09/02 13:53:56 jollytoad Exp $
+        * $Id: browser.php,v 1.43 2005/02/06 00:34:19 mr-russ Exp $
         */
 
        // Include application functions
                }
        }       
 
-       $databases = &$data->getDatabases();
+       $databases = &$data->getDatabases($conf['current_db_at_top'] && isset($_REQUEST['database']) ?
+                                                                               $_REQUEST['database'] : NULL);
        while (!$databases->EOF) {
                // If database is selected, show folder, otherwise show document
                if (isset($_REQUEST['database']) && $_REQUEST['database'] == $databases->f['datname']) {
index 42f58f17f52da9a277b235a94a8747deb2c5d81e..bced4de1b14105885f43a0a677a64f697298221e 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.251 2004/11/16 12:40:29 soranzo Exp $
+ * $Id: Postgres.php,v 1.252 2005/02/06 00:34:20 mr-russ Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -393,7 +393,7 @@ class Postgres extends ADODB_base {
         * Return all database available on the server
         * @return A list of databases, sorted alphabetically
         */
-       function &getDatabases() {
+       function &getDatabases($currentdatabase = NULL) {
                global $conf;
 
                if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser($_SESSION['webdbUsername'])) {
@@ -403,6 +403,11 @@ class Postgres extends ADODB_base {
                }
                else $clause = '';
 
+               if ($currentdatabase != NULL)
+                       $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname";
+               else
+                       $orderby = "ORDER BY pdb.datname";
+
                if (!$conf['show_system'])
                        $where = "AND pdb.datname NOT IN ('template1')";
                else
@@ -414,7 +419,7 @@ class Postgres extends ADODB_base {
                                        WHERE pdb.datdba = pu.usesysid
                                        {$where}
                                        {$clause}
-                                       ORDER BY pdb.datname";
+                                       {$orderby}";
 
                return $this->selectSet($sql);
        }
index cbe6ecf7eb90ffe26d766fa057749dc494385755..0ed5650fd5183eafb7f95c4c5f2fea22b5d37eb1 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.68 2004/11/10 01:46:35 chriskl Exp $
+ * $Id: Postgres71.php,v 1.69 2005/02/06 00:34:20 mr-russ Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -94,7 +94,12 @@ class Postgres71 extends Postgres {
                        $clause = " AND pu.usename='{$username}'";
                }
                else $clause = '';
-               
+
+               if ($currentdatabase != NULL)
+                       $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname";
+               else
+                       $orderby = "ORDER BY pdb.datname";
+
                if (!$conf['show_system'])
                        $where = ' AND NOT pdb.datistemplate';
                else
@@ -106,7 +111,8 @@ class Postgres71 extends Postgres {
                        WHERE pdb.datdba = pu.usesysid
                        {$where}
                        {$clause}
-                       ORDER BY pdb.datname";
+                       {$orderby}";
+
                return $this->selectSet($sql);
        }
 
index 9d6b13c1ce4f4da7c472269a2357a2e5617c3dd2..ea71d33c72e621c3f601ccce8be49a8b4f364aa6 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * PostgreSQL 8.0 support
  *
- * $Id: Postgres80.php,v 1.9 2005/02/01 16:41:19 chriskl Exp $
+ * $Id: Postgres80.php,v 1.10 2005/02/06 00:34:20 mr-russ Exp $
  */
 
 include_once('./classes/database/Postgres74.php');
@@ -47,7 +47,7 @@ class Postgres80 extends Postgres74 {
         * Return all database available on the server
         * @return A list of databases, sorted alphabetically
         */
-       function &getDatabases() {
+       function &getDatabases($currentdatabase = NULL) {
                global $conf;
 
                if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser($_SESSION['webdbUsername'])) {
@@ -56,7 +56,12 @@ class Postgres80 extends Postgres74 {
                        $clause = " AND pu.usename='{$username}'";
                }
                else $clause = '';
-               
+
+               if ($currentdatabase != NULL)
+                       $orderby = "ORDER BY pdb.datname = '{$currentdatabase}' DESC, pdb.datname";
+               else
+                       $orderby = "ORDER BY pdb.datname";
+
                if (!$conf['show_system'])
                        $where = ' AND NOT pdb.datistemplate';
                else
@@ -69,11 +74,11 @@ class Postgres80 extends Postgres74 {
                        WHERE pdb.datdba = pu.usesysid
                        {$where}
                        {$clause}
-                       ORDER BY pdb.datname";
-                       
+                       {$orderby}";
+
                return $this->selectSet($sql);
        }
-       
+
        // Schema functions
 
        /**
index e51eed76abda7ffb860a867fe69890072cb6df91..f2c39e26d145bf55b46faca98c52947c4f8379e6 100644 (file)
@@ -4,7 +4,7 @@
         * Central phpPgAdmin configuration.  As a user you may modify the
         * settings here for your particular configuration.
         *
-        * $Id: config.inc.php-dist,v 1.36 2004/11/15 16:03:46 soranzo Exp $
+        * $Id: config.inc.php-dist,v 1.37 2005/02/06 00:34:20 mr-russ Exp $
         */
 
        // An example server.  Create as many of these as you wish,
@@ -94,6 +94,9 @@
        // Send XHTML headers?  Unless debugging, it's best to leave this off
        $conf['use_xhtml'] = false;
 
+       // Show current database at top of list?
+       $conf['current_db_at_top'] = false;
+
        /*****************************************
         * Don't modify anything below this line *
         *****************************************/