First draft of Mark Gibson's pop-up SQL window. Still needs a lot of work. Changed...
authorchriskl <chriskl>
Thu, 31 Jul 2003 08:39:03 +0000 (08:39 +0000)
committerchriskl <chriskl>
Thu, 31 Jul 2003 08:39:03 +0000 (08:39 +0000)
CREDITS
HISTORY
lang/english.php
lang/recoded/english.php
sql.php
sqledit.php [new file with mode: 0644]
topbar.php
users.php

diff --git a/CREDITS b/CREDITS
index 20b88eded10d0d735f6366726c58c600a98ea418..3f82237bf1d55354a3fdd91476c195b482682656 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -35,4 +35,5 @@ Contributors
 - Jean-Michel Poure
 - Rafal Slubowski
 - Brett Toolin
+- Mark Gibson (Pop-up SQL window)
 
diff --git a/HISTORY b/HISTORY
index 48bd449e96c72b0979c132e7d85253b01303423e..f149247fdfdcd69581c935ac57099bec192cfbfd 100644 (file)
--- a/HISTORY
+++ b/HISTORY
@@ -14,6 +14,7 @@ Version 3.1
 * Support for domains in 7.3 and domain constraints in 7.4
 * Add/drop users to/from groups
 * Alter (rename) triggers
+* Pop-up SQL window from Mark Gibson
 
 Version 3.0
 -----------
index 030d7f2d0242c66fd82480802ff910a99abae281..2a5d985c25d35e89507705dc99eff952f6462b85 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.88 2003/07/30 07:02:30 chriskl Exp $
+        * $Id: english.php,v 1.89 2003/07/31 08:39:03 chriskl Exp $
         */
 
        // Language and character set
        $lang['strcascade'] = 'CASCADE';
 
        // Users
-       $lang['struseradmin'] = 'User Admin';
        $lang['struser'] = 'User';
        $lang['strusers'] = 'Users';
        $lang['strusername'] = 'Username';
        $lang['strpasswordconfirm'] = 'Password does not match confirmation.';
        
        // Groups
-       $lang['strgroupadmin'] = 'Group Admin';
        $lang['strgroup'] = 'Group';
        $lang['strgroups'] = 'Groups';
        $lang['strnogroup'] = 'Group not found.';
        $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user "%s", %s';
        $lang['strtimefmt'] = 'jS M, Y g:iA';
 
-       // SQL Editor
-       $lang['strsqleditor'] = 'SQL Editor';
-
 ?>
index 606cf0451eda1cd040d4d9124d0a9544450471dc..81b8b6ca0327a0e71434cd598f1e2e64f995a17b 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.40 2003/07/30 07:02:31 chriskl Exp $
+        * $Id: english.php,v 1.41 2003/07/31 08:39:03 chriskl Exp $
         */
 
        // Language and character set
        $lang['strcascade'] = 'CASCADE';
 
        // Users
-       $lang['struseradmin'] = 'User Admin';
        $lang['struser'] = 'User';
        $lang['strusers'] = 'Users';
        $lang['strusername'] = 'Username';
        $lang['strpasswordconfirm'] = 'Password does not match confirmation.';
        
        // Groups
-       $lang['strgroupadmin'] = 'Group Admin';
        $lang['strgroup'] = 'Group';
        $lang['strgroups'] = 'Groups';
        $lang['strnogroup'] = 'Group not found.';
        $lang['strtopbar'] = '%s running on %s:%s -- You are logged in as user &quot;%s&quot;, %s';
        $lang['strtimefmt'] = 'jS M, Y g:iA';
 
-       // SQL Editor
-       $lang['strsqleditor'] = 'SQL Editor';
-
 ?>
diff --git a/sql.php b/sql.php
index 8c47660c65a3b26bc09838e9010a8bf93853b799..c8c1f3d492875f0ae14d0898a453e13b8992b28d 100644 (file)
--- a/sql.php
+++ b/sql.php
@@ -8,7 +8,7 @@
         * @param $return_url The return URL
         * @param $return_desc The return link name
         *
-        * $Id: sql.php,v 1.6 2003/05/31 07:23:24 chriskl Exp $
+        * $Id: sql.php,v 1.7 2003/07/31 08:39:03 chriskl Exp $
         */
 
        // Include application functions
 
        $_POST['query'] = trim($_POST['query']);
        if ($_POST['query'] != '') {
+               \r
+               // NOTE: This is a quick hack!\r
+               if (isset($_POST['explain'])) {\r
+                       // TODO: Is there a generic (non PostgreSQL specific) way to do this\r
+                       $_POST['query'] = 'EXPLAIN '.$_POST['query'];\r
+               }\r
+               
                // Set fetch mode to NUM so that duplicate field names are properly returned
                $localData->conn->setFetchMode(ADODB_FETCH_NUM);
                // Execute the query
diff --git a/sqledit.php b/sqledit.php
new file mode 100644 (file)
index 0000000..19e483b
--- /dev/null
@@ -0,0 +1,72 @@
+<?php\r
+\r
+       /**\r
+        * Alternative SQL editing window\r
+        *\r
+        * $Id: sqledit.php,v 1.1 2003/07/31 08:39:03 chriskl Exp $\r
+        */\r
+\r
+       // Include application functions\r
+       include_once('libraries/lib.inc.php');\r
+\r
+       $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';\r
+       if (!isset($msg)) $msg = '';\r
+       $PHP_SELF = $_SERVER['PHP_SELF'];\r
+\r
+       /**\r
+        * Allow execution of arbitrary SQL statements on a database\r
+        */\r
+       function doDefault() {\r
+               global $PHP_SELF, $data, $localData, $misc;\r
+               global $lang;\r
+\r
+               if (!isset($_POST['query'])) $_POST['query'] = '';\r
+\r
+               echo "<h2>{$lang['strsql']}</h2>\n";\r
+\r
+               echo "<form action=\"sql.php\" method=\"post\" target=\"detail\">\n";\r
+\r
+               echo "<p>{$lang['strdatabase']}: <select name=\"database\">\n";\r
+               $databases = &$data->getDatabases();\r
+               while (!$databases->EOF) {\r
+                       $dbname = $databases->f[$data->dbFields['dbname']];\r
+                       echo "<option value=\"", htmlspecialchars($dbname), "\"",\r
+                       (isset($_REQUEST['database']) && $dbname == $_REQUEST['database']) ? ' selected' : '', ">",\r
+                               htmlspecialchars($dbname), "</option>\n";\r
+                       $databases->moveNext();\r
+               }\r
+               echo "</select>\n";\r
+               echo "<input type=\"submit\" value=\"{$lang['strgo']}\" />\n";\r
+               echo "<input type=\"submit\" name=\"explain\" value=\"{$lang['strexplain']}\" />\n";\r
+               echo "<input type=\"reset\" value=\"{$lang['strreset']}\" />\n";\r
+               echo "<input type=\"button\" value=\"Taller\" onclick=\"document.forms[0].query.rows += 2;\" />\n";\r
+               echo "<input type=\"button\" value=\"Shorter\" onclick=\"document.forms[0].query.rows -= 2;\" />\n";\r
+\r
+               $rows = isset($_REQUEST['rows']) ? $_REQUEST['rows'] : 20;\r
+\r
+               echo "<textarea style=\"width:100%; height:auto;\" rows=\"{$rows}\" cols=\"50\" name=\"query\" id=\"query\">",\r
+                       htmlspecialchars($_POST['query']), "</textarea></p>\n";\r
+\r
+               echo $misc->form;\r
+\r
+//             HMMM: Not sure what the back link could do in this situation, any ideas?\r
+\r
+//             echo "<input type=\"hidden\" name=\"return_url\" value=\"database.php?database=",\r
+//                     urlencode($_REQUEST['database']), " />\n";\r
+//             echo "<input type=\"hidden\" name=\"return_desc\" value=\"{$lang['strback']}\" />\n";\r
+               echo "</form>\n";\r
+       }\r
+\r
+       $misc->printHeader($lang['strsql']);\r
+       // Bring to the front always\r
+       echo "<body onLoad=\"window.focus();\">\n";\r
+       \r
+       switch ($action) {\r
+               default:\r
+                       doDefault();\r
+                       break;\r
+       }\r
+       \r
+       $misc->printFooter();\r
+       \r
+?>\r
index 8ef55de5c1993cdf2e50397499ad0fadd9e2b7b8..9e4da5850b9dfa679de869cce2dd7b73723bc927 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Top menu for phpPgAdmin
         *
-        * $Id: topbar.php,v 1.13 2003/05/28 03:08:45 chriskl Exp $
+        * $Id: topbar.php,v 1.14 2003/07/31 08:39:03 chriskl Exp $
         */
 
        // Include application functions
@@ -29,8 +29,8 @@
        // For superuser, show user and group admin.  For normal user, show change password.
        if ($data->isSuperUser($_SESSION['webdbUsername'])) :
 ?>
-                       <a class="toplink" href="users.php" target="detail"><?php echo $lang['struseradmin'] ?></a> | 
-                       <a class="toplink" href="groups.php" target="detail"><?php echo $lang['strgroupadmin'] ?></a> |
+                       <a class="toplink" href="users.php" target="detail"><?php echo $lang['strusers'] ?></a> | 
+                       <a class="toplink" href="groups.php" target="detail"><?php echo $lang['strgroups'] ?></a> |
 <?php
        endif;
 ?>
@@ -38,6 +38,8 @@
 <?php if ($conf['show_reports']) : ?>
                        <a class="toplink" href="reports.php" target="detail"><?php echo $lang['strreports'] ?></a> |
 <?php endif; ?>
+                       <a class="toplink" href="sqledit" target="sqledit"                                      
+                               onclick="window.open('sqledit.php','sqledit','toobar=no,width=700,height=420,resizable=yes,scrollbars=yes').focus(); return false;"><?php echo $lang['strsql'] ?></a> |
                        <a class="toplink" href="logout.php" target="_parent"><?php echo $lang['strlogout'] ?></a>
                </td>
        </tr>
index c534dca537a43835ecbc8f107cd9faddaa7618f4..12279132d84f82d2a95ba1d9eaf3da15889439cd 100644 (file)
--- a/users.php
+++ b/users.php
@@ -3,7 +3,7 @@
        /**
         * Manage users in a database cluster
         *
-        * $Id: users.php,v 1.14 2003/06/26 02:50:30 chriskl Exp $
+        * $Id: users.php,v 1.15 2003/07/31 08:39:03 chriskl Exp $
         */
 
        // Include application functions
        $action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
        if (!isset($msg)) $msg = '';
        $PHP_SELF = $_SERVER['PHP_SELF'];
+
+       /**
+        * Show access privileges that a user posesses
+        */
+       function doPrivileges($msg = '') {
+               global $data, $misc;
+               global $PHP_SELF, $lang;
        
+               echo "<h2>{$lang['strusers']}: ", $misc->printVal($_REQUEST['username']), ": {$lang['strprivileges']}</h2>\n";
+               $misc->printMsg($msg);
+               
+               $userdata = &$data->getUserPrivileges($_REQUEST['username']);
+               
+               if ($userdata->recordCount() > 0) {
+                       $userdata->f[$data->uFields['usuper']] = $data->phpBool($userdata->f[$data->uFields['usuper']]);
+                       $userdata->f[$data->uFields['ucreatedb']] = $data->phpBool($userdata->f[$data->uFields['ucreatedb']]);
+                       echo "<table>\n";
+                       echo "<tr><th class=\"data\">{$lang['strusername']}</th><th class=\"data\">{$lang['strsuper']}</th><th class=\"data\">{$lang['strcreatedb']}</th><th class=\"data\">{$lang['strexpires']}</th></tr>\n";
+                       echo "<tr><td class=\"data1\">", $misc->printVal($userdata->f[$data->uFields['uname']]), "</td>\n";
+                       echo "<td class=\"data1\">", (($userdata->f[$data->uFields['usuper']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
+                       echo "<td class=\"data1\">", (($userdata->f[$data->uFields['ucreatedb']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
+                       echo "<td class=\"data1\">", $misc->printVal($userdata->f[$data->uFields['uexpires']]), "</td></tr>\n";
+                       echo "</table>\n";
+               }
+               else echo "<p>{$lang['strnodata']}</p>\n";
+               
+               echo "<p><a class=\"navlink\" href=\"$PHP_SELF\">{$lang['strshowallusers']}</a> |\n";
+               echo "<a class=\"navlink\" href=\"$PHP_SELF?action=edit&amp;username=", 
+                       urlencode($_REQUEST['username']), "\">{$lang['stredit']}</a></p>\n";
+       }
+               
        /**
         * If a user is not a superuser, then we have an 'account management' page
         * where they can change their password, etc.  We don't prevent them from