Implement property pages for listens
authorchriskl <chriskl>
Wed, 1 Jun 2005 15:11:44 +0000 (15:11 +0000)
committerchriskl <chriskl>
Wed, 1 Jun 2005 15:11:44 +0000 (15:11 +0000)
classes/plugins/Slony.php
plugin_slony.php

index f211d2b025c945fe9ae9a8654bffd72e5e9dc416..d77236841cf3e18dd423ea448b2c5fa7d1461dae 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * A class that implements the Slony 1.0.x support plugin
  *
- * $Id: Slony.php,v 1.1.2.7 2005/06/01 14:57:26 chriskl Exp $
+ * $Id: Slony.php,v 1.1.2.8 2005/06/01 15:11:44 chriskl Exp $
  */
 
 include_once('./classes/plugins/Plugin.php');
@@ -278,6 +278,26 @@ class Slony extends Plugin {
                return $data->selectSet($sql);
        }
 
+       /**
+        * Gets node listen details
+        */
+       function getListen($no_id, $listen_id) {
+               global $data;
+
+               $schema = $this->slony_schema;
+               $data->fieldClean($schema);
+               $data->clean($no_id);
+               $data->clean($listen_id);
+               
+               $sql = "SELECT sl.*, sn.*, sn2.no_comment AS origin FROM \"{$schema}\".sl_listen sl, \"{$schema}\".sl_node sn, \"{$schema}\".sl_node sn2
+                                       WHERE sl.li_provider=sn.no_id 
+                                       AND sl.li_receiver='{$no_id}'
+                                       AND sn.no_id='{$listen_id}'
+                                       AND sn2.no_id=sl.li_origin";
+               
+               return $data->selectSet($sql);
+       }
+
 }
 
 ?>
index 0cd85821314c167887d5cee7d67f9632d585d0b3..6dc05b673e6e8302332e57b75be8b55720075b71 100755 (executable)
@@ -3,7 +3,7 @@
        /**
         * Slony database tab plugin
         *
-        * $Id: plugin_slony.php,v 1.1.2.6 2005/06/01 14:57:25 chriskl Exp $
+        * $Id: plugin_slony.php,v 1.1.2.7 2005/06/01 15:11:44 chriskl Exp $
         */
 
        // Include application functions
                                        'icon'   => field('icon', 'folder'),
                                        'action' => url(field('url'),
                                                                        $reqvars,
-                                                                       field('urlvars', array())
+                                                                       field('urlvars', array()),
+                                                                       array('action' => 'listens_properties', 'no_id' => $_REQUEST['no_id'])
                                                                ),
                                        'branch' => url(field('url'),
                                                                        $reqvars,
                                        'icon'   => field('icon', 'folder'),
                                        'action' => url('plugin_slony.php',
                                                                        $reqvars,
-                                                                       array('no_id' => field('no_id'))
+                                                                       array('no_id' => field('li_receiver'), 'listen_id' => field('no_id'), 'action' => 'listen_properties')
                                                                )
                                );
                                
                }
                else echo "<p>{$lang['strnodata']}</p>\n";
        }
-       
+
+       /**
+        * List all the listens
+        */
+       function doListens($msg = '') {
+               global $slony, $misc;
+               global $lang;
+
+               $misc->printTrail('database');
+               $misc->printMsg($msg);
+
+               $listens = $slony->getListens($_REQUEST['no_id']);
+
+               $columns = array(
+                       'no_name' => array(
+                               'title' => $lang['strname'],
+                               'field' => 'no_comment'
+                       ),
+                       'actions' => array(
+                               'title' => $lang['stractions'],
+                       ),
+                       'no_comment' => array(
+                               'title' => $lang['strcomment'],
+                               'field' => 'no_comment'
+                       )
+               );
+               
+               $actions = array (
+                       'detail' => array(
+                               'title' => $lang['strproperties'],
+                               'url'   => "plugin_slony.php?{$misc->href}&amp;action=listen_properties&amp;",
+                               'vars'  => array('no_id' => 'li_receiver', 'listen_id' => 'no_id')
+                       )
+               );
+               
+               $misc->printTable($listens, $columns, $actions, 'No listens found.');
+       }
+
+       /**
+        * Display the properties of a listen
+        */      
+       function doListen($msg = '') {
+               global $data, $slony, $misc, $PHP_SELF;
+               global $lang;
+               
+               $misc->printTrail('slony_path');
+               $misc->printTitle($lang['strproperties']);
+               $misc->printMsg($msg);
+               
+               // Fetch the listen information
+               $listen = &$slony->getListen($_REQUEST['no_id'], $_REQUEST['listen_id']);               
+               
+               if (is_object($listen) && $listen->recordCount() > 0) {                 
+                       // Show comment if any
+                       if ($listen->f['no_comment'] !== null)
+                               echo "<p class=\"comment\">", $misc->printVal($listen->f['no_comment']), "</p>\n";
+
+                       // Display domain info
+                       echo "<table>\n";
+                       echo "<tr><th class=\"data left\" width=\"70\">Provider</th>\n";
+                       echo "<td class=\"data1\">", $misc->printVal($listen->f['no_comment']), "</td></tr>\n";
+                       echo "<tr><th class=\"data left\" width=\"70\">Provider ID</th>\n";
+                       echo "<td class=\"data1\">", $misc->printVal($listen->f['li_provider']), "</td></tr>\n";
+                       echo "<tr><th class=\"data left\" width=\"70\">Origin</th>\n";
+                       echo "<td class=\"data1\">", $misc->printVal($listen->f['origin']), "</td></tr>\n";
+                       echo "<tr><th class=\"data left\" width=\"70\">Origin ID</th>\n";
+                       echo "<td class=\"data1\">", $misc->printVal($listen->f['li_origin']), "</td></tr>\n";
+                       echo "</table>\n";
+               }
+               else echo "<p>{$lang['strnodata']}</p>\n";
+       }
+               
        /**
         * List all the replication sets
         */
                case 'path_properties':
                        doPath();
                        break;
+               case 'listens_properties':
+                       doListens();
+                       break;
+               case 'listen_properties':
+                       doListen();
+                       break;
                case 'sets_properties':
                        doReplicationSets();
                        break;