Allow basic editing of existing rows of pg_autovacuum from the admin section. Also...
authorxzilla <xzilla>
Sat, 30 Sep 2006 17:30:56 +0000 (17:30 +0000)
committerxzilla <xzilla>
Sat, 30 Sep 2006 17:30:56 +0000 (17:30 +0000)
classes/database/Postgres73.php
database.php
lang/english.php
lang/recoded/english.php

index f142bc8e5955dc0b3219f4e76e1edbb70196422f..0db00e4a66892d58d61ca594c26e75c981228d50 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.159 2006/09/24 23:42:41 xzilla Exp $
+ * $Id: Postgres73.php,v 1.160 2006/09/30 17:30:56 xzilla Exp $
  */
 
 // @@@ THOUGHT: What about inherits? ie. use of ONLY???
@@ -248,6 +248,16 @@ class Postgres73 extends Postgres72 {
                return $this->endTransaction();
        }
 
+       /**
+        * Returns the specified variable information.
+        * @return the field 
+        */
+       function getVariable($setting) {
+               $sql = "SHOW $setting";
+               
+               return $this->selectSet($sql);
+       }
+       
        /**
         * Returns all available variable information.
         * @return A recordset
@@ -257,7 +267,7 @@ class Postgres73 extends Postgres72 {
                
                return $this->selectSet($sql);
        }
-       
+
        /**
         * Returns all available process information.
         * @param $database (optional) Find only connections to specified database
index 52377bdcd5194049429e3bb279393af9779e1642..a660bb306620981eed399dae0b6ed51e148bbcd8 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Manage schemas within a database
         *
-        * $Id: database.php,v 1.87 2006/09/28 13:04:00 xzilla Exp $
+        * $Id: database.php,v 1.88 2006/09/30 17:30:56 xzilla Exp $
         */
 
        // Include application functions
                global $lang;
 
                // Fetch the variables from the database
-               $variables = $data->getVariables();
-               
+               $variables = $data->getVariables();     
                $misc->printTrail('database');
                $misc->printTabs('database','variables');
 
                                echo "<br />";
 
                                if($data->hasAutovacuum()) {
-                                       echo "<h3>{$lang['strautovacuum']}</h3>";
+                                       $enabled = $data->getVariable('autovacuum');
+                                       echo "<h3>{$lang['strautovacuum']} ". (($enabled->f['autovacuum'] == 'on') ? $lang['strturnedon'] : $lang['strturnedoff'] ) ."</h3>";
                                        // Autovacuum
                                        // Fetch the processes from the database
                                        $autovac = $data->getAutovacuum();
                                        $actions = array(
                                                'edit' => array(
                                                'title' => $lang['stredit'],
-                                               'url'   => "{$PHP_SELF}?action=autovacuum&amp;{$misc->href}&amp;",
-                                               'vars'  => array('key' => 'vacrelid')
+                                               'url'   => "{$PHP_SELF}?action=editautovac&amp;schema=pg_catalog&amp;{$misc->href}&amp;",
+                                               'vars'  => array('key[vacrelid]' => 'vacrelid')
                                                ),
                                                'delete' => array(
                                                'title' => $lang['strdelete'],
                }
        }
 
-
        /**
-        * Modify specific entries in the autovacuum table
-     */
-       function doAutovacuum() {
-               global $PHP_SELF, $data, $misc;
+        * Show confirmation of edit and perform actual update of autovacuum entry
+        */
+       function doEditAutovacuum($confirm, $msg = '') {
+               global $data, $misc, $conf;
                global $lang;
+               global $PHP_SELF;
 
-               if (!isset($_REQUEST['query'])) $_REQUEST['query'] = '';
+               $key = $_REQUEST['key'];
+
+               if ($confirm) {
+                       $misc->printTrail('database');
+                       $misc->printTabs('database','admin');
+                       $misc->printMsg($msg);
 
+                       $attrs = $data->getTableAttributes('pg_autovacuum');
+                       $rs = $data->browseRow('pg_autovacuum', $key);
+                       
+                       echo "<form action=\"$PHP_SELF\" method=\"post\" id=\"ac_form\">\n";
+                       $elements = 0;
+                       $error = true;                  
+                       if ($rs->recordCount() == 1 && $attrs->recordCount() > 0) {
+                               echo "<table>\n";
+
+                               // Output table header
+                               echo "<tr><th class=\"data\">{$lang['strcolumn']}</th><th class=\"data\">{$lang['strtype']}</th>";
+                               echo "<th class=\"data\">{$lang['strformat']}</th>\n";
+                               echo "<th class=\"data\">{$lang['strvalue']}</th></tr>";
+
+                               $i = 0;
+                               $nCC = 0;
+                               while (!$attrs->EOF) {
+                                       $szValueName = "values[{$attrs->f['attname']}]";
+                                       $szEvents = "";
+                                       $szDivPH = "";
+                                       
+                                       $attrs->f['attnotnull'] = $data->phpBool($attrs->f['attnotnull']);
+                                       $id = (($i % 2) == 0 ? '1' : '2');
+                                       
+                                       // Initialise variables
+                                       if (!isset($_REQUEST['format'][$attrs->f['attname']]))
+                                               $_REQUEST['format'][$attrs->f['attname']] = 'VALUE';
+                                       
+                                       echo "<tr>\n";
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">", $misc->printVal($attrs->f['attname']), "</td>";
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">\n";
+                                       echo $misc->printVal($data->formatType($attrs->f['type'], $attrs->f['atttypmod']));
+                                       echo "<input type=\"hidden\" name=\"types[", htmlspecialchars($attrs->f['attname']), "]\" value=\"", 
+                                               htmlspecialchars($attrs->f['type']), "\" /></td>";
+                                       $elements++;
+                                       echo "<td class=\"data{$id}\" nowrap=\"nowrap\">\n";
+                                       echo "<select name=\"format[", htmlspecialchars($attrs->f['attname']), "]\">\n";
+                                       echo "<option value=\"VALUE\"", ($_REQUEST['format'][$attrs->f['attname']] == 'VALUE') ? ' selected="selected"' : '', ">{$lang['strvalue']}</option>\n";
+                                       echo "<option value=\"EXPRESSION\"", ($_REQUEST['format'][$attrs->f['attname']] == 'EXPRESSION') ? ' selected="selected"' : '', ">{$lang['strexpression']}</option>\n";
+                                       echo "</select>\n</td>\n";
+                                       $elements++;
+
+                                       echo "<td class=\"data{$id}\" id=\"aciwp{$i}\" nowrap=\"nowrap\">";
+                                       echo $data->printField($szValueName, $rs->f[$attrs->f['attname']], $attrs->f['type'],array(),$szEvents) . $szDivPH;
+                                       echo "</td>";
+                                       $elements++;
+                                       echo "</tr>\n";
+                                       $i++;
+                                       $attrs->moveNext();
+                               }
+                               echo "</table>\n";
+                               $error = false;
+                       }
+                       elseif ($rs->recordCount() != 1) {
+                               echo "<p>{$lang['strrownotunique']}</p>\n";                             
+                       }
+                       else {
+                               echo "<p>{$lang['strinvalidparam']}</p>\n";
+                       }
 
-               echo " editing a specific autovacuum row goes here "; 
+                       echo "<input type=\"hidden\" name=\"action\" value=\"confeditautovac\" />\n";
+                       echo $misc->form;
+                       echo "<input type=\"hidden\" name=\"table\" value=\"pg_autovacuum\" />\n";
+                       echo "<input type=\"hidden\" name=\"key\" value=\"", htmlspecialchars(serialize($key)), "\" />\n";
+                       echo "<p>";
+                       if (!$error) echo "<input type=\"submit\" name=\"save\" value=\"{$lang['strsave']}\" />\n";
+                       echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+                       echo "</p>\n";
+                       echo "</form>\n";
+               }
+               else {
+                       if (!isset($_POST['values'])) $_POST['values'] = array();
+                       if (!isset($_POST['nulls'])) $_POST['nulls'] = array();
+                       
+                       $status = $data->editRow($_POST['table'], $_POST['values'], $_POST['nulls'], 
+                                                                                               $_POST['format'], $_POST['types'], unserialize($_POST['key']));
+                       if ($status == 0)
+                               doAdmin($lang['strrowupdated']);
+                       elseif ($status == -2)
+                               doEditAutovacuum(true, $lang['strrownotunique']);
+                       else
+                               doEditAutovacuum(true, $lang['strrowupdatedbad']);
+               }
 
-               $misc->printTrail('database');
-               $misc->printTabs('database','admin');
+       }       
 
-       }
 
        /**
         * Delete rows from the autovacuum table
                case 'signal':
                        doSignal();
                        break;
+               case 'editautovac':
+                       doEditAutovacuum(true);
+                       break;
+               case 'confeditautovac':
+                       if (isset($_POST['save'])) doEditAutovacuum(false);
+                       else doAdmin();
+                       break;
                case 'delautovac':
                        doDelAutovacuum(true);
                        break;
                        if (isset($_POST['yes'])) doDelAutovacuum(false);
                        else doAdmin();
                        break;
-               case 'autovacuum':
-                       doAutovacuum();
-                       break;
                default:
                        doSQL();
                        break;
index a92512409ea9de1b3659a2a1d815962e8460ccee..201f659d72fc427aa9f455d77680cfaf4ef87984 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.196 2006/09/14 20:54:27 xzilla Exp $
+        * $Id: english.php,v 1.197 2006/09/30 17:30:56 xzilla Exp $
         */
 
        // Language and character set
 
        //Autovacuum
        $lang['strautovacuum'] = 'Autovacuum'; 
+       $lang['strturnedon'] = 'Turned On'; 
+       $lang['strturnedoff'] = 'Turned Off'; 
        $lang['strenabled'] = 'Enabled'; 
        $lang['strvacuumbasethreshold'] = 'Vacuum Base Threshold'; 
        $lang['strvacuumscalefactor'] = 'Vacuum Scale Factor';  
index 2d13005ebd054f84cdc455f6c9529c8f3d2e539f..903e6fac99d300e6edd61330da6bb070fb96a27c 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.149 2006/09/14 20:54:27 xzilla Exp $
+        * $Id: english.php,v 1.150 2006/09/30 17:30:56 xzilla Exp $
         */
 
        // Language and character set
 
        //Autovacuum
        $lang['strautovacuum'] = 'Autovacuum'; 
+       $lang['strturnedon'] = 'Turned On'; 
+       $lang['strturnedoff'] = 'Turned Off'; 
        $lang['strenabled'] = 'Enabled'; 
        $lang['strvacuumbasethreshold'] = 'Vacuum Base Threshold'; 
        $lang['strvacuumscalefactor'] = 'Vacuum Scale Factor';