Implement moving a table to another replication set. Fix links to full table details.
authorchriskl <chriskl>
Sat, 11 Jun 2005 08:20:08 +0000 (08:20 +0000)
committerchriskl <chriskl>
Sat, 11 Jun 2005 08:20:08 +0000 (08:20 +0000)
classes/plugins/Slony.php
lang/english.php
lang/recoded/english.php
plugin_slony.php

index a5a5c778dc976f013779d77222cd60494bc3b197..cdca3545a2c01047600efefc4b9d744d0f1294c7 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * A class that implements the Slony 1.0.x support plugin
  *
- * $Id: Slony.php,v 1.1.2.17 2005/06/11 06:37:02 chriskl Exp $
+ * $Id: Slony.php,v 1.1.2.18 2005/06/11 08:20:08 chriskl Exp $
  */
 
 include_once('./classes/plugins/Plugin.php');
@@ -343,6 +343,22 @@ class Slony extends Plugin {
                return $data->execute($sql);
        }               
 
+       /**
+        * Moves a table to another replication set
+        */
+       function moveTable($tab_id, $new_set_id) {
+               global $data;
+
+               $schema = $this->slony_schema;
+               $data->fieldClean($schema);
+               $data->clean($tab_id);
+               $data->clean($new_set_id);
+
+               $sql = "SELECT \"{$schema}\".setmovetable('{$tab_id}', '{$new_set_id}')";
+
+               return $data->execute($sql);
+       }               
+
        // SEQUENCES
        
        /**
index 0ed3359ca04276777970b63cffa8d9d6b0a1642a..92ebda04fc880c7bd71262363855d5f7ced4f28b 100755 (executable)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.176.2.3 2005/06/11 06:37:02 chriskl Exp $
+        * $Id: english.php,v 1.176.2.4 2005/06/11 08:20:08 chriskl Exp $
         */
 
        // Language and character set
        $lang['strrepsetdropped'] = 'Replication set dropped.';
        $lang['strrepsetdroppedbad'] = 'Replication set drop failed.';
        $lang['strmerge'] = 'Merge';
-       $lang['strmergeinto'] = 'Merge Into';
+       $lang['strmergeinto'] = 'Merge into';
        $lang['strrepsetmerged'] = 'Replication sets merged.';
        $lang['strrepsetmergedbad'] = 'Replication sets merge failed.';
        $lang['strmove'] = 'Move';
-       $lang['strneworigin'] = 'New Origin';
+       $lang['strneworigin'] = 'New origin';
        $lang['strrepsetmoved'] = 'Replication set moved.';
        $lang['strrepsetmovedbad'] = 'Replication set move failed.';
+       $lang['strnewrepset'] = 'New replication set';
 
        // Slony subscriptions
        $lang['strsubscriptions'] = 'Subscriptions';
index 5f3f41b9dd9953f764d9b50aa1204b98918984b2..daf107a6c05fc871862cc0b95cda84bdfd6690a1 100644 (file)
@@ -4,7 +4,7 @@
         * English language file for phpPgAdmin.  Use this as a basis
         * for new translations.
         *
-        * $Id: english.php,v 1.128.2.2 2005/06/11 06:37:03 chriskl Exp $
+        * $Id: english.php,v 1.128.2.3 2005/06/11 08:20:08 chriskl Exp $
         */
 
        // Language and character set
        $lang['strneworigin'] = 'New Origin';
        $lang['strrepsetmoved'] = 'Replication set moved.';
        $lang['strrepsetmovedbad'] = 'Replication set move failed.';
+       $lang['strnewrepset'] = 'New replication set';
 
        // Slony subscriptions
        $lang['strsubscriptions'] = 'Subscriptions';
index f3e4ca40b3c55e993dbff6aa8fa7209aab196f3a..653ec01c1ff89bcfcfbc37bce786192754061481 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Slony database tab plugin
         *
-        * $Id: plugin_slony.php,v 1.1.2.17 2005/06/11 06:37:02 chriskl Exp $
+        * $Id: plugin_slony.php,v 1.1.2.18 2005/06/11 08:20:08 chriskl Exp $
         */
 
        // Include application functions
                global $PHP_SELF, $lang;
                
                if ($confirm) {
-                       if (!isset($_POST['target'])) $_POST['target'] = '';
+                       if (!isset($_POST['new_origin'])) $_POST['new_origin'] = '';
        
-                       $sets = $slony->getReplicationSets();
+                       $nodes = $slony->getNodes();
+                       $set = $slony->getReplicationSet($_REQUEST['set_id']);
        
                        $misc->printTrail('slony_sets');
                        $misc->printTitle($lang['strmove']);
                        echo $misc->form;
                        echo "<table>\n";
                        echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strneworigin']}</th>\n";
-                       echo "<td class=\"data1\" colspan=\"3\"><select name=\"target\">";
-                       while (!$sets->EOF) {
-                               if ($sets->f['set_id'] != $_REQUEST['set_id']) {
-                                       echo "<option value=\"{$sets->f['set_id']}\">";
-                                       echo htmlspecialchars($sets->f['set_comment']), "</option>\n";
+                       echo "<td class=\"data1\" colspan=\"3\"><select name=\"new_origin\">";
+                       while (!$nodes->EOF) {
+                               if ($nodes->f['no_id'] != $set->f['set_origin']) {
+                                       echo "<option value=\"{$nodes->f['no_id']}\">";
+                                       echo htmlspecialchars($nodes->f['no_comment']), "</option>\n";
                                }
-                               $sets->moveNext();      
+                               $nodes->moveNext();     
                        }
                        echo "</select></td></tr>\n";
                        echo "</table>\n";
                        echo "</form>\n";
                }
                else {
-                       $status = $slony->moveReplicationSet($_POST['set_id'], $_POST['target']);
+                       $status = $slony->moveReplicationSet($_POST['set_id'], $_POST['new_origin']);
                        if ($status == 0)
                                doReplicationSet($lang['strrepsetmoved']);
                        else
 
                $tables = $slony->getTables($_REQUEST['set_id']);
 
-               // XXX: SCHEMA LINKS HERE
                $columns = array(
                        'table' => array(
                                'title' => $lang['strtable'],
                        'properties' => array(
                                'title' => $lang['strproperties'],
                                'url'   => "redirect.php?subject=table&amp;{$misc->href}&amp;",
-                               'vars'  => array('table' => 'relname'),
+                               'vars'  => array('table' => 'relname', 'schema' => 'nspname'),
                        ),
                        'remove' => array(
                                'title' => 'Remove',
                                'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_drop_table&amp;set_id={$_REQUEST['set_id']}&amp;",
                                'vars'  => array('tab_id' => 'tab_id', 'qualname' => 'qualname'),
+                       ),
+                       'move' => array(
+                               'title' => $lang['strmove'],
+                               'url'   => "plugin_slony.php?{$misc->href}&amp;action=move_table&amp;set_id={$_REQUEST['set_id']}&amp;stage=1&amp;",
+                               'vars'  => array('tab_id' => 'tab_id'),
                        )
                );
                
                }
        }
 
+       /**
+        * Displays a screen where they can move a table to a 
+        * replication set.
+        */
+       function doMoveTable($stage, $msg = '') {
+               global $data, $slony, $misc;
+               global $PHP_SELF, $lang;
+               
+               switch ($stage) {
+                       case 1:
+                               if (!isset($_POST['new_set_id'])) $_POST['new_set_id'] = '';
+                               
+                               $sets = &$slony->getReplicationSets();
+               
+                               $misc->printTrail('slony_sets');
+                               $misc->printTitle($lang['strmove']);
+                               $misc->printMsg($msg);
+               
+                               echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+                               echo $misc->form;
+                               echo "<table>\n";
+                               echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strnewrepset']}</th>\n";
+                               echo "<td class=\"data1\" colspan=\"3\"><select name=\"new_set_id\">";
+                               while (!$sets->EOF) {
+                                       if ($sets->f['set_id'] != $_REQUEST['set_id']) {
+                                               echo "<option value=\"{$sets->f['set_id']}\">";
+                                               echo htmlspecialchars($sets->f['set_comment']), "</option>\n";
+                                       }
+                                       $sets->moveNext();      
+                               }
+                               echo "</select></td></tr>\n";
+                               echo "</table>\n";
+                               echo "<p>\n";
+                               echo "<input type=\"hidden\" name=\"action\" value=\"move_table\" />\n";
+                               echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
+                               echo "<input type=\"hidden\" name=\"tab_id\" value=\"", htmlspecialchars($_REQUEST['tab_id']), "\" />\n";
+                               echo "<input type=\"hidden\" name=\"stage\" value=\"2\" />\n";
+                               echo "<input type=\"submit\" value=\"{$lang['strmove']}\" />\n";
+                               echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+                               echo "</p>\n";
+                               echo "</form>\n";
+                               break;
+                       case 2:
+                               $status = $slony->moveTable($_REQUEST['tab_id'], $_REQUEST['new_set_id']);
+                               if ($status == 0)
+                                       doTables('Table moved to replication set.');
+                               else
+                                       doMoveTable(1, 'Failed moving table to replication set.');
+                               break;
+               }
+       }
+
        /**
         * Show confirmation of drop and perform actual drop of a table from a
         * replication set.
 
                $sequences = $slony->getSequences($_REQUEST['set_id']);
 
-               // XXX: SCHEMA LINKS HERE
                $columns = array(
                        'sequence' => array(
                                'title' => $lang['strsequence'],
                $actions = array(
                        'properties' => array(
                                'title' => $lang['strproperties'],
-                               'url'   => "{$PHP_SELF}?action=properties&amp;{$misc->href}&amp;",
-                               'vars'  => array('sequence' => 'seqname'),
+                               'url'   => "sequences.php?action=properties&amp;{$misc->href}&amp;",
+                               'vars'  => array('sequence' => 'seqname', 'schema' => 'nspname'),
                        ),
                        'remove' => array(
                                'title' => 'Remove',
                case 'confirm_drop_table':
                        doRemoveTable(true);
                        break;
+               case 'move_table':
+                       if (isset($_REQUEST['cancel'])) doTables();
+                       else doMoveTable($_REQUEST['stage']);
+                       break;
                case 'sequences_properties':
                        doSequences();
                        break;