-
Notifications
You must be signed in to change notification settings - Fork 3
/
emajgroupsconf.php
738 lines (655 loc) · 26.7 KB
/
emajgroupsconf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
<?php
/*
* Manage the E-Maj tables groups configuration
*/
// Include application functions
include_once('./libraries/lib.inc.php');
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
if (!isset($msg)) $msg = '';
// Function to dynamicaly modify actions list for tables
function tblseqPre(&$rowdata, $actions) {
// disable 'assign' if the table already belongs to a group
if ($rowdata->fields['grpdef_group'] != NULL) {
$actions['assign']['disable'] = true;
} else {
// otherwise, disable 'remove' and 'update'
$actions['remove']['disable'] = true;
$actions['update']['disable'] = true;
// disable also 'assign' for unsupported object type
if ($rowdata->fields['relkind'] != 'r+' and $rowdata->fields['relkind'] != 'S+') {
$actions['assign']['disable'] = true;
}
};
return $actions;
}
// Callback function to dynamicaly modify the Table/Sequence columns content
// It replaces the database value by an icon representing either a table or a sequence
function renderTblSeq($val) {
global $misc, $lang;
if ($val == 'r+') { // regular table
$icon = $misc->icon('Table');
$alt = $lang['strtable'];
} elseif ($val == 'S+') { // sequence
$icon = $misc->icon('Sequence');
$alt = $lang['strsequence'];
} elseif ($val == '!') { // object declared in the emaj_group_def table but unknown in the catalog
$icon = $misc->icon('ObjectNotFound');
$alt = $lang['strunknownobject'];
} else { // unsupported type
$icon = $misc->icon('ObjectNotFound');
$alt = $lang['strunsupportedobject'];
}
return "<img src=\"{$icon}\" alt=\"{$alt}\" title=\"{$alt}\"/>";
}
// Callback function to dynamicaly modify the schema owner columns content
// It generates a warning icon when the owner is not known (i.e. the object does not exist)
function renderSchemaOwner($val) {
global $misc, $lang;
if ($val == '!') {
return "<img src=\"".$misc->icon('ObjectNotFound')."\" alt=\"{$lang['strunknownobject']}\" title=\"{$lang['strunknownobject']}\" />";
}
return $val;
}
/**
* Define groups content
*/
function configure_groups($msg = '', $errMsg = '', $prevSchema = '') {
global $misc, $lang, $emajdb;
if (!isset($_REQUEST['appschema'])) $_REQUEST['appschema'] = $prevSchema;
if (is_array($_REQUEST['appschema'])) $_REQUEST['appschema'] = $_REQUEST['appschema'][0];
$misc->printHeader('database', 'database', 'emajconfiguregroups');
$misc->printMsg($msg,$errMsg);
// Schemas list
$misc->printTitle($lang['strappschemas']);
$schemas = $emajdb->getSchemas();
$columns = array(
'schema' => array(
'title' => $lang['strschema'],
'field' => field('nspname'),
'url' => "emajgroupsconf.php?action=configure_groups&back=define&{$misc->href}&",
'vars' => array('appschema' => 'nspname'),
),
'owner' => array(
'title' => $lang['strowner'],
'field' => field('nspowner'),
'type' => 'callback',
'params'=> array('function' => 'renderSchemaOwner')
),
'comment' => array(
'title' => $lang['strcomment'],
'field' => field('nspcomment'),
),
);
$actions = array ();
$misc->printTable($schemas, $columns, $actions, 'defineGroupSchemas', $lang['strnoschemas'], null, array('sorter' => true, 'filter' => true));
echo "<hr>\n";
// Tables and sequences for the selected schema, if any
if (isset($_REQUEST['appschema']) && $_REQUEST['appschema'] != '') {
$misc->printTitle(sprintf($lang['strtblseqofschema'],$_REQUEST['appschema']));
$tblseq = $emajdb->getTablesSequences($_REQUEST['appschema']);
$columns = array(
'type' => array(
'title' => $lang['strtype'],
'field' => field('relkind'),
'type' => 'callback',
'params'=> array('function' => 'renderTblSeq','align' => 'center'),
'sorter_text_extraction' => 'img_alt',
'filter'=> false,
),
'appschema' => array(
'title' => $lang['strschema'],
'field' => field('nspname'),
),
'tblseq' => array(
'title' => $lang['strname'],
'field' => field('relname'),
),
'actions' => array(
'title' => $lang['stractions'],
),
'group' => array(
'title' => $lang['strgroup'],
'field' => field('grpdef_group'),
),
'priority' => array(
'title' => $lang['strpriority'],
'field' => field('grpdef_priority'),
'params'=> array('align' => 'center'),
));
if ($emajdb->getNumEmajVersion() < 30100) { // version < 3.1.0
$columns = array_merge($columns, array(
'logschemasuffix' => array(
'title' => $lang['strlogschemasuffix'],
'field' => field('grpdef_log_schema_suffix'),
),
'emajnamesprefix' => array(
'title' => $lang['strnamesprefix'],
'field' => field('grpdef_emaj_names_prefix'),
),
));
}
$columns = array_merge($columns, array(
'logdattsp' => array(
'title' => $lang['strlogdattsp'],
'field' => field('grpdef_log_dat_tsp'),
),
'logidxtsp' => array(
'title' => $lang['strlogidxtsp'],
'field' => field('grpdef_log_idx_tsp'),
),
'owner' => array(
'title' => $lang['strowner'],
'field' => field('relowner'),
),
'tablespace' => array(
'title' => $lang['strtablespace'],
'field' => field('tablespace')
),
'comment' => array(
'title' => $lang['strcomment'],
'field' => field('relcomment'),
),
));
$urlvars = $misc->getRequestVars();
$actions = array(
'multiactions' => array(
'keycols' => array('appschema' => 'nspname', 'tblseq' => 'relname', 'group' => 'grpdef_group', 'type' => 'relkind'),
'url' => "emajgroupsconf.php?back=define",
),
'assign' => array(
'content' => $lang['strassign'],
'attr' => array (
'href' => array (
'url' => 'emajgroupsconf.php',
'urlvars' => array_merge($urlvars, array (
'action' => 'assign_tblseq',
'appschema' => field('nspname'),
'tblseq' => field('relname'),
'group' => field('grpdef_group'),
'type' => field('relkind'),
)))),
'multiaction' => 'assign_tblseq',
),
'update' => array(
'content' => $lang['strupdate'],
'attr' => array (
'href' => array (
'url' => 'emajgroupsconf.php',
'urlvars' => array_merge($urlvars, array (
'action' => 'update_tblseq',
'type' => field('relkind'),
'appschema' => field('nspname'),
'tblseq' => field('relname'),
'group' => field('grpdef_group'),
'priority' => field('grpdef_priority'),
'logschemasuffix' => field('grpdef_log_schema_suffix'),
'emajnamesprefix' => field('grpdef_emaj_names_prefix'),
'logdattsp' => field('grpdef_log_dat_tsp'),
'logidxtsp' => field('grpdef_log_idx_tsp'),
)))),
),
'remove' => array(
'content' => $lang['strremove'],
'attr' => array (
'href' => array (
'url' => 'emajgroupsconf.php',
'urlvars' => array_merge($urlvars, array (
'action' => 'remove_tblseq',
'appschema' => field('nspname'),
'tblseq' => field('relname'),
'group' => field('grpdef_group'),
'type' => field('relkind'),
)))),
'multiaction' => 'remove_tblseq',
),
);
$misc->printTable($tblseq, $columns, $actions, 'defineGroupTblseq', $lang['strnotables'], 'tblseqPre', array('sorter' => true, 'filter' => true));
}
}
/**
* Prepare insert a table/sequence into a group: ask for properties and confirmation
*/
function assign_tblseq() {
global $misc, $lang, $emajdb;
// Test at least 1 table/sequence is to be processed
if (empty($_REQUEST['tblseq']) && empty($_REQUEST['ma'])) {
configure_groups($lang['strspecifytblseqtoassign']);
exit();
}
// Test all tables/sequences to process are not yet assigned to a group and have a valid type
if (isset($_REQUEST['ma'])) {
foreach($_REQUEST['ma'] as $t) {
$a = unserialize(htmlspecialchars_decode($t, ENT_QUOTES));
if ($a['group'] != '') {
configure_groups('', sprintf($lang['strtblseqyetgroup'],$a['appschema'],$a['tblseq']), $a['appschema']);
exit();
}
if ($a['type'] != 'r+' and $a['type'] != 'S+') {
configure_groups('', sprintf($lang['strtblseqbadtype'],$a['appschema'],$a['tblseq']), $a['appschema']);
exit();
}
}
}
$misc->printHeader('database', 'database', 'emajconfiguregroups');
$misc->printTitle($lang['strassigntblseq']);
// Get group names already known in emaj_group_def table
$knownGroups = $emajdb->getKnownGroups();
// Get log schema suffix already known in emaj_group_def table
if ($emajdb->getNumEmajVersion() < 30100) { // version < 3.1.0
$knownSuffix = $emajdb->getKnownSuffix();
}
// Get tablespaces the current user can see
$knownTsp = $emajdb->getKnownTsp();
// Build the list of tables and sequences to processs and count them
$nbTbl = 0; $nbSeq = 0;
echo "<form action=\"emajgroupsconf.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"assign_tblseq_ok\" />\n";
if (isset($_REQUEST['ma'])) {
// multiple assign
$fullList = "<ul>";
foreach($_REQUEST['ma'] as $t) {
$a = unserialize(htmlspecialchars_decode($t, ENT_QUOTES));
echo "<input type=\"hidden\" name=\"appschema[]\" value=\"", htmlspecialchars($a['appschema']), "\" />\n";
echo "<input type=\"hidden\" name=\"tblseq[]\" value=\"", htmlspecialchars($a['tblseq']), "\" />\n";
if ($a['type'] == 'r+') {
$nbTbl++;
$fullList .= "<li>" . sprintf($lang['strthetable'],$a['appschema'],$a['tblseq']) . "</li>\n";
} else {
$nbSeq++;
$fullList .= "<li>" . sprintf($lang['strthesequence'],$a['appschema'],$a['tblseq']) . "</li>\n";
}
}
$fullList .= "</ul>\n";
echo "<p>{$lang['strconfirmassigntblseq']}{$fullList}</p>\n";
} else {
// single assign
echo "<input type=\"hidden\" name=\"appschema\" value=\"", htmlspecialchars($_REQUEST['appschema']), "\" />\n";
echo "<input type=\"hidden\" name=\"tblseq\" value=\"", htmlspecialchars($_REQUEST['tblseq']), "\" />\n";
if ($_REQUEST['type'] == 'r+') {
$nbTbl++;
$tblseqName = sprintf($lang['strthetable'],$_REQUEST['appschema'],$_REQUEST['tblseq']);
} else {
$nbSeq++;
$tblseqName = sprintf($lang['strthesequence'],$_REQUEST['appschema'],$_REQUEST['tblseq']);
}
echo "<p>{$lang['strassign']} {$tblseqName}</p>\n";
}
// Display the input fields depending on the context
echo "<div class=\"form-container\">\n";
// group name
echo "\t<div class=\"form-label required\">{$lang['strgroup']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"group\" list=\"groupList\" required pattern=\"\S+.*\" value=\"\" placeholder='{$lang['strrequiredfield']}' autocomplete=\"off\"/>";
echo "</div>\n";
echo "\t<div class=\"form-comment\"></div>\n";
echo "\t<datalist id=\"groupList\">\n";
if ($knownGroups->recordCount() > 0) {
foreach($knownGroups as $r)
echo "\t\t<option value=\"", htmlspecialchars($r['group_name']), "\">\n";
}
echo "\t</datalist>\n";
// priority level (only for tables)
if ($nbTbl >= 1) {
echo "\t<div class=\"form-label\">{$lang['strenterpriority']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"number\" name=\"priority\" class=\"priority\" min=\"0\" max=\"2147483647\" value=\"\" />";
echo "</div>\n";
echo "\t<div class=\"form-comment\"><img src=\"{$misc->icon('Info')}\" alt=\"info\" title=\"{$lang['strpriorityhelp']}\"/></div>\n";
} else {
echo "<input type=\"hidden\" name=\"priority\" value=\"\" />\n";
}
// log schema name suffix
if ($emajdb->getNumEmajVersion() < 30100 && $nbTbl >= 1) { // version < 3.1.0
echo "\t<div class=\"form-label\">{$lang['strenterlogschema']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"suffix\" list=\"suffixList\" value=\"\"/ autocomplete=\"off\">";
echo "</div>\n";
echo "\t<div class=\"form-comment\"><img src=\"{$misc->icon('Info')}\" alt=\"info\" title=\"{$lang['strlogschemahelp']}\"/></div>\n";
echo "\t<datalist id=\"suffixList\">\n";
if ($knownSuffix->recordCount() > 0) {
foreach($knownSuffix as $r)
echo "\t\t<option value=\"", htmlspecialchars($r['known_suffix']), "\">\n";
}
echo "\t</datalist>\n";
} else {
echo "<input type=\"hidden\" name=\"suffix\" value=\"\" />\n";
}
// objects name prefix (only for tables)
if ($emajdb->getNumEmajVersion() < 30100 && $nbTbl == 1) { // version < 3.1.0
// the names prefix is accessible only for a single table assignment
echo "\t<div class=\"form-label\">{$lang['strenternameprefix']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"nameprefix\" value=\"\"/>";
echo "</div>\n";
echo "\t<div class=\"form-comment\"><img src=\"{$misc->icon('Info')}\" alt=\"info\" title=\"", htmlspecialchars($lang['strnameprefixhelp']), "\"/></div>\n";
} else {
echo "<input type=\"hidden\" name=\"nameprefix\" value=\"\" />\n";
}
// log tablespace (only for tables)
if ($nbTbl >= 1) {
// data log tablespace
echo "\t<div class=\"form-label\">{$lang['strenterlogdattsp']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"logdattsp\" list=\"tspList\" value=\"\" autocomplete=\"off\"/>";
echo "</div>\n";
echo "\t<div class=\"form-comment\"></div>\n";
// index log tablespace
echo "\t<div class=\"form-label\">{$lang['strenterlogidxtsp']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"logidxtsp\" list=\"tspList\" value=\"\" autocomplete=\"off\"/>";
echo "</div>\n";
echo "\t<div class=\"form-comment\"></div>\n";
echo "\t<datalist id=\"tspList\">\n";
if ($knownTsp->recordCount() > 0) {
foreach($knownTsp as $r)
echo "\t\t<option value=\"", htmlspecialchars($r['spcname']), "\">\n";
}
echo "\t</datalist>\n";
} else {
echo "<input type=\"hidden\" name=\"logdattsp\" value=\"\" />\n";
echo "<input type=\"hidden\" name=\"logidxtsp\" value=\"\" />\n";
}
echo"</div>\n";
echo $misc->form;
echo "<p><input type=\"submit\" name=\"assigntblseq\" value=\"{$lang['strassign']}\" id=\"ok\" />\n";
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" formnovalidate/></p>\n";
echo "</form>\n";
}
/**
* Perform table/sequence insertion into a tables group
*/
function assign_tblseq_ok() {
global $lang, $data, $emajdb;
// process the click on the <cancel> button
if (isset($_POST['cancel'])) {configure_groups(); exit();}
if (is_array($_POST['tblseq'])) {
// multiple assignement
$status = $data->beginTransaction();
if ($status == 0) {
for($i = 0; $i < sizeof($_POST['tblseq']); ++$i)
{
$status = $emajdb->assignTblSeq($_POST['appschema'][$i],$_POST['tblseq'][$i],$_POST['group'],
$_POST['priority'], $_POST['suffix'], $_POST['nameprefix'], $_POST['logdattsp'], $_POST['logidxtsp']);
if ($status != 0) {
$data->rollbackTransaction();
configure_groups('', $lang['strmodifygrouperr']);
return;
}
}
}
if($data->endTransaction() == 0)
configure_groups($lang['strmodifygroupok']);
else
configure_groups('', $lang['strmodifygrouperr']);
} else {
// single assignement
$status = $emajdb->assignTblSeq($_POST['appschema'],$_POST['tblseq'],$_POST['group'],
$_POST['priority'], $_POST['suffix'], $_POST['nameprefix'], $_POST['logdattsp'], $_POST['logidxtsp']);
if ($status == 0)
configure_groups($lang['strmodifygroupok']);
else
configure_groups('', $lang['strmodifygrouperr']);
}
}
/**
* Prepare update a table/sequence into a group: ask for properties and confirmation
*/
function update_tblseq() {
global $misc, $lang, $emajdb;
// Test at least 1 table/sequence is to be processed
if (empty($_REQUEST['tblseq'])) {
configure_groups($lang['strspecifytblseqtoupdate']);
exit();
}
// Test the table/sequence is already assign to a group
if ($_REQUEST['group'] == '') {
configure_groups('', sprintf($lang['strtblseqnogroup'],$_REQUEST['appschema'],$_REQUEST['tblseq']), $_REQUEST['appschema']);
exit();
}
$misc->printHeader('database', 'database', 'emajconfiguregroups');
$misc->printTitle($lang['strupdatetblseq']);
// Get group names already known in emaj_group_def table
$knownGroups = $emajdb->getKnownGroups();
// Get log schema suffix already known in emaj_group_def table
if ($emajdb->getNumEmajVersion() < 30100) { // version < 3.1.0
$knownSuffix = $emajdb->getKnownSuffix();
}
// Get tablespaces the current user can see
$knownTsp = $emajdb->getKnownTsp();
echo "<form action=\"emajgroupsconf.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"update_tblseq_ok\" />\n";
echo "<input type=\"hidden\" name=\"appschema\" value=\"", htmlspecialchars($_REQUEST['appschema']), "\" />\n";
echo "<input type=\"hidden\" name=\"tblseq\" value=\"", htmlspecialchars($_REQUEST['tblseq']), "\" />\n";
echo "<input type=\"hidden\" name=\"groupold\" value=\"", htmlspecialchars($_REQUEST['group']), "\" />\n";
if ($_REQUEST['type'] == 'r+') {
$tblseqName = sprintf($lang['strthetable'],$_REQUEST['appschema'],$_REQUEST['tblseq']);
} else {
$tblseqName = sprintf($lang['strthesequence'],$_REQUEST['appschema'],$_REQUEST['tblseq']);
}
echo "<p>{$lang['strupdate']} {$tblseqName}</p>\n";
// Display the input fields depending on the context
echo "<div class=\"form-container\">\n";
// group name
echo "\t<div class=\"form-label required\">{$lang['strgroup']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"groupnew\" list=\"groupList\" required pattern=\"\S+.*\" value=\"", htmlspecialchars($_REQUEST['group']), "\" placeholder='{$lang['strrequiredfield']}' autocomplete=\"off\"/>\n";
echo "</div>\n";
echo "\t<div class=\"form-comment\"></div>\n";
echo "\t<datalist id=\"groupList\">\n";
if ($knownGroups->recordCount() > 0) {
foreach($knownGroups as $r)
echo "\t\t<option value=\"", htmlspecialchars($r['group_name']), "\">\n";
}
echo "\t</datalist>\n";
// priority level (only for tables)
if ($_REQUEST['type'] == 'r+') {
echo "\t<div class=\"form-label\">{$lang['strenterpriority']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"number\" name=\"priority\" class=\"priority\" min=\"0\" max=\"2147483647\" value=\"{$_REQUEST['priority']}\" />";
echo "</div>\n";
echo "\t<div class=\"form-comment\"><img src=\"{$misc->icon('Info')}\" alt=\"info\" title=\"{$lang['strpriorityhelp']}\"/></div>\n";
} else {
echo "<input type=\"hidden\" name=\"priority\" value=\"\" />\n";
}
// log schema name suffix (only for tables)
if ($emajdb->getNumEmajVersion() < 30100 && $_REQUEST['type'] == 'r+') { // version < 3.1.0
echo "\t<div class=\"form-label\">{$lang['strenterlogschema']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"suffix\" list=\"suffixList\" value=\"", htmlspecialchars($_REQUEST['logschemasuffix']), "\"/ autocomplete=\"off\">";
echo "</div>\n";
echo "\t<div class=\"form-comment\"><img src=\"{$misc->icon('Info')}\" alt=\"info\" title=\"{$lang['strlogschemahelp']}\"/></div>\n";
echo "\t<datalist id=\"suffixList\">\n";
if ($knownSuffix->recordCount() > 0) {
foreach($knownSuffix as $r)
echo "\t\t<option value=\"", htmlspecialchars($r['known_suffix']), "\">\n";
}
echo "\t</datalist>\n";
} else {
echo "<input type=\"hidden\" name=\"suffix\" value=\"\" />\n";
}
// objects name prefix (only for tables)
if ($emajdb->getNumEmajVersion() < 30100 && $_REQUEST['type'] == 'r+') { // version < 3.1.0
// the names prefix is accessible only for a table
echo "\t<div class=\"form-label\">{$lang['strenternameprefix']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"nameprefix\" value=\"", htmlspecialchars($_REQUEST['emajnamesprefix']), "\"/>";
echo "</div>\n";
echo "\t<div class=\"form-comment\"><img src=\"{$misc->icon('Info')}\" alt=\"info\" title=\"", htmlspecialchars($lang['strnameprefixhelp']), "\"/></div>\n";
} else {
echo "<input type=\"hidden\" name=\"nameprefix\" value=\"\" />\n";
}
// log tablespaces (only for tables)
if ($_REQUEST['type'] == 'r+') {
// data log tablespace
echo "\t<div class=\"form-label\">{$lang['strenterlogdattsp']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"logdattsp\" list=\"tspList\" value=\"", htmlspecialchars($_REQUEST['logdattsp']), "\" autocomplete=\"off\"/>";
echo "</div>\n";
echo "\t<div class=\"form-comment\"></div>\n";
// index log tablespace
echo "\t<div class=\"form-label\">{$lang['strenterlogidxtsp']}</div>\n";
echo "\t<div class=\"form-input\">";
echo "<input type=\"text\" name=\"logidxtsp\" list=\"tspList\" value=\"", htmlspecialchars($_REQUEST['logidxtsp']), "\" autocomplete=\"off\"/>";
echo "</div>\n";
echo "\t<div class=\"form-comment\"></div>\n";
echo "\t<datalist id=\"tspList\">\n";
if ($knownTsp->recordCount() > 0) {
foreach($knownTsp as $r)
echo "\t\t<option value=\"", htmlspecialchars($r['spcname']), "\">\n";
}
echo "\t</datalist>\n";
} else {
echo "<input type=\"hidden\" name=\"logdattsp\" value=\"\" />\n";
echo "<input type=\"hidden\" name=\"logidxtsp\" value=\"\" />\n";
}
echo"</div>\n";
echo $misc->form;
echo "<p><input type=\"submit\" name=\"updatetblseq\" value=\"{$lang['strupdate']}\" id=\"ok\" />\n";
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" formnovalidate /></p>\n";
echo "</form>\n";
}
/**
* Perform table/sequence insertion into a tables group
*/
function update_tblseq_ok() {
global $lang, $data, $emajdb;
// process the click on the <cancel> button
if (isset($_POST['cancel'])) {configure_groups(); exit();}
$status = $emajdb->updateTblSeq($_POST['appschema'],$_POST['tblseq'],$_POST['groupold'],$_POST['groupnew'],
$_POST['priority'], $_POST['suffix'], $_POST['nameprefix'], $_POST['logdattsp'], $_POST['logidxtsp']);
if ($status == 0)
configure_groups($lang['strmodifygroupok']);
else
configure_groups('', $lang['strmodifygrouperr']);
}
/**
* Prepare remove a table/sequence from a group: ask for confirmation
*/
function remove_tblSeq() {
global $misc, $lang;
// Test at least 1 table/sequence is to be processed
if (empty($_REQUEST['tblseq']) && empty($_REQUEST['ma'])) {
configure_groups($lang['strspecifytblseqtoremove']);
exit();
}
// Test all tables/sequences to process are already assigned to a group
if (isset($_REQUEST['ma'])) {
foreach($_REQUEST['ma'] as $t) {
$a = unserialize(htmlspecialchars_decode($t, ENT_QUOTES));
if ($a['group'] == '') {
configure_groups('', sprintf($lang['strtblseqnogroup'],$a['appschema'],$a['tblseq']), $a['appschema']);
exit();
}
}
}
$misc->printHeader('database', 'database', 'emajconfiguregroups');
$misc->printTitle($lang['strremovetblseq']);
$nbTbl = 0; $nbSeq = 0;
echo "<form action=\"emajgroupsconf.php\" method=\"post\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"remove_tblseq_ok\" />\n";
if (isset($_REQUEST['ma'])) {
// multiple removal
$fullList = "<ul>";
foreach($_REQUEST['ma'] as $t) {
$a = unserialize(htmlspecialchars_decode($t, ENT_QUOTES));
echo "<input type=\"hidden\" name=\"appschema[]\" value=\"", htmlspecialchars($a['appschema']), "\" />\n";
echo "<input type=\"hidden\" name=\"tblseq[]\" value=\"", htmlspecialchars($a['tblseq']), "\" />\n";
echo "<input type=\"hidden\" name=\"group[]\" value=\"", htmlspecialchars($a['group']), "\" />\n";
if ($a['type'] == 'r+') {
$nbTbl++;
$fullList .= "<li>" . sprintf($lang['strthetable'],$a['appschema'],$a['tblseq']);
} else {
$nbSeq++;
$fullList .= "<li>" . sprintf($lang['strthesequence'],$a['appschema'],$a['tblseq']);
}
$fullList .= " " . sprintf($lang['strfromgroup'], htmlspecialchars($a['group'])) . "</li>\n";
}
$fullList .= "</ul>\n";
echo "<p>{$lang['strconfirmremovetblseq']}{$fullList}</p>\n";
} else {
// single removal
echo "<input type=\"hidden\" name=\"appschema\" value=\"", htmlspecialchars($_REQUEST['appschema']), "\" />\n";
echo "<input type=\"hidden\" name=\"tblseq\" value=\"", htmlspecialchars($_REQUEST['tblseq']), "\" />\n";
echo "<input type=\"hidden\" name=\"group\" value=\"", htmlspecialchars($_REQUEST['group']), "\" />\n";
if ($_REQUEST['type'] == 'r+') {
$nbTbl++;
$tblseqName = sprintf($lang['strthetable'],$_REQUEST['appschema'],$_REQUEST['tblseq']);
} else {
$nbSeq++;
$tblseqName = sprintf($lang['strthesequence'],$_REQUEST['appschema'],$_REQUEST['tblseq']);
}
echo "<p>" . sprintf($lang['strconfirmremove1tblseq'], $tblseqName, htmlspecialchars($_REQUEST['group'])) . "</p>\n";
}
echo $misc->form;
echo "<input type=\"submit\" name=\"removetblseq\" value=\"{$lang['strremove']}\" />\n";
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
echo "</form>\n";
}
/**
* Perform table/sequence removal from a tables group
*/
function remove_tblseq_ok() {
global $lang, $data, $emajdb;
// process the click on the <cancel> button
if (isset($_POST['cancel'])) {configure_groups(); exit();}
if (is_array($_POST['tblseq'])) {
// multiple removal
$status = $data->beginTransaction();
if ($status == 0) {
for($i = 0; $i < sizeof($_POST['tblseq']); ++$i)
{
$status = $emajdb->removeTblSeq($_POST['appschema'][$i],$_POST['tblseq'][$i],$_POST['group'][$i]);
if ($status != 0) {
$data->rollbackTransaction();
$configure_groups('', $lang['strmodifygrouperr']);
return;
}
}
}
if($data->endTransaction() == 0)
configure_groups($lang['strmodifygroupok']);
else
configure_groups('', $lang['strmodifygrouperr']);
} else {
// single removal
$status = $emajdb->removeTblSeq($_POST['appschema'],$_POST['tblseq'],$_POST['group']);
if ($status == 0)
configure_groups($lang['strmodifygroupok']);
else
configure_groups('', $lang['strmodifygrouperr']);
}
}
// redirect to the emajenvir.php page if the emaj extension is not installed or accessible or is too old
if (!(isset($emajdb) && $emajdb->isEnabled() && $emajdb->isAccessible()
&& $emajdb->getNumEmajVersion() >= $oldest_supported_emaj_version_num)) {
header('Location: emajenvir.php?' . $_SERVER["QUERY_STRING"]);
}
$misc->printHtmlHeader($lang['strgroupsconfiguration']);
$misc->printBody();
switch ($action) {
case 'configure_groups':
configure_groups();
break;
case 'assign_tblseq';
assign_tblseq();
break;
case 'assign_tblseq_ok':
assign_tblseq_ok();
break;
case 'update_tblseq';
update_tblseq();
break;
case 'update_tblseq_ok':
update_tblseq_ok();
break;
case 'remove_tblseq';
remove_tblseq();
break;
case 'remove_tblseq_ok':
remove_tblseq_ok();
break;
default:
configure_groups();
}
$misc->printFooter();
?>