Projekt

Obecné

Profil

Stáhnout (74.4 KB) Statistiky
| Větev: | Tag: | Revize:
1
<?php
2

    
3
	/**
4
	 * Slony database tab plugin
5
	 *
6
	 * $Id: plugin_slony.php,v 1.6 2005/11/09 09:05:58 jollytoad Exp $
7
	 */
8

    
9
	// Avoid database connections whenever possible
10
	switch (isset($_REQUEST['action']) ? $_REQUEST['action'] : '') {
11
		case 'clusters_top':
12
		case 'nodes_top':
13
		case 'sets_top':
14
				$_no_db_connection = true;
15
				break;
16
		default:
17
	}
18

    
19
	// Include application functions
20
	include_once('./libraries/lib.inc.php');
21

    
22
	$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
23
	$PHP_SELF = $_SERVER['PHP_SELF'];
24
	
25
	// Include 'slony_cluster' in $misc->href if present
26
	if (isset($_REQUEST['slony_cluster'])) {
27
		$misc->href .= '&amp;slony_cluster=' . urlencode($_REQUEST['slony_cluster']);
28
	}
29

    
30
	/**
31
	 * Generate the somewhat complex Slony tree
32
	 * @param string $subject The tree node to return
33
	 */
34
	function doTree($subject) {
35
		global $misc, $data, $lang, $PHP_SELF, $slony;
36

    
37
		$reqvars = $misc->getRequestVars('database');
38
		if (isset($slony))
39
			$reqvars['slony_cluster'] = $slony->slony_cluster;
40

    
41
		// Determine what actual tree we are building
42
		switch ($subject) {
43
			case 'clusters':
44
				// Clusters
45
				
46
				// Enabled check here is just a hack.
47
				if ($slony->isEnabled()) {
48
						$tabs = array('cluster' => array (
49
											'title' => $slony->slony_cluster,
50
											'url'   => 'plugin_slony.php',
51
											'urlvars' => array('subject' => 'clusters_top')
52
										));
53
				}
54
				else $tabs = array();
55
					
56
				$items = $misc->adjustTabsForTree($tabs);
57
				
58
				$attrs = array(
59
					'text'   => noEscape(field('title')),
60
					'icon'   => field('icon', 'folder'),
61
					'action' => url(field('url'),
62
									$reqvars,
63
									array('action'  => 'cluster_properties')
64
								),
65
					'branch' => url(field('url'),
66
									$reqvars,
67
									field('urlvars'),
68
									array('action' => 'clusters_top')
69
								),
70
				);
71
				
72
				$misc->printTreeXML($items, $attrs);
73

    
74
				break;			
75
			case 'clusters_top':
76
				// Top level Nodes and Replication sets folders
77
				$tabs = array('nodes' => array (
78
										'title' => $lang['strnodes'],
79
										'url'   => 'plugin_slony.php',
80
										'urlvars' => array('subject' => 'nodes')
81
									));
82
				
83
				$items = $misc->adjustTabsForTree($tabs);
84
				
85
				$attrs = array(
86
					'text'   => noEscape(field('title')),
87
					'icon'   => field('icon', 'folder'),
88
					'action' => url(field('url'),
89
									$reqvars,
90
									field('urlvars', array()),
91
									array(
92
										'action' => 'nodes_properties'
93
									)
94
								),
95
					'branch' => url(field('url'),
96
									$reqvars,
97
									field('urlvars'),
98
									array('action' => 'nodes')
99
								),
100
					'nofoot' => true
101
				);
102
				
103
				$misc->printTreeXML($items, $attrs);
104

    
105
				$tabs = array('sets' => array (
106
										'title' => 	$lang['strrepsets'],
107
										'url'   => 'plugin_slony.php',
108
										'urlvars' => array('subject' => 'sets')
109
									));
110
				
111
				$items = $misc->adjustTabsForTree($tabs);
112
				
113
				$attrs = array(
114
					'text'   => noEscape(field('title')),
115
					'icon'   => field('icon', 'folder'),
116
					'action' => url(field('url'),
117
									$reqvars,
118
									field('urlvars', array()),
119
									array('action' => 'sets_properties')
120
								),
121
					'branch' => url(field('url'),
122
									$reqvars,
123
									field('urlvars'),
124
									array('action' => 'sets')
125
								),
126
					'nohead' => true
127
				);
128
				
129
				$misc->printTreeXML($items, $attrs);
130
				
131
				break;
132
			case 'nodes':			
133
				$nodes = $slony->getNodes();
134
				
135
				$attrs = array(
136
					'text'   => field('no_comment'),
137
					'icon'   => 'folder',
138
					'action' => url('plugin_slony.php',
139
									$reqvars,
140
									array(
141
										'subject' => 'slony_node',
142
										'action'  => 'node_properties',
143
										'no_id' => field('no_id'),
144
										'no_name' => field('no_comment'),
145
										'slony_cluster' => $slony->slony_cluster
146
									)
147
								),
148
					'branch' => url('plugin_slony.php',
149
									$reqvars,
150
									array(
151
										'action'  => 'nodes_top',
152
										'no_id' => field('no_id')
153
									)
154
								)
155
				);
156

    
157
				$misc->printTreeXML($nodes, $attrs);
158
				
159
				break;
160
			case 'nodes_top':
161
				// Nodes paths and listens entries
162
				
163
				$tabs = array('paths' => array (
164
										'title' => $lang['strpaths'],
165
										'url'   => 'plugin_slony.php',
166
										'urlvars' => array('subject' => 'paths')
167
									));
168
				
169
				$items = $misc->adjustTabsForTree($tabs);
170
				
171
				$attrs = array(
172
					'text'   => noEscape(field('title')),
173
					'icon'   => field('icon', 'folder'),
174
					'action' => url(field('url'),
175
									$reqvars,
176
									field('urlvars', array()),
177
									array('action' => 'paths_properties', 'no_id' => $_REQUEST['no_id'])
178
								),
179
					'branch' => url(field('url'),
180
									$reqvars,
181
									field('urlvars'),
182
									array('action' => 'paths', 'no_id' => $_REQUEST['no_id'])
183
								),
184
					'nofoot' => true
185
				);
186
				
187
				$misc->printTreeXML($items, $attrs);
188

    
189
				$tabs = array('listens' => array (
190
										'title' => $lang['strlistens'],
191
										'url'   => 'plugin_slony.php',
192
										'urlvars' => array('subject' => 'listens')
193
									));
194
				
195
				$items = $misc->adjustTabsForTree($tabs);
196
				
197
				$attrs = array(
198
					'text'   => noEscape(field('title')),
199
					'icon'   => field('icon', 'folder'),
200
					'action' => url(field('url'),
201
									$reqvars,
202
									field('urlvars', array()),
203
									array('action' => 'listens_properties', 'no_id' => $_REQUEST['no_id'])
204
								),
205
					'branch' => url(field('url'),
206
									$reqvars,
207
									field('urlvars'),
208
									array('action' => 'listens', 'no_id' => $_REQUEST['no_id'])
209
								),
210
					'nohead' => true
211
				);
212
				
213
				$misc->printTreeXML($items, $attrs);
214
				
215
				break;			
216
			case 'paths':
217
				$tables = $slony->getPaths($_REQUEST['no_id']);
218
				
219
				$attrs = array(
220
					'text'   => field('no_comment'),
221
					'icon'   => field('icon', 'folder'),
222
					'action' => url('plugin_slony.php',
223
									$reqvars,
224
									array('no_id' => field('pa_client'), 'path_id' => field('no_id'), 'action' => 'path_properties')
225
								)
226
				);
227
				
228
				$misc->printTreeXML($tables, $attrs);
229
			
230
				break;
231
			case 'listens':
232
				$tables = $slony->getListens($_REQUEST['no_id']);
233
				
234
				$attrs = array(
235
					'text'   => field('no_comment'),
236
					'icon'   => field('icon', 'folder'),
237
					'action' => url('plugin_slony.php',
238
									$reqvars,
239
									array('no_id' => field('li_receiver'), 'listen_id' => field('no_id'), 'action' => 'listen_properties')
240
								)
241
				);
242
				
243
				$misc->printTreeXML($tables, $attrs);
244
			
245
				break;
246
			case 'sets':
247
				$sets = $slony->getReplicationSets();
248
			
249
				$attrs = array(
250
					'text'   => field('set_comment'),
251
					'icon'   => 'folder',
252
					'action' => url('plugin_slony.php',
253
									$reqvars,
254
									array(
255
										'action'  => 'set_properties',
256
										'set_id' => field('set_id')
257
									)
258
								),
259
					'branch' => url('plugin_slony.php',
260
									$reqvars,
261
									array(
262
										'action'  => 'sets_top',
263
										'set_id' => field('set_id')
264
									)
265
								)
266
				);
267
				
268
				$misc->printTreeXML($sets, $attrs);
269
				break;
270
			case 'sets_top':
271
				// Top level Nodes and Replication sets folders
272
				
273
				$tabs = array('sequences' => array (
274
										'title' => $lang['strsequences'],
275
										'url'   => 'plugin_slony.php',
276
										'urlvars' => array('subject' => 'sequences')
277
									));
278
				
279
				$items = $misc->adjustTabsForTree($tabs);
280
				
281
				$attrs = array(
282
					'text'   => noEscape(field('title')),
283
					'icon'   => field('icon', 'sequences'),
284
					'action' => url(field('url'),
285
									$reqvars,
286
									field('urlvars', array()),
287
									array('action' => 'sequences_properties', 'set_id' => $_REQUEST['set_id'])
288
								),
289
					'branch' => url(field('url'),
290
									$reqvars,
291
									field('urlvars'),
292
									array('action' => 'sequences', 'set_id' => $_REQUEST['set_id'])
293
								),
294
					'nofoot' => true
295
				);
296
				
297
				$misc->printTreeXML($items, $attrs);
298

    
299
				$tabs = array('tables' => array (
300
										'title' => $lang['strtables'],
301
										'url'   => 'plugin_slony.php',
302
										'urlvars' => array('subject' => 'tables')
303
									));
304
				
305
				$items = $misc->adjustTabsForTree($tabs);
306
				
307
				$attrs = array(
308
					'text'   => noEscape(field('title')),
309
					'icon'   => field('icon', 'tables'),
310
					'action' => url(field('url'),
311
									$reqvars,
312
									field('urlvars', array()),
313
									array('action' => 'tables_properties', 'set_id' => $_REQUEST['set_id'])
314
								),
315
					'branch' => url(field('url'),
316
									$reqvars,
317
									field('urlvars'),
318
									array('action' => 'tables', 'set_id' => $_REQUEST['set_id'])
319
								),
320
					'nohead' => true,
321
					'nofoot' => true
322
				);
323
				
324
				$misc->printTreeXML($items, $attrs);
325

    
326
				$tabs = array('subscriptions' => array (
327
										'title' => $lang['strsubscriptions'],
328
										'url'   => 'plugin_slony.php',
329
										'urlvars' => array('subject' => 'subscriptions')
330
									));
331
				
332
				$items = $misc->adjustTabsForTree($tabs);
333
				
334
				$attrs = array(
335
					'text'   => noEscape(field('title')),
336
					'icon'   => field('icon', 'folder'),
337
					'action' => url(field('url'),
338
									$reqvars,
339
									field('urlvars', array()),
340
									array('action' => 'subscriptions_properties', 'set_id' => $_REQUEST['set_id'])
341
								),
342
					'branch' => url(field('url'),
343
									$reqvars,
344
									field('urlvars'),
345
									array('action' => 'subscriptions', 'set_id' => $_REQUEST['set_id'])
346
								),
347
					'nohead' => true
348
				);
349
				
350
				$misc->printTreeXML($items, $attrs);
351
				
352
				break;
353
			case 'sequences':
354
				$tables = $slony->getSequences($_REQUEST['set_id']);
355
				
356
				$reqvars = $misc->getRequestVars('sequence');
357

    
358
				$attrs = array(
359
					'text'   => field('qualname'),
360
					'icon'   => 'sequences',
361
					'toolTip'=> field('seqcomment'),
362
					'action' => url('sequences.php',
363
									$reqvars,
364
									array (
365
										'action' => 'properties',
366
										'sequence' => field('seqname'),
367
										'schema' => field('nspname')
368
									)
369
								)
370
				);
371
				
372
				$misc->printTreeXML($tables, $attrs);
373
			
374
				break;
375
			case 'tables':
376
				$tables = $slony->getTables($_REQUEST['set_id']);
377
				
378
				$reqvars = $misc->getRequestVars('table');
379
				
380
				$attrs = array(
381
					'text'   => field('qualname'),
382
					'icon'   => 'tables',
383
					'toolTip'=> field('relcomment'),
384
					'action' => url('redirect.php',
385
									$reqvars,
386
									array('table' => field('relname'), 'schema' => field('nspname'))
387
								)
388
				);
389
				
390
				$misc->printTreeXML($tables, $attrs);
391
			
392
				break;
393
			case 'subscriptions':
394
				$tables = $slony->getSubscribedNodes($_REQUEST['set_id']);
395
				
396
				$attrs = array(
397
					'text'   => field('no_comment'),
398
					'icon'   => field('icon', 'folder'),
399
					'action' => url('plugin_slony.php',
400
									$reqvars,
401
									array('set_id' => field('sub_set'), 'no_id' => field('no_id'), 'action' => 'subscription_properties')
402
								)
403
				);
404
				
405
				$misc->printTreeXML($tables, $attrs);
406
			
407
				break;
408
		}
409
			
410
		exit;
411
	}
412

    
413
	/**
414
	 * Display the slony clusters (we only support one)
415
	 */	 
416
	function doClusters($msg = '') {
417
		global $PHP_SELF, $slony, $misc;
418
		global $lang;
419

    
420
		$misc->printTrail('database');
421
		$misc->printTabs('database','slony');
422
		$misc->printMsg($msg);
423

    
424
		$clusters = $slony->getClusters();
425

    
426
		$columns = array(
427
			'no_name' => array(
428
				'title' => $lang['strcluster'],
429
				'field' => 'cluster'
430
			),
431
			'actions' => array(
432
				'title' => $lang['stractions'],
433
			),
434
			'no_comment' => array(
435
				'title' => $lang['strcomment'],
436
				'field' => 'comment'
437
			)
438
		);
439
		
440
		$actions = array (
441
			'properties' => array(
442
				'title' => $lang['strproperties'],
443
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=cluster_properties&amp;",
444
				'vars'  => array('slony_cluster' => 'cluster')
445
			),
446
			'drop' => array(
447
				'title' => $lang['strdrop'],
448
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_drop_cluster&amp;",
449
				'vars'  => array('slony_cluster' => 'cluster')
450
			)
451
		);
452
		
453
		$misc->printTable($clusters, $columns, $actions, $lang['strnoclusters']);
454

    
455
		if ($clusters->recordCount() == 0) {		
456
			echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=create_cluster&amp;{$misc->href}\">{$lang['strinitcluster']}</a></p>\n";
457
		}
458
	}
459

    
460
	// CLUSTERS
461

    
462
	/**
463
	 * Display the properties of a slony cluster
464
	 */	 
465
	function doCluster($msg = '') {
466
		global $data, $slony, $misc, $PHP_SELF;
467
		global $lang;
468
		
469
		$misc->printTrail('slony_cluster');
470
		$misc->printTabs('slony_cluster', 'properties');
471
		$misc->printMsg($msg);
472
		
473
		// Fetch the cluster information
474
		$cluster = $slony->getCluster();
475
		
476
		if (is_object($cluster) && $cluster->recordCount() > 0) {			
477
			echo "<table>\n";
478
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strname']}</th>\n";
479
			echo "<td class=\"data1\">", $misc->printVal($slony->slony_cluster), "</td></tr>\n";
480
			echo "<tr><th class=\"data left\" width=\"70\">Local Node ID</th>\n";
481
			echo "<td class=\"data1\">", $misc->printVal($cluster->f['no_id']), "</td></tr>\n";
482
			echo "<tr><th class=\"data left\" width=\"70\">Local Node</th>\n";
483
			echo "<td class=\"data1\">", $misc->printVal($cluster->f['no_comment']), "</td></tr>\n";
484
			echo "<tr><th class=\"data left\" width=\"70\">Version</th>\n";
485
			echo "<td class=\"data1\">", $misc->printVal($cluster->f['version']), "</td></tr>\n";
486
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strowner']}</th>\n";
487
			echo "<td class=\"data1\">", $misc->printVal($slony->slony_owner), "</td></tr>\n";
488
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strcomment']}</th>\n";
489
			echo "<td class=\"data1\"></td></tr>\n";
490
			echo "</table>\n";
491
		}
492
		else echo "<p>{$lang['strnodata']}</p>\n";
493
	}
494

    
495
	/**
496
	 * Displays a screen where they can enter a new cluster
497
	 */
498
	function doCreateCluster($confirm, $msg = '') {
499
		global $data, $slony, $misc;
500
		global $PHP_SELF, $lang;
501
		
502
		if ($confirm) {
503
			if (!isset($_POST['cluster'])) $_POST['cluster'] = '';
504
			if (!isset($_POST['no_id'])) $_POST['no_id'] = '1';
505
			if (!isset($_POST['no_comment'])) $_POST['no_comment'] = '';
506
	
507
			$misc->printTrail('slony_clusters');
508
			$misc->printTitle($lang['strinitcluster']);
509
			$misc->printMsg($msg);
510
	
511
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
512
			echo $misc->form;
513
			echo "<table width=\"100%\">\n";
514
			echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strcluster']}</th>\n";
515
			echo "\t\t<td class=\"data1\"><input name=\"cluster\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
516
				htmlspecialchars($_POST['cluster']), "\" /></td>\n\t</tr>\n";
517
			echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strid']}</th>\n";
518
			echo "\t\t<td class=\"data1\"><input name=\"no_id\" size=\"5\" value=\"",
519
				htmlspecialchars($_POST['no_id']), "\" /></td>\n\t</tr>\n";
520
			echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n";
521
			echo "\t\t<td class=\"data1\"><textarea name=\"no_comment\" rows=\"3\" cols=\"32\" wrap=\"virtual\">", 
522
				htmlspecialchars($_POST['no_comment']), "</textarea></td>\n\t</tr>\n";
523
			echo "</table>\n";
524
			echo "<p>\n";
525
			echo "<input type=\"hidden\" name=\"action\" value=\"save_create_cluster\" />\n";
526
			echo "<input type=\"submit\" value=\"{$lang['strinitcluster']}\" />\n";
527
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
528
			echo "</p>\n";
529
			echo "</form>\n";
530
		}
531
		else {
532
			if (trim($_POST['cluster']) == '') {
533
				doCreateCluster(true, $lang['strclusterneedsname']);
534
				return;
535
			}
536
			elseif (trim($_POST['no_id']) == '') {
537
				doCreateCluster(true, $lang['strclusterneedsnodeid']);
538
				return;
539
			}
540
			
541
			$status = $slony->initCluster($_POST['cluster'], $_POST['no_id'], $_POST['no_comment']);
542
			if ($status == 0)
543
				doClusters($lang['strclustercreated']);
544
			else
545
				doCreateCluster(true, $lang['strclustercreatedbad'] . ':' . $status);
546
		}
547
	}
548

    
549
	/**
550
	 * Show confirmation of drop and perform actual drop of a cluster
551
	 */
552
	function doDropCluster($confirm) {
553
		global $slony, $misc;
554
		global $PHP_SELF, $lang;
555

    
556
		if ($confirm) {
557
			$misc->printTrail('slony_cluster');
558
			$misc->printTitle($lang['strdrop']);
559

    
560
			echo "<p>", sprintf($lang['strconfdropcluster'], $misc->printVal($slony->slony_cluster)), "</p>\n";
561

    
562
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
563
			echo "<input type=\"hidden\" name=\"action\" value=\"drop_cluster\" />\n";
564
			echo $misc->form;
565
			echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
566
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
567
			echo "</form>\n";
568
		}
569
		else {
570
			$status = $slony->dropCluster();
571
			if ($status == 0)
572
				doClusters($lang['strclusterdropped']);
573
			else
574
				doClusters($lang['strclusterdroppedbad']);
575
		}
576
	}
577

    
578
	// NODES
579
	
580
	/**
581
	 * List all the nodes
582
	 */
583
	function doNodes($msg = '') {
584
		global $PHP_SELF, $slony, $misc;
585
		global $lang;
586

    
587
		$misc->printTrail('slony_cluster');
588
		$misc->printTabs('slony_cluster', 'nodes');
589
		$misc->printMsg($msg);
590

    
591
		$nodes = $slony->getNodes();
592

    
593
		$columns = array(
594
			'no_name' => array(
595
				'title' => $lang['strname'],
596
				'field' => 'no_comment'
597
			),
598
			'actions' => array(
599
				'title' => $lang['stractions'],
600
			),
601
			'no_comment' => array(
602
				'title' => $lang['strcomment'],
603
				'field' => 'no_comment'
604
			)
605
		);
606
		
607
		$actions = array (
608
			'properties' => array(
609
				'title' => $lang['strproperties'],
610
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=node_properties&amp;subject=slony_node&amp;",
611
				'vars'  => array('no_id' => 'no_id', 'no_name' => 'no_comment')
612
			),
613
			'drop' => array(
614
				'title' => $lang['strdrop'],
615
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_drop_node&amp;subject=slony_node&amp;",
616
				'vars'  => array('no_id' => 'no_id', 'no_name' => 'no_comment')
617
			)
618
		);
619
		
620
		$misc->printTable($nodes, $columns, $actions, $lang['strnonodes']);
621
		
622
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=create_node&amp;{$misc->href}\">{$lang['strcreatenode']}</a></p>\n";
623
	}
624
	
625
	/**
626
	 * Display the properties of a node
627
	 */	 
628
	function doNode($msg = '') {
629
		global $data, $slony, $misc, $PHP_SELF;
630
		global $lang;
631
		
632
		$misc->printTrail('slony_node');
633
		$misc->printTitle($lang['strproperties']);
634
		$misc->printMsg($msg);
635
		
636
		// Fetch the node information
637
		$node = $slony->getNode($_REQUEST['no_id']);		
638
		
639
		if (is_object($node) && $node->recordCount() > 0) {			
640
			// Show comment if any
641
			if ($node->f['no_comment'] !== null)
642
				echo "<p class=\"comment\">", $misc->printVal($node->f['no_comment']), "</p>\n";
643

    
644
			echo "<table>\n";
645
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strname']}</th>\n";
646
			echo "<td class=\"data1\">", $misc->printVal($node->f['no_comment']), "</td></tr>\n";
647
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strid']}</th>\n";
648
			echo "<td class=\"data1\">", $misc->printVal($node->f['no_id']), "</td></tr>\n";
649
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['stractive']}</th>\n";
650
			echo "<td class=\"data1\">", ($data->phpBool($node->f['no_active'])) ? $lang['stryes'] : $lang['strno'], "</td></tr>\n";
651
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strcomment']}</th>\n";
652
			echo "<td class=\"data1\">", $misc->printVal($node->f['no_comment']), "</td></tr>\n";
653
			echo "</table>\n";
654
		}
655
		else echo "<p>{$lang['strnodata']}</p>\n";
656

    
657
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_drop_node&amp;{$misc->href}&amp;no_id={$_REQUEST['no_id']}\">{$lang['strdrop']}</a></p>\n";
658
	}
659

    
660
	/**
661
	 * Displays a screen where they can enter a new node
662
	 */
663
	function doCreateNode($confirm, $msg = '') {
664
		global $slony, $misc;
665
		global $PHP_SELF, $lang;
666
		
667
		if ($confirm) {
668
			if (!isset($_POST['nodeid'])) $_POST['nodeid'] = '';
669
			if (!isset($_POST['nodecomment'])) $_POST['nodecomment'] = '';
670
	
671
			$misc->printTrail('slony_nodes');
672
			$misc->printTitle($lang['strcreatenode']);
673
			$misc->printMsg($msg);
674
	
675
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
676
			echo $misc->form;
677
			echo "<table width=\"100%\">\n";
678
			echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strid']}</th>\n";
679
			echo "\t\t<td class=\"data1\"><input name=\"nodeid\" size=\"5\" value=\"",
680
				htmlspecialchars($_POST['nodeid']), "\" /></td>\n\t</tr>\n";
681
			echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n";
682
			echo "\t\t<td class=\"data1\"><textarea name=\"nodecomment\" rows=\"3\" cols=\"32\" wrap=\"virtual\">", 
683
				htmlspecialchars($_POST['nodecomment']), "</textarea></td>\n\t</tr>\n";
684
				
685
			echo "\t</tr>\n";
686
			echo "</table>\n";
687
			echo "<p>\n";
688
			echo "<input type=\"hidden\" name=\"action\" value=\"save_create_node\" />\n";
689
			echo "<input type=\"submit\" value=\"{$lang['strcreate']}\" />\n";
690
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
691
			echo "</p>\n";
692
			echo "</form>\n";
693
		}
694
		else {
695
			$status = $slony->createNode($_POST['nodeid'], $_POST['nodecomment']);
696
			if ($status == 0)
697
				doNodes($lang['strnodecreated']);
698
			else
699
				doCreateNode(true, $lang['strnodecreatedbad']);
700
		}
701
	}
702

    
703
	/**
704
	 * Show confirmation of drop and perform actual drop of a node
705
	 */
706
	function doDropNode($confirm) {
707
		global $slony, $misc;
708
		global $PHP_SELF, $lang;
709

    
710
		if ($confirm) {
711
			$misc->printTrail('slony_cluster');
712
			$misc->printTitle($lang['strdrop']);
713

    
714
			echo "<p>", sprintf($lang['strconfdropnode'], $misc->printVal($_REQUEST['no_id'])), "</p>\n";
715

    
716
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
717
			echo "<input type=\"hidden\" name=\"action\" value=\"drop_node\" />\n";
718
			echo "<input type=\"hidden\" name=\"no_id\" value=\"", htmlspecialchars($_REQUEST['no_id']), "\" />\n";
719
			echo $misc->form;
720
			echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
721
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
722
			echo "</form>\n";
723
		}
724
		else {
725
			$status = $slony->dropNode($_REQUEST['no_id']);
726
			if ($status == 0)
727
				doNodes($lang['strnodedropped']);
728
			else
729
				doNodes($lang['strnodedroppedbad']);
730
		}
731
	}
732
			
733
	// PATHS
734

    
735
	/**
736
	 * List all the paths
737
	 */
738
	function doPaths($msg = '') {
739
		global $PHP_SELF, $slony, $misc;
740
		global $lang;
741

    
742
		$misc->printTrail('database');
743
		$misc->printMsg($msg);
744

    
745
		$paths = $slony->getPaths($_REQUEST['no_id']);
746

    
747
		$columns = array(
748
			'no_name' => array(
749
				'title' => $lang['strname'],
750
				'field' => 'no_comment'
751
			),
752
			'actions' => array(
753
				'title' => $lang['stractions'],
754
			),
755
			'no_comment' => array(
756
				'title' => $lang['strcomment'],
757
				'field' => 'no_comment'
758
			)
759
		);
760
		
761
		$actions = array (
762
			'properties' => array(
763
				'title' => $lang['strproperties'],
764
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=path_properties&amp;",
765
				'vars'  => array('no_id' => 'pa_client', 'path_id' => 'no_id')
766
			),
767
			'drop' => array(
768
				'title' => $lang['strdrop'],
769
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_drop_path&amp;",
770
				'vars'  => array('no_id' => 'pa_client', 'path_id' => 'no_id')
771
			)
772
		);
773
		
774
		$misc->printTable($paths, $columns, $actions, $lang['strnopaths']);
775
	
776
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=create_path&amp;{$misc->href}&amp;no_id={$_REQUEST['no_id']}\">{$lang['strcreatepath']}</a></p>\n";
777
	}
778
	
779
	/**
780
	 * Display the properties of a path
781
	 */	 
782
	function doPath($msg = '') {
783
		global $data, $slony, $misc, $PHP_SELF;
784
		global $lang;
785
		
786
		$misc->printTrail('slony_path');
787
		$misc->printTitle($lang['strproperties']);
788
		$misc->printMsg($msg);
789
		
790
		// Fetch the path information
791
		$path = $slony->getPath($_REQUEST['no_id'], $_REQUEST['path_id']);		
792
		
793
		if (is_object($path) && $path->recordCount() > 0) {			
794
			// Show comment if any
795
			if ($path->f['no_comment'] !== null)
796
				echo "<p class=\"comment\">", $misc->printVal($path->f['no_comment']), "</p>\n";
797

    
798
			echo "<table>\n";
799
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strnodename']}</th>\n";
800
			echo "<td class=\"data1\">", $misc->printVal($path->f['no_comment']), "</td></tr>\n";
801
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strnodeid']}</th>\n";
802
			echo "<td class=\"data1\">", $misc->printVal($path->f['no_id']), "</td></tr>\n";
803
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strconninfo']}</th>\n";
804
			echo "<td class=\"data1\">", $misc->printVal($path->f['pa_conninfo']), "</td></tr>\n";
805
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strconnretry']}</th>\n";
806
			echo "<td class=\"data1\">", $misc->printVal($path->f['pa_connretry']), "</td></tr>\n";
807
			echo "</table>\n";
808
		}
809
		else echo "<p>{$lang['strnodata']}</p>\n";
810

    
811
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_drop_path&amp;{$misc->href}&amp;no_id={$_REQUEST['no_id']}&amp;path_id={$_REQUEST['path_id']}\">{$lang['strdrop']}</a></p>\n";
812
	}
813

    
814
	/**
815
	 * Displays a screen where they can enter a new path
816
	 */
817
	function doCreatePath($confirm, $msg = '') {
818
		global $data, $slony, $misc;
819
		global $PHP_SELF, $lang;
820
		
821
		if ($confirm) {
822
			if (!isset($_POST['pathserver'])) $_POST['pathserver'] = '';
823
			if (!isset($_POST['pathconn'])) $_POST['pathconn'] = '';
824
			if (!isset($_POST['pathretry'])) $_POST['pathretry'] = '10';
825
	
826
			// Fetch all servers
827
			$nodes = $slony->getNodes();
828

    
829
			$misc->printTrail('slony_paths');
830
			$misc->printTitle($lang['strcreatepath']);
831
			$misc->printMsg($msg);
832
	
833
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
834
			echo $misc->form;
835
			echo "<table width=\"100%\">\n";
836
			echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strnodename']}</th>\n";
837
			echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"pathserver\">\n";
838
			while (!$nodes->EOF) {
839
				echo "\t\t\t\t<option value=\"{$nodes->f['no_id']}\"",
840
					($nodes->f['no_id'] == $_POST['pathserver']) ? ' selected="selected"' : '', ">", htmlspecialchars($nodes->f['no_comment']), "</option>\n";
841
				$nodes->moveNext();
842
			}
843
			echo "\t\t\t</select>\n\t\t</td>\n\t\n";		
844
			echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strconninfo']}</th>\n";
845
			echo "\t\t<td class=\"data1\"><input name=\"pathconn\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
846
				htmlspecialchars($_POST['pathconn']), "\" /></td>\n\t</tr>\n";
847
			echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strconnretry']}</th>\n";
848
			echo "\t\t<td class=\"data1\"><input name=\"pathretry\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
849
				htmlspecialchars($_POST['pathretry']), "\" /></td>\n\t</tr>\n";
850
				
851
			echo "\t</tr>\n";
852
			echo "</table>\n";
853
			echo "<p>\n";
854
			echo "<input type=\"hidden\" name=\"action\" value=\"save_create_path\" />\n";
855
			echo "<input type=\"hidden\" name=\"no_id\" value=\"", htmlspecialchars($_REQUEST['no_id']), "\" />\n";
856
			echo "<input type=\"submit\" value=\"{$lang['strcreate']}\" />\n";
857
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
858
			echo "</p>\n";
859
			echo "</form>\n";
860
		}
861
		else {
862
			if (trim($_POST['pathconn']) == '') {
863
				doCreatePath(true, $lang['strpathneedsconninfo']);
864
				return;
865
			}
866
			elseif (trim($_POST['pathretry']) == '') {
867
				doCreatePath(true, $lang['strpathneedsconnretry']);
868
				return;
869
			}
870
				
871
			$status = $slony->createPath($_POST['no_id'], $_POST['pathserver'], $_POST['pathconn'], $_POST['pathretry']);
872
			if ($status == 0)
873
				doPaths($lang['strpathcreated']);
874
			else
875
				doCreatePath(true, $lang['strpathcreatedbad']);
876
		}
877
	}
878

    
879
	/**
880
	 * Show confirmation of drop and perform actual drop of a path
881
	 */
882
	function doDropPath($confirm) {
883
		global $slony, $misc;
884
		global $PHP_SELF, $lang;
885

    
886
		if ($confirm) {
887
			$misc->printTrail('slony_cluster');
888
			$misc->printTitle($lang['strdrop']);
889

    
890
			echo "<p>", sprintf($lang['strconfdroppath'], $misc->printVal($_REQUEST['path_id'])), "</p>\n";
891

    
892
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
893
			echo "<input type=\"hidden\" name=\"action\" value=\"drop_path\" />\n";
894
			echo "<input type=\"hidden\" name=\"no_id\" value=\"", htmlspecialchars($_REQUEST['no_id']), "\" />\n";
895
			echo "<input type=\"hidden\" name=\"path_id\" value=\"", htmlspecialchars($_REQUEST['path_id']), "\" />\n";
896
			echo $misc->form;
897
			echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
898
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
899
			echo "</form>\n";
900
		}
901
		else {
902
			$status = $slony->dropPath($_REQUEST['no_id'], $_REQUEST['path_id']);
903
			if ($status == 0)
904
				doPaths($lang['strpathdropped']);
905
			else
906
				doPaths($lang['strpathdroppedbad']);
907
		}
908
	}
909
	
910
	// LISTENS
911
	
912
	/**
913
	 * List all the listens
914
	 */
915
	function doListens($msg = '') {
916
		global $PHP_SELF, $slony, $misc;
917
		global $lang;
918

    
919
		$misc->printTrail('database');
920
		$misc->printMsg($msg);
921

    
922
		$listens = $slony->getListens($_REQUEST['no_id']);
923

    
924
		$columns = array(
925
			'no_name' => array(
926
				'title' => $lang['strname'],
927
				'field' => 'no_comment'
928
			),
929
			'actions' => array(
930
				'title' => $lang['stractions'],
931
			),
932
			'no_comment' => array(
933
				'title' => $lang['strcomment'],
934
				'field' => 'no_comment'
935
			)
936
		);
937
		
938
		$actions = array (
939
			'properties' => array(
940
				'title' => $lang['strproperties'],
941
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=listen_properties&amp;",
942
				'vars'  => array('no_id' => 'li_receiver', 'listen_id' => 'no_id', 'origin_id' => 'li_origin')
943
			),
944
			'drop' => array(
945
				'title' => $lang['strdrop'],
946
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_drop_listen&amp;",
947
				'vars'  => array('no_id' => 'li_receiver', 'listen_id' => 'no_id', 'origin_id' => 'li_origin')
948
			)
949

    
950
		);
951
		
952
		$misc->printTable($listens, $columns, $actions, $lang['strnolistens']);
953

    
954
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=create_listen&amp;{$misc->href}&amp;no_id={$_REQUEST['no_id']}\">{$lang['strcreatelisten']}</a></p>\n";
955
	}
956

    
957
	/**
958
	 * Display the properties of a listen
959
	 */	 
960
	function doListen($msg = '') {
961
		global $data, $slony, $misc, $PHP_SELF;
962
		global $lang;
963
		
964
		$misc->printTrail('slony_path');
965
		$misc->printTitle($lang['strproperties']);
966
		$misc->printMsg($msg);
967
		
968
		// Fetch the listen information
969
		$listen = $slony->getListen($_REQUEST['no_id'], $_REQUEST['listen_id']);		
970
		
971
		if (is_object($listen) && $listen->recordCount() > 0) {			
972
			// Show comment if any
973
			if ($listen->f['no_comment'] !== null)
974
				echo "<p class=\"comment\">", $misc->printVal($listen->f['no_comment']), "</p>\n";
975

    
976
			echo "<table>\n";
977
			echo "<tr><th class=\"data left\" width=\"70\">Provider</th>\n";
978
			echo "<td class=\"data1\">", $misc->printVal($listen->f['no_comment']), "</td></tr>\n";
979
			echo "<tr><th class=\"data left\" width=\"70\">Provider ID</th>\n";
980
			echo "<td class=\"data1\">", $misc->printVal($listen->f['li_provider']), "</td></tr>\n";
981
			echo "<tr><th class=\"data left\" width=\"70\">Origin</th>\n";
982
			echo "<td class=\"data1\">", $misc->printVal($listen->f['origin']), "</td></tr>\n";
983
			echo "<tr><th class=\"data left\" width=\"70\">Origin ID</th>\n";
984
			echo "<td class=\"data1\">", $misc->printVal($listen->f['li_origin']), "</td></tr>\n";
985
			echo "</table>\n";
986
		}
987
		else echo "<p>{$lang['strnodata']}</p>\n";
988

    
989
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_drop_listen&amp;{$misc->href}&amp;no_id={$_REQUEST['no_id']}&amp;listen_id={$_REQUEST['listen_id']}&amp;origin_id={$listen->f['li_origin']}\">{$lang['strdrop']}</a></p>\n";
990
	}
991

    
992
	/**
993
	 * Displays a screen where they can enter a new listen
994
	 */
995
	function doCreateListen($confirm, $msg = '') {
996
		global $data, $slony, $misc;
997
		global $PHP_SELF, $lang;
998
		
999
		if ($confirm) {
1000
			if (!isset($_POST['listenorigin'])) $_POST['listenorigin'] = '';
1001
			if (!isset($_POST['listenprovider'])) $_POST['listenprovider'] = '';
1002
	
1003
			// Fetch all servers
1004
			$nodes = $slony->getNodes();
1005

    
1006
			$misc->printTrail('slony_listens');
1007
			$misc->printTitle($lang['strcreatelisten']);
1008
			$misc->printMsg($msg);
1009
	
1010
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1011
			echo $misc->form;
1012
			echo "<table width=\"100%\">\n";
1013
			echo "\t<tr>\n\t\t<th class=\"data left required\">Origin</th>\n";
1014
			echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"listenorigin\">\n";
1015
			while (!$nodes->EOF) {
1016
				echo "\t\t\t\t<option value=\"{$nodes->f['no_id']}\"",
1017
					($nodes->f['no_id'] == $_POST['listenorigin']) ? ' selected="selected"' : '', ">", htmlspecialchars($nodes->f['no_comment']), "</option>\n";
1018
				$nodes->moveNext();
1019
			}
1020
			echo "\t\t\t</select>\n\t\t</td>\n\t\n";
1021
			echo "\t<tr>\n\t\t<th class=\"data left required\">Provider</th>\n";
1022
			echo "\t\t<td class=\"data1\">\n\t\t\t<select name=\"listenprovider\">\n";
1023
			$nodes->moveFirst();
1024
			while (!$nodes->EOF) {
1025
				echo "\t\t\t\t<option value=\"{$nodes->f['no_id']}\"",
1026
					($nodes->f['no_id'] == $_POST['listenprovider']) ? ' selected="selected"' : '', ">", htmlspecialchars($nodes->f['no_comment']), "</option>\n";
1027
				$nodes->moveNext();
1028
			}
1029
			echo "\t\t\t</select>\n\t\t</td>\n\t\n";		
1030
			echo "\t</tr>\n";
1031
			echo "</table>\n";
1032
			echo "<p>\n";
1033
			echo "<input type=\"hidden\" name=\"action\" value=\"save_create_listen\" />\n";
1034
			echo "<input type=\"hidden\" name=\"no_id\" value=\"", htmlspecialchars($_REQUEST['no_id']), "\" />\n";
1035
			echo "<input type=\"submit\" value=\"{$lang['strcreate']}\" />\n";
1036
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1037
			echo "</p>\n";
1038
			echo "</form>\n";
1039
		}
1040
		else {
1041
			$status = $slony->createListen($_POST['no_id'], $_POST['listenorigin'], $_POST['listenprovider']);
1042
			if ($status == 0)
1043
				doListens($lang['strlistencreated']);
1044
			else
1045
				doCreateListen(true, $lang['strlistencreatedbad']);
1046
		}
1047
	}
1048

    
1049
	/**
1050
	 * Show confirmation of drop and perform actual drop of a listen
1051
	 */
1052
	function doDropListen($confirm) {
1053
		global $slony, $misc;
1054
		global $PHP_SELF, $lang;
1055

    
1056
		if ($confirm) {
1057
			$misc->printTrail('slony_cluster');
1058
			$misc->printTitle($lang['strdrop']);
1059

    
1060
			echo "<p>", sprintf($lang['strconfdroplisten'], $misc->printVal($_REQUEST['listen_id'])), "</p>\n";
1061

    
1062
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1063
			echo "<input type=\"hidden\" name=\"action\" value=\"drop_listen\" />\n";
1064
			echo "<input type=\"hidden\" name=\"no_id\" value=\"", htmlspecialchars($_REQUEST['no_id']), "\" />\n";
1065
			echo "<input type=\"hidden\" name=\"listen_id\" value=\"", htmlspecialchars($_REQUEST['listen_id']), "\" />\n";
1066
			echo "<input type=\"hidden\" name=\"origin_id\" value=\"", htmlspecialchars($_REQUEST['origin_id']), "\" />\n";
1067
			echo $misc->form;
1068
			echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
1069
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1070
			echo "</form>\n";
1071
		}
1072
		else {
1073
			$status = $slony->dropListen($_REQUEST['no_id'], $_REQUEST['origin_id'], $_REQUEST['listen_id']);
1074
			if ($status == 0)
1075
				doListens($lang['strlistendropped']);
1076
			else
1077
				doListens($lang['strlistendroppedbad']);
1078
		}
1079
	}
1080
	
1081
	// REPLICATION SETS
1082
		
1083
	/**
1084
	 * List all the replication sets
1085
	 */
1086
	function doReplicationSets($msg = '') {
1087
		global $PHP_SELF, $slony, $misc;
1088
		global $lang;
1089

    
1090
		$misc->printTrail('slony_cluster');
1091
		$misc->printTabs('slony_cluster', 'sets');
1092
		$misc->printMsg($msg);
1093

    
1094
		$sets = $slony->getReplicationSets();
1095

    
1096
		$columns = array(
1097
			'set_name' => array(
1098
				'title' => $lang['strname'],
1099
				'field' => 'set_comment'
1100
			),
1101
			'actions' => array(
1102
				'title' => $lang['stractions'],
1103
			),
1104
			'set_comment' => array(
1105
				'title' => $lang['strcomment'],
1106
				'field' => 'set_comment'
1107
			)
1108
		);
1109
		
1110
		$actions = array (
1111
			'properties' => array(
1112
				'title' => $lang['strproperties'],
1113
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=set_properties&amp;",
1114
				'vars'  => array('set_id' => 'set_id')
1115
			),
1116
			'drop' => array(
1117
				'title' => $lang['strdrop'],
1118
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_drop_set&amp;",
1119
				'vars'  => array('set_id' => 'set_id')
1120
			),
1121
			'lock' => array(
1122
				'title' => $lang['strlock'],
1123
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_lock_set&amp;",
1124
				'vars'  => array('set_id' => 'set_id')
1125
			),
1126
			'unlock' => array(
1127
				'title' => $lang['strunlock'],
1128
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_unlock_set&amp;",
1129
				'vars'  => array('set_id' => 'set_id')
1130
			),
1131
			'merge' => array(
1132
				'title' => $lang['strmerge'],
1133
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=merge_set&amp;",
1134
				'vars'  => array('set_id' => 'set_id')
1135
			),
1136
			'move' => array(
1137
				'title' => $lang['strmove'],
1138
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=move_set&amp;",
1139
				'vars'  => array('set_id' => 'set_id')
1140
			),
1141
			'execute' => array(
1142
				'title' => $lang['strexecute'],
1143
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=execute_set&amp;",
1144
				'vars'  => array('set_id' => 'set_id')
1145
			)
1146
		);
1147
		
1148
		$misc->printTable($sets, $columns, $actions, $lang['strnorepsets']);
1149
		
1150
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=create_set&amp;{$misc->href}\">{$lang['strcreaterepset']}</a></p>\n";
1151
	}	
1152

    
1153
	/**
1154
	 * Display the properties of a replication set
1155
	 */	 
1156
	function doReplicationSet($msg = '') {
1157
		global $data, $slony, $misc, $PHP_SELF;
1158
		global $lang;
1159
		
1160
		$misc->printTrail('slony_set');
1161
		$misc->printTitle($lang['strproperties']);
1162
		$misc->printMsg($msg);
1163
		
1164
		// Fetch the set information
1165
		$set = $slony->getReplicationSet($_REQUEST['set_id']);		
1166
		
1167
		if (is_object($set) && $set->recordCount() > 0) {			
1168
			// Show comment if any
1169
			if ($set->f['set_comment'] !== null)
1170
				echo "<p class=\"comment\">", $misc->printVal($set->f['set_comment']), "</p>\n";
1171

    
1172
			echo "<table>\n";
1173
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strname']}</th>\n";
1174
			echo "<td class=\"data1\">", $misc->printVal($set->f['set_comment']), "</td></tr>\n";
1175
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strid']}</th>\n";
1176
			echo "<td class=\"data1\">", $misc->printVal($set->f['set_id']), "</td></tr>\n";
1177
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strlocked']}</th>\n";
1178
			echo "<td class=\"data1\">", ($data->phpBool($set->f['is_locked'])) ? $lang['stryes'] : $lang['strno'], "</td></tr>\n";
1179
			echo "<tr><th class=\"data left\" width=\"70\">Origin ID</th>\n";
1180
			echo "<td class=\"data1\">", $misc->printVal($set->f['set_origin']), "</td></tr>\n";
1181
			echo "<tr><th class=\"data left\" width=\"70\">Origin Node</th>\n";
1182
			echo "<td class=\"data1\">", $misc->printVal($set->f['no_comment']), "</td></tr>\n";
1183
			echo "<tr><th class=\"data left\" width=\"70\">Subscriptions</th>\n";
1184
			echo "<td class=\"data1\">", $misc->printVal($set->f['subscriptions']), "</td></tr>\n";
1185
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['strcomment']}</th>\n";
1186
			echo "<td class=\"data1\">", $misc->printVal($set->f['set_comment']), "</td></tr>\n";
1187
			echo "</table>\n";
1188
		}
1189
		else echo "<p>{$lang['strnodata']}</p>\n";
1190

    
1191
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_drop_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strdrop']}</a> |\n";
1192
		echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_lock_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strlock']}</a> |\n";
1193
		echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=confirm_unlock_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strunlock']}</a> |\n";
1194
		echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=merge_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strmerge']}</a> |\n";
1195
		echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=move_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strmove']}</a> |\n";
1196
		echo "<a class=\"navlink\" href=\"{$PHP_SELF}?action=execute_set&amp;{$misc->href}&amp;set_id={$_REQUEST['set_id']}\">{$lang['strexecute']}</a></p>\n";
1197
	}
1198

    
1199
	/**
1200
	 * Displays a screen where they can enter a new set
1201
	 */
1202
	function doCreateReplicationSet($confirm, $msg = '') {
1203
		global $slony, $misc;
1204
		global $PHP_SELF, $lang;
1205
		
1206
		if ($confirm) {
1207
			if (!isset($_POST['setid'])) $_POST['setid'] = '';
1208
			if (!isset($_POST['setcomment'])) $_POST['setcomment'] = '';
1209
	
1210
			$misc->printTrail('slony_sets');
1211
			$misc->printTitle($lang['strcreaterepset']);
1212
			$misc->printMsg($msg);
1213
	
1214
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1215
			echo $misc->form;
1216
			echo "<table width=\"100%\">\n";
1217
			echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strid']}</th>\n";
1218
			echo "\t\t<td class=\"data1\"><input name=\"setid\" size=\"5\" value=\"",
1219
				htmlspecialchars($_POST['setid']), "\" /></td>\n\t</tr>\n";
1220
			echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n";
1221
			echo "\t\t<td class=\"data1\"><textarea name=\"setcomment\" rows=\"3\" cols=\"32\" wrap=\"virtual\">", 
1222
				htmlspecialchars($_POST['setcomment']), "</textarea></td>\n\t</tr>\n";
1223
				
1224
			echo "\t</tr>\n";
1225
			echo "</table>\n";
1226
			echo "<p>\n";
1227
			echo "<input type=\"hidden\" name=\"action\" value=\"save_create_set\" />\n";
1228
			echo "<input type=\"submit\" value=\"{$lang['strcreate']}\" />\n";
1229
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1230
			echo "</p>\n";
1231
			echo "</form>\n";
1232
		}
1233
		else {
1234
			$status = $slony->createReplicationSet($_POST['setid'], $_POST['setcomment']);
1235
			if ($status == 0)
1236
				doReplicationSets($lang['strrepsetcreated']);
1237
			else
1238
				doCreateReplicationSet(true, $lang['strrepsetcreatedbad']);
1239
		}
1240
	}
1241

    
1242
	/**
1243
	 * Show confirmation of drop and perform actual drop of a set
1244
	 */
1245
	function doDropReplicationSet($confirm) {
1246
		global $slony, $misc;
1247
		global $PHP_SELF, $lang;
1248

    
1249
		if ($confirm) {
1250
			$misc->printTrail('slony_cluster');
1251
			$misc->printTitle($lang['strdrop']);
1252

    
1253
			echo "<p>", sprintf($lang['strconfdroprepset'], $misc->printVal($_REQUEST['set_id'])), "</p>\n";
1254

    
1255
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1256
			echo "<input type=\"hidden\" name=\"action\" value=\"drop_set\" />\n";
1257
			echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1258
			echo $misc->form;
1259
			echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strdrop']}\" />\n";
1260
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1261
			echo "</form>\n";
1262
		}
1263
		else {
1264
			$status = $slony->dropReplicationSet($_REQUEST['set_id']);
1265
			if ($status == 0)
1266
				doReplicationSet($lang['strrepsetdropped']);
1267
			else
1268
				doReplicationSet($lang['strrepsetdroppedbad']);
1269
		}
1270
	}
1271

    
1272
	/**
1273
	 * Show confirmation of lock and perform actual lock of a set
1274
	 */
1275
	function doLockReplicationSet($confirm) {
1276
		global $slony, $misc;
1277
		global $PHP_SELF, $lang;
1278

    
1279
		if ($confirm) {
1280
			$misc->printTrail('slony_cluster');
1281
			$misc->printTitle($lang['strlock']);
1282

    
1283
			echo "<p>", sprintf($lang['strconflockrepset'], $misc->printVal($_REQUEST['set_id'])), "</p>\n";
1284

    
1285
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1286
			echo "<input type=\"hidden\" name=\"action\" value=\"lock_set\" />\n";
1287
			echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1288
			echo $misc->form;
1289
			echo "<input type=\"submit\" name=\"lock\" value=\"{$lang['strlock']}\" />\n";
1290
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1291
			echo "</form>\n";
1292
		}
1293
		else {
1294
			$status = $slony->lockReplicationSet($_REQUEST['set_id'], true);
1295
			if ($status == 0)
1296
				doReplicationSet($lang['strrepsetlocked']);
1297
			else
1298
				doReplicationSet($lang['strrepsetlockedbad']);
1299
		}
1300
	}
1301

    
1302
	/**
1303
	 * Show confirmation of unlock and perform actual unlock of a set
1304
	 */
1305
	function doUnlockReplicationSet($confirm) {
1306
		global $slony, $misc;
1307
		global $PHP_SELF, $lang;
1308

    
1309
		if ($confirm) {
1310
			$misc->printTrail('slony_cluster');
1311
			$misc->printTitle($lang['strunlock']);
1312

    
1313
			echo "<p>", sprintf($lang['strconfunlockrepset'], $misc->printVal($_REQUEST['set_id'])), "</p>\n";
1314

    
1315
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1316
			echo "<input type=\"hidden\" name=\"action\" value=\"unlock_set\" />\n";
1317
			echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1318
			echo $misc->form;
1319
			echo "<input type=\"submit\" name=\"unlock\" value=\"{$lang['strunlock']}\" />\n";
1320
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1321
			echo "</form>\n";
1322
		}
1323
		else {
1324
			$status = $slony->lockReplicationSet($_REQUEST['set_id'], false);
1325
			if ($status == 0)
1326
				doReplicationSets($lang['strrepsetunlocked']);
1327
			else
1328
				doReplicationSets($lang['strrepsetunlockedbad']);
1329
		}
1330
	}
1331
	
1332
	/**
1333
	 * Displays a screen where they can merge one set into another
1334
	 */
1335
	function doMergeReplicationSet($confirm, $msg = '') {
1336
		global $slony, $misc;
1337
		global $PHP_SELF, $lang;
1338
		
1339
		if ($confirm) {
1340
			if (!isset($_POST['target'])) $_POST['target'] = '';
1341
	
1342
			$sets = $slony->getReplicationSets();
1343
	
1344
			$misc->printTrail('slony_sets');
1345
			$misc->printTitle($lang['strmerge']);
1346
			$misc->printMsg($msg);
1347
	
1348
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1349
			echo $misc->form;
1350
			echo "<table>\n";
1351
			echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strmergeinto']}</th>\n";
1352
			echo "<td class=\"data1\" colspan=\"3\"><select name=\"target\">";
1353
			while (!$sets->EOF) {
1354
				if ($sets->f['set_id'] != $_REQUEST['set_id']) {
1355
					echo "<option value=\"{$sets->f['set_id']}\">";
1356
					echo htmlspecialchars($sets->f['set_comment']), "</option>\n";
1357
				}
1358
				$sets->moveNext();	
1359
			}
1360
			echo "</select></td></tr>\n";
1361
			echo "</table>\n";
1362
			echo "<p>\n";
1363
			echo "<input type=\"hidden\" name=\"action\" value=\"save_merge_set\" />\n";
1364
			echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1365
			echo "<input type=\"submit\" value=\"{$lang['strmerge']}\" />\n";
1366
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1367
			echo "</p>\n";
1368
			echo "</form>\n";
1369
		}
1370
		else {
1371
			$status = $slony->mergeReplicationSet($_POST['set_id'], $_POST['target']);
1372
			if ($status == 0)
1373
				doReplicationSet($lang['strrepsetmerged']);
1374
			else
1375
				doMergeReplicationSet(true, $lang['strrepsetmergedbad']);
1376
		}
1377
	}
1378

    
1379
	/**
1380
	 * Displays a screen where they can move one set into another
1381
	 */
1382
	function doMoveReplicationSet($confirm, $msg = '') {
1383
		global $slony, $misc;
1384
		global $PHP_SELF, $lang;
1385
		
1386
		if ($confirm) {
1387
			if (!isset($_POST['new_origin'])) $_POST['new_origin'] = '';
1388
	
1389
			$nodes = $slony->getNodes();
1390
			$set = $slony->getReplicationSet($_REQUEST['set_id']);
1391
	
1392
			$misc->printTrail('slony_sets');
1393
			$misc->printTitle($lang['strmove']);
1394
			$misc->printMsg($msg);
1395
	
1396
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1397
			echo $misc->form;
1398
			echo "<table>\n";
1399
			echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strneworigin']}</th>\n";
1400
			echo "<td class=\"data1\" colspan=\"3\"><select name=\"new_origin\">";
1401
			while (!$nodes->EOF) {
1402
				if ($nodes->f['no_id'] != $set->f['set_origin']) {
1403
					echo "<option value=\"{$nodes->f['no_id']}\">";
1404
					echo htmlspecialchars($nodes->f['no_comment']), "</option>\n";
1405
				}
1406
				$nodes->moveNext();	
1407
			}
1408
			echo "</select></td></tr>\n";
1409
			echo "</table>\n";
1410
			echo "<p>\n";
1411
			echo "<input type=\"hidden\" name=\"action\" value=\"save_move_set\" />\n";
1412
			echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1413
			echo "<input type=\"submit\" value=\"{$lang['strmove']}\" />\n";
1414
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1415
			echo "</p>\n";
1416
			echo "</form>\n";
1417
		}
1418
		else {
1419
			$status = $slony->moveReplicationSet($_POST['set_id'], $_POST['new_origin']);
1420
			if ($status == 0)
1421
				doReplicationSet($lang['strrepsetmoved']);
1422
			else
1423
				doMoveReplicationSet(true, $lang['strrepsetmovedbad']);
1424
		}
1425
	}
1426

    
1427
	/**
1428
	 * Displays a screen where they can enter a DDL script to
1429
	 * be executed on all or a particular node, for this set.
1430
	 */
1431
	function doExecuteReplicationSet($confirm, $msg = '') {
1432
		global $slony, $misc;
1433
		global $PHP_SELF, $lang;
1434
		
1435
		if ($confirm) {
1436
			if (!isset($_POST['script'])) $_POST['script'] = '';
1437
	
1438
			$nodes = $slony->getNodes();
1439
	
1440
			$misc->printTrail('slony_sets');
1441
			$misc->printTitle($lang['strexecute']);
1442
			$misc->printMsg($msg);
1443
	
1444
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1445
			echo $misc->form;
1446
			echo "<table>\n";
1447
			/* Slony 1.1 only
1448
			echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['stronlyonnode']}</th>\n";
1449
			echo "<td class=\"data1\" colspan=\"3\"><select name=\"only_on_node\">";
1450
			echo "<option value=\"0\"></option>\n";
1451
			while (!$nodes->EOF) {
1452
				echo "<option value=\"{$nodes->f['no_id']}\"", ($_POST['only_on_node'] == $nodes->f['no_id'] ? ' selected="selected"' : ''), ">";
1453
				echo htmlspecialchars($nodes->f['no_comment']), "</option>\n";
1454
				$nodes->moveNext();	
1455
			}
1456
			echo "</select></td></tr>\n";
1457
			*/
1458
			echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strddlscript']}</th>\n";
1459
			echo "\t\t<td class=\"data1\"><textarea name=\"script\" rows=\"20\" cols=\"40\" wrap=\"virtual\">", 
1460
				htmlspecialchars($_POST['script']), "</textarea></td>\n\t</tr>\n";
1461
			echo "</table>\n";
1462
			echo "<p>\n";
1463
			echo "<input type=\"hidden\" name=\"action\" value=\"save_execute_set\" />\n";
1464
			echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1465
			echo "<input type=\"submit\" value=\"{$lang['strexecute']}\" />\n";
1466
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1467
			echo "</p>\n";
1468
			echo "</form>\n";
1469
		}
1470
		else {
1471
			if (trim($_POST['script']) == '') {
1472
				doExecuteReplicationSet(true, $lang['strscriptneedsbody']);
1473
				return;
1474
			}
1475
			
1476
			$status = $slony->executeReplicationSet($_POST['set_id'], $_POST['script']);
1477
			if ($status == 0)
1478
				doReplicationSet($lang['strscriptexecuted']);
1479
			else
1480
				doExecuteReplicationSet(true, $lang['strscriptexecutedbad']);
1481
		}
1482
	}
1483
			
1484
	// TABLES
1485
	
1486
	/**
1487
	 * List all the tables in a replication set
1488
	 */
1489
	function doTables($msg = '') {
1490
		global $PHP_SELF, $data, $slony, $misc;
1491
		global $lang;
1492

    
1493
		$misc->printTrail('database');
1494
		$misc->printMsg($msg);
1495

    
1496
		$tables = $slony->getTables($_REQUEST['set_id']);
1497

    
1498
		$columns = array(
1499
			'table' => array(
1500
				'title' => $lang['strtable'],
1501
				'field' => 'qualname',
1502
			),
1503
			'owner' => array(
1504
				'title' => $lang['strowner'],
1505
				'field' => 'relowner',
1506
			),
1507
			'tablespace' => array(
1508
				'title' => $lang['strtablespace'],
1509
				'field' => 'tablespace'
1510
			),
1511
			'tuples' => array(
1512
				'title' => $lang['strestimatedrowcount'],
1513
				'field' => 'reltuples',
1514
				'type'  => 'numeric'
1515
			),
1516
			'actions' => array(
1517
				'title' => $lang['stractions'],
1518
			),
1519
			'comment' => array(
1520
				'title' => $lang['strcomment'],
1521
				'field' => 'relcomment',
1522
			),
1523
		);
1524
		
1525
		$actions = array(
1526
			'properties' => array(
1527
				'title' => $lang['strproperties'],
1528
				'url'   => "redirect.php?subject=table&amp;{$misc->href}&amp;",
1529
				'vars'  => array('table' => 'relname', 'schema' => 'nspname'),
1530
			),
1531
			'remove' => array(
1532
				'title' => $lang['strremove'],
1533
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_drop_table&amp;set_id={$_REQUEST['set_id']}&amp;",
1534
				'vars'  => array('tab_id' => 'tab_id', 'qualname' => 'qualname'),
1535
			),
1536
			'move' => array(
1537
				'title' => $lang['strmove'],
1538
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=move_table&amp;set_id={$_REQUEST['set_id']}&amp;stage=1&amp;",
1539
				'vars'  => array('tab_id' => 'tab_id'),
1540
			)
1541
		);
1542
		
1543
		if (!$data->hasTablespaces()) unset($columns['tablespace']);
1544

    
1545
		$misc->printTable($tables, $columns, $actions, $lang['strnotables']);
1546
		
1547
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=add_table&amp;stage=1&amp;set_id={$_REQUEST['set_id']}&amp;{$misc->href}\">{$lang['straddtable']}</a></p>\n";
1548
	}
1549

    
1550
	/**
1551
	 * Displays a screen where they can add a table to a 
1552
	 * replication set.
1553
	 */
1554
	function doAddTable($stage, $msg = '') {
1555
		global $data, $slony, $misc;
1556
		global $PHP_SELF, $lang;
1557
		
1558
		switch ($stage) {
1559
			case 1:
1560
				if (!isset($_POST['tab_id'])) $_POST['tab_id'] = '';
1561
				if (!isset($_POST['comment'])) $_POST['comment'] = '';
1562
				
1563
				$tables = $data->getTables(true);
1564
		
1565
				$misc->printTrail('slony_sets');
1566
				$misc->printTitle($lang['straddtable']);
1567
				$misc->printMsg($msg);
1568
		
1569
				echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1570
				echo $misc->form;
1571
				echo "<table width=\"100%\">\n";
1572
				echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strtable']}</th>\n";
1573
				echo "<td class=\"data1\" colspan=\"3\"><select name=\"target\">";
1574
				while (!$tables->EOF) {
1575
					$key = array('schemaname' => $tables->f['nspname'], 'tablename' => $tables->f['relname']);
1576
					$key = serialize($key);
1577
					echo "<option value=\"", htmlspecialchars($key), "\">";
1578
					echo htmlspecialchars($tables->f['nspname']), '.';
1579
					echo htmlspecialchars($tables->f['relname']), "</option>\n";
1580
					$tables->moveNext();	
1581
				}
1582
				echo "</select></td></tr>\n";
1583
				echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strid']}</th>\n";
1584
				echo "\t\t<td class=\"data1\"><input name=\"tab_id\" size=\"5\" value=\"",
1585
					htmlspecialchars($_POST['tab_id']), "\" /></td>\n\t</tr>\n";
1586
				echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n";
1587
				echo "\t\t<td class=\"data1\"><textarea name=\"comment\" rows=\"3\" cols=\"32\" wrap=\"virtual\">", 
1588
					htmlspecialchars($_POST['comment']), "</textarea></td>\n\t</tr>\n";
1589
					
1590
				echo "\t</tr>\n";
1591
				echo "</table>\n";
1592
				echo "<p>\n";
1593
				echo "<input type=\"hidden\" name=\"action\" value=\"add_table\" />\n";
1594
				echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1595
				echo "<input type=\"hidden\" name=\"stage\" value=\"2\" />\n";
1596
				echo "<input type=\"submit\" value=\"{$lang['strnext']}\" />\n";
1597
				echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1598
				echo "</p>\n";
1599
				echo "</form>\n";
1600
				break;
1601
			case 2:
1602
				// Unserialize table and fetch. This is a bit messy
1603
				// because the table could be in another schema.
1604
				$_REQUEST['target'] = unserialize($_REQUEST['target']);
1605
				$data->setSchema($_REQUEST['target']['schemaname']);
1606
				// Get indexes
1607
				$indexes = $data->getIndexes($_REQUEST['target']['tablename'], true);
1608
				if ($indexes->recordCount() == 0) {
1609
					doAddTable(1, $lang['strtableneedsuniquekey']);
1610
					return;
1611
				}
1612
				
1613
				// Get triggers
1614
				$triggers = $data->getTriggers($_REQUEST['target']['tablename']);				
1615

    
1616
				// If only one index and no triggers then jump to next step
1617
				if ($indexes->recordCount() == 1 && $triggers->recordCount() == 0) {
1618
					$_REQUEST['idxname'] = $indexes->f['indname'];
1619
					$_REQUEST['nspname'] = $_REQUEST['target']['schemaname'];
1620
					$_REQUEST['relname'] = $_REQUEST['target']['tablename'];
1621
					$_REQUEST['target'] = serialize($_REQUEST['target']);
1622
					doAddTable(3);
1623
					return;
1624
				}
1625
				
1626
				$misc->printTrail('slony_sets');
1627
				$misc->printTitle($lang['straddtable']);
1628
				$misc->printMsg($msg);
1629
		
1630
				echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1631
				echo $misc->form;
1632
				echo "<table>\n";
1633
				if ($indexes->recordCount() > 1) {
1634
					echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strindex']}</th>\n";
1635
					echo "<td class=\"data1\" colspan=\"3\"><select name=\"idxname\">";
1636
					while (!$indexes->EOF) {
1637
						echo "<option value=\"", htmlspecialchars($indexes->f['indname']), "\">";
1638
						echo htmlspecialchars($indexes->f['indname']), "</option>\n";
1639
						$indexes->moveNext();	
1640
					}
1641
					echo "</select></td></tr>\n";
1642
				}
1643
				else {
1644
					echo "<input type=\"hidden\" name=\"idxname\" value=\"", htmlspecialchars($indexes->f['indname']), "\" />\n";
1645
				}
1646
				if ($triggers->recordCount() > 0) {
1647
					echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strtriggers']}</th>\n";
1648
					echo "<td class=\"data1\" colspan=\"3\"><p>{$lang['strtabletriggerstoretain']}</p>\n";
1649
					while (!$triggers->EOF) {
1650
						echo "<input type=\"checkbox\" name=\"storedtriggers[", htmlspecialchars($triggers->f['tgname']), "]\">";
1651
						echo htmlspecialchars($triggers->f['tgname']), "<br/>\n";
1652
						$triggers->moveNext();	
1653
					}
1654
					echo "</select></td></tr>\n";					
1655
				}
1656
				echo "</table>\n";
1657
				echo "<p>\n";
1658
				echo "<input type=\"hidden\" name=\"action\" value=\"add_table\" />\n";
1659
				echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1660
				echo "<input type=\"hidden\" name=\"tab_id\" value=\"", htmlspecialchars($_REQUEST['tab_id']), "\" />\n";
1661
				echo "<input type=\"hidden\" name=\"comment\" value=\"", htmlspecialchars($_REQUEST['comment']), "\" />\n";
1662
				echo "<input type=\"hidden\" name=\"nspname\" value=\"", htmlspecialchars($_REQUEST['target']['schemaname']), "\" />\n";
1663
				echo "<input type=\"hidden\" name=\"relname\" value=\"", htmlspecialchars($_REQUEST['target']['tablename']), "\" />\n";
1664
				echo "<input type=\"hidden\" name=\"target\" value=\"", htmlspecialchars(serialize($_REQUEST['target'])), "\" />\n";
1665
				echo "<input type=\"hidden\" name=\"stage\" value=\"3\" />\n";
1666
				echo "<input type=\"submit\" value=\"{$lang['stradd']}\" />\n";
1667
				echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1668
				echo "</p>\n";
1669
				echo "</form>\n";
1670
				break;
1671
			case 3:
1672
				if (!isset($_REQUEST['storedtriggers'])) $_REQUEST['storedtriggers'] = array();
1673
				$status = $slony->addTable($_REQUEST['set_id'], $_REQUEST['tab_id'], $_REQUEST['nspname'], $_REQUEST['relname'], 
1674
														$_REQUEST['idxname'], $_REQUEST['comment'], array_keys($_REQUEST['storedtriggers']));
1675
				if ($status == 0)
1676
					doTables($lang['strtableaddedtorepset']);
1677
				else
1678
					doAddTable(2, $lang['strtableaddedtorepsetbad']);
1679
				break;
1680
		}
1681
	}
1682

    
1683
	/**
1684
	 * Displays a screen where they can move a table to a 
1685
	 * replication set.
1686
	 */
1687
	function doMoveTable($stage, $msg = '') {
1688
		global $data, $slony, $misc;
1689
		global $PHP_SELF, $lang;
1690
		
1691
		switch ($stage) {
1692
			case 1:
1693
				if (!isset($_POST['new_set_id'])) $_POST['new_set_id'] = '';
1694
				
1695
				$sets = $slony->getReplicationSets();
1696
		
1697
				$misc->printTrail('slony_sets');
1698
				$misc->printTitle($lang['strmove']);
1699
				$misc->printMsg($msg);
1700
		
1701
				echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1702
				echo $misc->form;
1703
				echo "<table>\n";
1704
				echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strnewrepset']}</th>\n";
1705
				echo "<td class=\"data1\" colspan=\"3\"><select name=\"new_set_id\">";
1706
				while (!$sets->EOF) {
1707
					if ($sets->f['set_id'] != $_REQUEST['set_id']) {
1708
						echo "<option value=\"{$sets->f['set_id']}\">";
1709
						echo htmlspecialchars($sets->f['set_comment']), "</option>\n";
1710
					}
1711
					$sets->moveNext();	
1712
				}
1713
				echo "</select></td></tr>\n";
1714
				echo "</table>\n";
1715
				echo "<p>\n";
1716
				echo "<input type=\"hidden\" name=\"action\" value=\"move_table\" />\n";
1717
				echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1718
				echo "<input type=\"hidden\" name=\"tab_id\" value=\"", htmlspecialchars($_REQUEST['tab_id']), "\" />\n";
1719
				echo "<input type=\"hidden\" name=\"stage\" value=\"2\" />\n";
1720
				echo "<input type=\"submit\" value=\"{$lang['strmove']}\" />\n";
1721
				echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1722
				echo "</p>\n";
1723
				echo "</form>\n";
1724
				break;
1725
			case 2:
1726
				$status = $slony->moveTable($_REQUEST['tab_id'], $_REQUEST['new_set_id']);
1727
				if ($status == 0)
1728
					doTables('Table moved to replication set.');
1729
				else
1730
					doMoveTable(1, 'Failed moving table to replication set.');
1731
				break;
1732
		}
1733
	}
1734

    
1735
	/**
1736
	 * Show confirmation of drop and perform actual drop of a table from a
1737
	 * replication set.
1738
	 */
1739
	function doRemoveTable($confirm) {
1740
		global $slony, $misc;
1741
		global $PHP_SELF, $lang;
1742

    
1743
		if ($confirm) {
1744
			$misc->printTrail('slony_cluster');
1745
			$misc->printTitle('Remove');
1746

    
1747
			echo "<p>", sprintf($lang['strconfremovetablefromrepset'], 
1748
				$misc->printVal($_REQUEST['qualname']), $misc->printVal($_REQUEST['set_id'])), "</p>\n";
1749

    
1750
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1751
			echo "<input type=\"hidden\" name=\"action\" value=\"drop_table\" />\n";
1752
			echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1753
			echo "<input type=\"hidden\" name=\"tab_id\" value=\"", htmlspecialchars($_REQUEST['tab_id']), "\" />\n";
1754
			echo $misc->form;
1755
			echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strremove']}\" />\n";
1756
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1757
			echo "</form>\n";
1758
		}
1759
		else {
1760
			$status = $slony->removeTable($_REQUEST['tab_id']);
1761
			if ($status == 0)
1762
				doTables($lang['strtableremovedfromrepset']);
1763
			else
1764
				doTables($lang['strtableremovedfromrepsetbad']);
1765
		}
1766
	}
1767

    
1768
	// SEQUENCES
1769
	
1770
	/**
1771
	 * List all the sequences in a replication set
1772
	 */
1773
	function doSequences($msg = '') {
1774
		global $PHP_SELF, $data, $slony, $misc;
1775
		global $lang;
1776

    
1777
		$misc->printTrail('database');
1778
		$misc->printMsg($msg);
1779

    
1780
		$sequences = $slony->getSequences($_REQUEST['set_id']);
1781

    
1782
		$columns = array(
1783
			'sequence' => array(
1784
				'title' => $lang['strsequence'],
1785
				'field' => 'qualname',
1786
			),
1787
			'owner' => array(
1788
				'title' => $lang['strowner'],
1789
				'field' => 'seqowner',
1790
			),
1791
			'actions' => array(
1792
				'title' => $lang['stractions'],
1793
			),
1794
			'comment' => array(
1795
				'title' => $lang['strcomment'],
1796
				'field' => 'seqcomment',
1797
			),
1798
		);
1799
		
1800
		$actions = array(
1801
			'properties' => array(
1802
				'title' => $lang['strproperties'],
1803
				'url'   => "sequences.php?action=properties&amp;{$misc->href}&amp;",
1804
				'vars'  => array('sequence' => 'seqname', 'schema' => 'nspname'),
1805
			),
1806
			'remove' => array(
1807
				'title' => $lang['strremove'],
1808
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=confirm_drop_sequence&amp;set_id={$_REQUEST['set_id']}&amp;",
1809
				'vars'  => array('seq_id' => 'seq_id', 'qualname' => 'qualname'),
1810
			),
1811
			'move' => array(
1812
				'title' => $lang['strmove'],
1813
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=move_sequence&amp;set_id={$_REQUEST['set_id']}&amp;stage=1&amp;",
1814
				'vars'  => array('seq_id' => 'seq_id'),
1815
			)
1816
		);
1817
		
1818
		$misc->printTable($sequences, $columns, $actions, $lang['strnosequences']);
1819
		
1820
		echo "<p><a class=\"navlink\" href=\"{$PHP_SELF}?action=add_sequence&amp;stage=1&amp;set_id={$_REQUEST['set_id']}&amp;{$misc->href}\">{$lang['straddsequence']}</a></p>\n";
1821
	}
1822

    
1823
	/**
1824
	 * Displays a screen where they can add a sequence to a 
1825
	 * replication set.
1826
	 */
1827
	function doAddSequence($stage, $msg = '') {
1828
		global $data, $slony, $misc;
1829
		global $PHP_SELF, $lang;
1830
		
1831
		switch ($stage) {
1832
			case 1:
1833
				if (!isset($_POST['seq_id'])) $_POST['seq_id'] = '';
1834
				if (!isset($_POST['comment'])) $_POST['comment'] = '';
1835
				
1836
				$sequences = $data->getSequences(true);
1837
		
1838
				$misc->printTrail('slony_sets');
1839
				$misc->printTitle($lang['straddsequence']);
1840
				$misc->printMsg($msg);
1841
		
1842
				echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1843
				echo $misc->form;
1844
				echo "<table width=\"100%\">\n";
1845
				echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strsequence']}</th>\n";
1846
				echo "<td class=\"data1\" colspan=\"3\"><select name=\"target\">";
1847
				while (!$sequences->EOF) {
1848
					$key = array('schemaname' => $sequences->f['nspname'], 'sequencename' => $sequences->f['seqname']);
1849
					$key = serialize($key);
1850
					echo "<option value=\"", htmlspecialchars($key), "\">";
1851
					echo htmlspecialchars($sequences->f['nspname']), '.';
1852
					echo htmlspecialchars($sequences->f['seqname']), "</option>\n";
1853
					$sequences->moveNext();	
1854
				}
1855
				echo "</select></td></tr>\n";
1856
				echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strid']}</th>\n";
1857
				echo "\t\t<td class=\"data1\"><input name=\"seq_id\" size=\"5\" value=\"",
1858
					htmlspecialchars($_POST['seq_id']), "\" /></td>\n\t</tr>\n";
1859
				echo "\t<tr>\n\t\t<th class=\"data left\">{$lang['strcomment']}</th>\n";
1860
				echo "\t\t<td class=\"data1\"><textarea name=\"comment\" rows=\"3\" cols=\"32\" wrap=\"virtual\">", 
1861
					htmlspecialchars($_POST['comment']), "</textarea></td>\n\t</tr>\n";
1862
					
1863
				echo "\t</tr>\n";
1864
				echo "</table>\n";
1865
				echo "<p>\n";
1866
				echo "<input type=\"hidden\" name=\"action\" value=\"add_sequence\" />\n";
1867
				echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1868
				echo "<input type=\"hidden\" name=\"stage\" value=\"2\" />\n";
1869
				echo "<input type=\"submit\" value=\"{$lang['stradd']}\" />\n";
1870
				echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1871
				echo "</p>\n";
1872
				echo "</form>\n";
1873
				break;
1874
			case 2:
1875
				// Unserialize sequence.
1876
				$_REQUEST['target'] = unserialize($_REQUEST['target']);
1877

    
1878
				$status = $slony->addSequence($_REQUEST['set_id'], $_REQUEST['seq_id'], 
1879
															$_REQUEST['target']['schemaname'] . '.' . $_REQUEST['target']['sequencename'],
1880
															$_REQUEST['comment']);
1881
				if ($status == 0)
1882
					doSequences($lang['strsequenceaddedtorepset']);
1883
				else
1884
					doAddSequence(1, $lang['strsequenceaddedtorepsetbad']);
1885
				break;
1886
		}
1887
	}
1888

    
1889
	/**
1890
	 * Show confirmation of drop and perform actual drop of a sequence from a
1891
	 * replication set.
1892
	 */
1893
	function doRemoveSequence($confirm) {
1894
		global $slony, $misc;
1895
		global $PHP_SELF, $lang;
1896

    
1897
		if ($confirm) {
1898
			$misc->printTrail('slony_cluster');
1899
			$misc->printTitle($lang['strremove']);
1900

    
1901
			echo "<p>", sprintf($lang['strconfremovesequencefromrepset'], 
1902
				$misc->printVal($_REQUEST['qualname']), $misc->printVal($_REQUEST['set_id'])), "</p>\n";
1903

    
1904
			echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1905
			echo "<input type=\"hidden\" name=\"action\" value=\"drop_sequence\" />\n";
1906
			echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1907
			echo "<input type=\"hidden\" name=\"seq_id\" value=\"", htmlspecialchars($_REQUEST['seq_id']), "\" />\n";
1908
			echo $misc->form;
1909
			echo "<input type=\"submit\" name=\"drop\" value=\"{$lang['strremove']}\" />\n";
1910
			echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1911
			echo "</form>\n";
1912
		}
1913
		else {
1914
			$status = $slony->removeSequence($_REQUEST['seq_id']);
1915
			if ($status == 0)
1916
				doSequences($lang['strsequenceremovedfromrepset']);
1917
			else
1918
				doSequences($lang['strsequenceremovedfromrepsetbad']);
1919
		}
1920
	}
1921

    
1922
	/**
1923
	 * Displays a screen where they can move a sequence to a 
1924
	 * replication set.
1925
	 */
1926
	function doMoveSequence($stage, $msg = '') {
1927
		global $data, $slony, $misc;
1928
		global $PHP_SELF, $lang;
1929
		
1930
		switch ($stage) {
1931
			case 1:
1932
				if (!isset($_POST['new_set_id'])) $_POST['new_set_id'] = '';
1933
				
1934
				$sets = $slony->getReplicationSets();
1935
		
1936
				$misc->printTrail('slony_sets');
1937
				$misc->printTitle($lang['strmove']);
1938
				$misc->printMsg($msg);
1939
		
1940
				echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
1941
				echo $misc->form;
1942
				echo "<sequence>\n";
1943
				echo "\t<tr>\n\t\t<th class=\"data left required\">{$lang['strnewrepset']}</th>\n";
1944
				echo "<td class=\"data1\" colspan=\"3\"><select name=\"new_set_id\">";
1945
				while (!$sets->EOF) {
1946
					if ($sets->f['set_id'] != $_REQUEST['set_id']) {
1947
						echo "<option value=\"{$sets->f['set_id']}\">";
1948
						echo htmlspecialchars($sets->f['set_comment']), "</option>\n";
1949
					}
1950
					$sets->moveNext();	
1951
				}
1952
				echo "</select></td></tr>\n";
1953
				echo "</sequence>\n";
1954
				echo "<p>\n";
1955
				echo "<input type=\"hidden\" name=\"action\" value=\"move_sequence\" />\n";
1956
				echo "<input type=\"hidden\" name=\"set_id\" value=\"", htmlspecialchars($_REQUEST['set_id']), "\" />\n";
1957
				echo "<input type=\"hidden\" name=\"seq_id\" value=\"", htmlspecialchars($_REQUEST['seq_id']), "\" />\n";
1958
				echo "<input type=\"hidden\" name=\"stage\" value=\"2\" />\n";
1959
				echo "<input type=\"submit\" value=\"{$lang['strmove']}\" />\n";
1960
				echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
1961
				echo "</p>\n";
1962
				echo "</form>\n";
1963
				break;
1964
			case 2:
1965
				$status = $slony->moveSequence($_REQUEST['seq_id'], $_REQUEST['new_set_id']);
1966
				if ($status == 0)
1967
					doSequences('Sequence moved to replication set.');
1968
				else
1969
					doMoveSequence(1, 'Failed moving sequence to replication set.');
1970
				break;
1971
		}
1972
	}
1973
				
1974
	// SUBSCRIPTIONS
1975
	
1976
	/**
1977
	 * List all the subscriptions
1978
	 */
1979
	function doSubscriptions($msg = '') {
1980
		global $slony, $misc;
1981
		global $lang;
1982

    
1983
		$misc->printTrail('database');
1984
		$misc->printMsg($msg);
1985

    
1986
		$subscriptions = $slony->getSubscribedNodes($_REQUEST['set_id']);
1987

    
1988
		$columns = array(
1989
			'no_name' => array(
1990
				'title' => $lang['strname'],
1991
				'field' => 'no_comment'
1992
			),
1993
/*			'actions' => array(
1994
				'title' => $lang['stractions'],
1995
			),*/
1996
			'no_comment' => array(
1997
				'title' => $lang['strcomment'],
1998
				'field' => 'no_comment'
1999
			)
2000
		);
2001
		
2002
		$actions = array (
2003
			'properties' => array(
2004
				'title' => $lang['strproperties'],
2005
				'url'   => "plugin_slony.php?{$misc->href}&amp;action=subscription_properties&amp;",
2006
				'vars'  => array('set_id' => 'sub_set', 'no_id' => 'no_id')
2007
			)
2008
		);
2009
		
2010
		$misc->printTable($subscriptions, $columns, $actions, $lang['strnosubscriptions']);
2011
	}
2012
	
2013
	/**
2014
	 * Display the properties of a subscription
2015
	 */	 
2016
	function doSubscription($msg = '') {
2017
		global $data, $slony, $misc, $PHP_SELF;
2018
		global $lang;
2019
		
2020
		$misc->printTrail('slony_subscription');
2021
		$misc->printTitle($lang['strproperties']);
2022
		$misc->printMsg($msg);
2023
		
2024
		// Fetch the subscription information
2025
		$subscription = $slony->getSubscription($_REQUEST['set_id'], $_REQUEST['no_id']);		
2026
		
2027
		if (is_object($subscription) && $subscription->recordCount() > 0) {			
2028
			// Show comment if any
2029
			if ($subscription->f['receiver'] !== null)
2030
				echo "<p class=\"comment\">", $misc->printVal($subscription->f['receiver']), "</p>\n";
2031

    
2032
			echo "<table>\n";
2033
			echo "<tr><th class=\"data left\" width=\"70\">Provider ID</th>\n";
2034
			echo "<td class=\"data1\">", $misc->printVal($subscription->f['sub_provider']), "</td></tr>\n";
2035
			echo "<tr><th class=\"data left\" width=\"70\">Provider Name</th>\n";
2036
			echo "<td class=\"data1\">", $misc->printVal($subscription->f['provider']), "</td></tr>\n";
2037
			echo "<tr><th class=\"data left\" width=\"70\">Receiver ID</th>\n";
2038
			echo "<td class=\"data1\">", $misc->printVal($subscription->f['sub_receiver']), "</td></tr>\n";
2039
			echo "<tr><th class=\"data left\" width=\"70\">Receiver Name</th>\n";
2040
			echo "<td class=\"data1\">", $misc->printVal($subscription->f['receiver']), "</td></tr>\n";
2041
			echo "<tr><th class=\"data left\" width=\"70\">{$lang['stractive']}</th>\n";
2042
			echo "<td class=\"data1\">", ($data->phpBool($subscription->f['sub_active'])) ? $lang['stryes'] : $lang['strno'], "</td></tr>\n";
2043
			echo "<tr><th class=\"data left\" width=\"70\">May Forward</th>\n";
2044
			echo "<td class=\"data1\">", ($data->phpBool($subscription->f['sub_forward'])) ? $lang['stryes'] : $lang['strno'], "</td></tr>\n";
2045
			echo "</table>\n";
2046
		}
2047
		else echo "<p>{$lang['strnodata']}</p>\n";
2048
	}
2049

    
2050
	// Tree actions
2051
	if ($action == 'tree') doTree('clusters');
2052
	elseif ($action == 'clusters_top') doTree('clusters_top');
2053
	elseif ($action == 'nodes') doTree('nodes');
2054
	elseif ($action == 'nodes_top') doTree('nodes_top');
2055
	elseif ($action == 'paths') doTree('paths');
2056
	elseif ($action == 'listens') doTree('listens');
2057
	elseif ($action == 'sets') doTree('sets');
2058
	elseif ($action == 'sets_top') doTree('sets_top');
2059
	elseif ($action == 'subscriptions') doTree('subscriptions');
2060
	elseif ($action == 'sequences') doTree('sequences');
2061
	elseif ($action == 'tables') doTree('tables');
2062

    
2063
	$misc->printHeader('Slony');
2064
	$misc->printBody();
2065

    
2066
	switch ($action) {
2067
		case 'save_create_cluster':
2068
			if (isset($_POST['cancel'])) doClusters();
2069
			else doCreateCluster(false);
2070
			break;
2071
		case 'create_cluster':
2072
			doCreateCluster(true);
2073
			break;
2074
		case 'drop_cluster':
2075
			if (isset($_POST['cancel'])) doClusters();
2076
			else doDropCluster(false);
2077
			break;
2078
		case 'confirm_drop_cluster':
2079
			doDropCluster(true);
2080
			break;
2081
		case 'nodes_properties':
2082
			doNodes();
2083
			break;
2084
		case 'node_properties':
2085
			doNode();
2086
			break;
2087
		case 'save_create_node':
2088
			if (isset($_POST['cancel'])) doNodes();
2089
			else doCreateNode(false);
2090
			break;
2091
		case 'create_node':
2092
			doCreateNode(true);
2093
			break;
2094
		case 'drop_node':
2095
			if (isset($_POST['cancel'])) doNodes();
2096
			else doDropNode(false);
2097
			break;
2098
		case 'confirm_drop_node':
2099
			doDropNode(true);
2100
			break;
2101
		case 'failover_node':
2102
			if (isset($_POST['cancel'])) doNodes();
2103
			else doFailoverNode(false);
2104
			break;
2105
		case 'confirm_failover_node':
2106
			doFailoverNode(true);
2107
			break;
2108
		case 'paths_properties':
2109
			doPaths();
2110
			break;
2111
		case 'path_properties':
2112
			doPath();
2113
			break;
2114
		case 'save_create_path':
2115
			if (isset($_POST['cancel'])) doPaths();
2116
			else doCreatePath(false);
2117
			break;
2118
		case 'create_path':
2119
			doCreatePath(true);
2120
			break;
2121
		case 'drop_path':
2122
			if (isset($_POST['cancel'])) doPaths();
2123
			else doDropPath(false);
2124
			break;
2125
		case 'confirm_drop_path':
2126
			doDropPath(true);
2127
			break;
2128
		case 'listens_properties':
2129
			doListens();
2130
			break;
2131
		case 'listen_properties':
2132
			doListen();
2133
			break;
2134
		case 'save_create_listen':
2135
			if (isset($_POST['cancel'])) doListens();
2136
			else doCreateListen(false);
2137
			break;
2138
		case 'create_listen':
2139
			doCreateListen(true);
2140
			break;
2141
		case 'drop_listen':
2142
			if (isset($_POST['cancel'])) doListens();
2143
			else doDropListen(false);
2144
			break;
2145
		case 'confirm_drop_listen':
2146
			doDropListen(true);
2147
			break;
2148
		case 'sets_properties':
2149
			doReplicationSets();
2150
			break;
2151
		case 'set_properties':
2152
			doReplicationSet();
2153
			break;
2154
		case 'save_create_set':
2155
			if (isset($_POST['cancel'])) doReplicationSets();
2156
			else doCreateReplicationSet(false);
2157
			break;
2158
		case 'create_set':
2159
			doCreateReplicationSet(true);
2160
			break;
2161
		case 'drop_set':
2162
			if (isset($_POST['cancel'])) doReplicationSets();
2163
			else doDropReplicationSet(false);
2164
			break;
2165
		case 'confirm_drop_set':
2166
			doDropReplicationSet(true);
2167
			break;
2168
		case 'lock_set':
2169
			if (isset($_POST['cancel'])) doReplicationSets();
2170
			else doLockReplicationSet(false);
2171
			break;
2172
		case 'confirm_lock_set':
2173
			doLockReplicationSet(true);
2174
			break;
2175
		case 'unlock_set':
2176
			if (isset($_POST['cancel'])) doReplicationSets();
2177
			else doUnlockReplicationSet(false);
2178
			break;
2179
		case 'confirm_unlock_set':
2180
			doUnlockReplicationSet(true);
2181
			break;
2182
		case 'save_merge_set':
2183
			if (isset($_POST['cancel'])) doReplicationSet();
2184
			else doMergeReplicationSet(false);
2185
			break;
2186
		case 'merge_set':
2187
			doMergeReplicationSet(true);
2188
			break;
2189
		case 'save_move_set':
2190
			if (isset($_POST['cancel'])) doReplicationSet();
2191
			else doMoveReplicationSet(false);
2192
			break;
2193
		case 'move_set':
2194
			doMoveReplicationSet(true);
2195
			break;
2196
		case 'save_execute_set':
2197
			if (isset($_POST['cancel'])) doReplicationSet();
2198
			else doExecuteReplicationSet(false);
2199
			break;
2200
		case 'execute_set':
2201
			doExecuteReplicationSet(true);
2202
			break;
2203
		case 'tables_properties':
2204
			doTables();
2205
			break;
2206
		case 'add_table':
2207
			if (isset($_REQUEST['cancel'])) doTables();
2208
			else doAddTable($_REQUEST['stage']);
2209
			break;
2210
		case 'drop_table':
2211
			if (isset($_POST['cancel'])) doTables();
2212
			else doRemoveTable(false);
2213
			break;
2214
		case 'confirm_drop_table':
2215
			doRemoveTable(true);
2216
			break;
2217
		case 'move_table':
2218
			if (isset($_REQUEST['cancel'])) doTables();
2219
			else doMoveTable($_REQUEST['stage']);
2220
			break;
2221
		case 'sequences_properties':
2222
			doSequences();
2223
			break;
2224
		case 'add_sequence':
2225
			if (isset($_REQUEST['cancel'])) doSequences();
2226
			else doAddSequence($_REQUEST['stage']);
2227
			break;
2228
		case 'drop_sequence':
2229
			if (isset($_POST['cancel'])) doSequences();
2230
			else doRemoveSequence(false);
2231
			break;
2232
		case 'confirm_drop_sequence':
2233
			doRemoveSequence(true);
2234
			break;
2235
		case 'move_sequence':
2236
			if (isset($_REQUEST['cancel'])) doSequences();
2237
			else doMoveSequence($_REQUEST['stage']);
2238
			break;
2239
		case 'subscriptions_properties':
2240
			doSubscriptions();
2241
			break;
2242
		case 'subscription_properties':
2243
			doSubscription();
2244
			break;
2245
		case 'cluster_properties':
2246
			doCluster();
2247
			break;
2248
		case 'clusters_properties':
2249
		default:
2250
			doClusters();
2251
			break;
2252
	}
2253
	
2254
	$misc->printFooter();
2255

    
2256
?>
(35-35/53)