-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgroupstat.php
694 lines (617 loc) · 25.5 KB
/
groupstat.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
<?php
/*
* Manage the tables groups recorded changes statistics
*/
// Include application functions
include_once('./libraries/lib.inc.php');
/********************************************************************************************************
* Callback functions
*******************************************************************************************************/
// Callback function to dynamicaly translate a boolean column into an icon
function renderBooleanIcon($val) {
global $misc;
if ($val == 't') {
$icon = 'Checkmark';
} else {
$icon = 'RedX';
}
return "<img src=\"" . $misc->icon($icon) . "\" class=\"cellicon\" />";
}
/********************************************************************************************************
* Main functions displaying pages
*******************************************************************************************************/
/**
* Show changes statistics between 2 marks or since a mark for tables or sequences
*/
function changes_stat_group() {
global $misc, $lang, $emajdb, $_reload_browser;
if (! $emajdb->existsGroup($_REQUEST['group'])) {
show_groups('', sprintf($lang['strgroupmissing'], htmlspecialchars($_REQUEST['group'])));
$_reload_browser = true;
return;
}
$misc->printHeader('emaj', 'emajgroup', 'emajchangesstat');
$misc->printTitle(sprintf($lang['strchangesgroup'], htmlspecialchars($_REQUEST['group'])));
// display the form
$estimateTables = (isset($_REQUEST['estimatetables'])) ? true : false;
$estimateSequences = (isset($_REQUEST['estimatesequences'])) ? true : false;
$detailTables = (isset($_REQUEST['detailtables'])) ? true : false;
// get marks from database
$marks = $emajdb->getMarks($_REQUEST['group']);
// get group's characteristics
$group = $emajdb->getGroup($_REQUEST['group']);
if ($marks->recordCount() < 1) {
// No mark recorded for the group => no update logged => no stat to display
echo "<p>{$lang['strnomark']}</p>\n";
} else {
// form for statistics selection
echo "<form id=\"statistics_form\" action=\"groupstat.php?action=changes_stat_group&back=detail&{$misc->href}\"";
echo " method=\"post\" enctype=\"multipart/form-data\">\n";
echo "<div class=\"form-container\">\n";
// First mark defining the marks range to analyze
echo "\t<div class=\"form-label\">{$lang['strstartmark']}</div>\n";
echo "\t<div class=\"form-input\">\n";
echo "\t\t<select name=\"rangestart\" id=\"rangestart\">\n";
foreach($marks as $r)
echo "\t\t\t<option value=\"", htmlspecialchars($r['mark_name']), "\" >", htmlspecialchars($r['mark_name']), " ({$r['mark_datetime']})</option>\n";
echo "\t\t</select>\n";
echo "\t</div>\n";
echo "\t<div class=\"form-comment\"></div>\n";
// Last mark defining the marks range to analyze
echo "\t<div class=\"form-label\">{$lang['strendmark']}</div>\n";
echo "\t<div class=\"form-input\">\n";
echo "\t\t<select name=\"rangeend\" id=\"rangeend\" >\n";
echo "\t\t\t<option value=\"currentsituation\">{$lang['strcurrentsituation']}</option>\n";
foreach($marks as $r)
echo "\t\t\t<option value=\"", htmlspecialchars($r['mark_name']), "\" >", htmlspecialchars($r['mark_name']), " ({$r['mark_datetime']})</option>\n";
echo "\t\t</select>\n";
echo "\t</div>\n";
echo "\t<div class=\"form-comment\"></div>\n";
echo "</div>\n";
// Buttons
echo "<div class=\"actionslist\">\n";
echo "\t<input type=\"hidden\" name=\"group\" value=\"", htmlspecialchars($_REQUEST['group']), "\" />\n";
echo "\t<input type=\"submit\" name=\"estimatetables\" value=\"{$lang['strestimatetables']}\" />\n";
if ($emajdb->getNumEmajVersion() >= 40301) { // version >= 4.3.1
echo "\t<input type=\"submit\" name=\"estimatesequences\" value=\"{$lang['strestimatesequences']}\" />\n";
}
echo "\t<input type=\"submit\" name=\"detailtables\" value=\"{$lang['strdetailtables']}\" />\n";
echo "\t<img src=\"{$misc->icon('Warning')}\" alt=\"warning\" title=\"{$lang['strdetailedlogstatwarning']}\" style=\"vertical-align:middle; height:22px;\"/>";
echo "</div>\n";
echo "</form>\n";
// JQuery scripts
echo "<script>\n";
// JQuery to remove the last mark as it cannot be selected as end mark
echo " $(\"#rangeend option:last-child\").remove();\n";
// JQuery to set the selected start mark by default
// (the previous requested start mark or the first mark if no stat are already displayed)
if (isset($_REQUEST['rangestart'])) {
echo " $(\"#rangestart option[value='{$_REQUEST['rangestart']}']\").attr(\"selected\", true);\n";
} else {
echo " $(\"#rangestart option:first-child\").attr(\"selected\", true);\n";
}
// JQuery to set the selected end mark by default
// (the previous requested end mark or the current state if no stat are already displayed)
if (isset($_REQUEST['rangeend'])) {
echo " $(\"#rangeend option[value='{$_REQUEST['rangeend']}']\").attr(\"selected\", true);\n";
} else {
echo " $(\"#rangeend option:first-child\").attr(\"selected\", true);\n";
}
// JQuery script to avoid rangestart > rangeend
// After document loaded
echo " $(document).ready(function() {\n";
echo " mark = $(\"#rangestart option:selected\").val();\n";
echo " todisable = false;\n";
echo " $(\"#rangeend option\").each(function() {\n";
echo " $(this).prop('disabled', todisable);\n";
echo " if ($(this).val() == mark) {todisable = true;}\n";
echo " });\n";
echo " mark = $(\"#rangeend option:selected\").val();\n";
echo " todisable = true;\n";
echo " if (mark == \"currentsituation\") {todisable = false;}\n";
echo " $(\"#rangestart option\").each(function() {\n";
echo " if ($(this).val() == mark) { todisable = false; }\n";
echo " $(this).prop('disabled', todisable);\n";
echo " });\n";
echo " });\n";
// At each list box change
echo " $(\"#rangestart\").change(function () {\n";
echo " mark = $(\"#rangestart option:selected\").val();\n";
echo " todisable = false;\n";
echo " $(\"#rangeend option\").each(function() {\n";
echo " $(this).prop('disabled', todisable);\n";
echo " if ($(this).val() == mark) {todisable = true;}\n";
echo " });\n";
echo " });\n";
echo " $(\"#rangeend\").change(function () {\n";
echo " mark = $(\"#rangeend option:selected\").val();\n";
echo " todisable = true;\n";
echo " if (mark == \"currentsituation\") {todisable = false;}\n";
echo " $(\"#rangestart option\").each(function() {\n";
echo " if ($(this).val() == mark) { todisable = false; }\n";
echo " $(this).prop('disabled', todisable);\n";
echo " });\n";
echo " });\n";
echo "</script>\n";
// If any stat is requested, get common data
if ($estimateTables || $estimateSequences || $detailTables) {
$groupStat = $emajdb->getNbObjectsGroupInPeriod($_REQUEST['group'],$_REQUEST['rangestart'],$_REQUEST['rangeend']);
}
// If tables estimates stats are requested, display them
if ($estimateTables) {
disp_tables_estimates_stat_section($groupStat);
}
// If Sequences estimates stats are requested, display them
if ($estimateSequences) {
disp_sequences_estimates_stat_section($groupStat);
}
// If tables detailed stats are requested, display them
if ($detailTables) {
disp_tables_details_stat_section($groupStat);
}
}
}
/**
* This function is called by the changes_stat_group() function.
* It generates the page section corresponding to the tables estimates statistics output
*/
function disp_tables_estimates_stat_section($groupStat) {
global $misc, $lang, $emajdb;
// Get statistics from E-Maj
if ($_REQUEST['rangeend'] == 'currentsituation')
$stats = $emajdb->getLogStatGroup($_REQUEST['group'], $_REQUEST['rangestart'],'');
else
$stats = $emajdb->getLogStatGroup($_REQUEST['group'], $_REQUEST['rangestart'], $_REQUEST['rangeend']);
$summary = $emajdb->getLogStatSummary();
if ($emajdb->getNumEmajVersion() >= 40400) { // version >= 4.4.0
$nbLogSession = $emajdb->getNbLogSessionInPeriod($_REQUEST['group'], $_REQUEST['rangestart'], $_REQUEST['rangeend']);
} else {
$nbLogSession = 0;
}
// Title
if ($_REQUEST['rangeend'] == 'currentsituation')
$misc->printSubtitle(sprintf($lang['strchangestblsince'], htmlspecialchars($_REQUEST['rangestart'])));
else
$misc->printSubtitle(sprintf($lang['strchangestblbetween'], htmlspecialchars($_REQUEST['rangestart']), htmlspecialchars($_REQUEST['rangeend'])));
// Display summary statistics
echo "<table class=\"data\"><tr>\n";
echo "<th class=\"data\"></th>";
echo "<th class=\"data\">{$lang['strtblingroup']}</th>";
echo "<th class=\"data\">{$lang['strtblwithchanges']}</th>";
echo "<th class=\"data\">{$lang['strchanges']}</th>";
echo "</tr><tr class=\"data1\">\n";
echo "<th class=\"data\" style=\"font-size: larger;\">{$lang['strestimates']}</td>\n";
echo "<td class=\"center\">{$groupStat->fields['nb_tbl_in_group']}</td>";
echo "<td class=\"center\">{$summary->fields['nb_tables']}</td>";
echo "<td class=\"center\">{$summary->fields['sum_rows']}</td>";
echo "</tr></table>\n";
if ($nbLogSession > 1) {
echo "<p><img src=\"{$misc->icon('Warning')}\" alt=\"warning\" style=\"vertical-align:middle; height:22px;\"/> {$lang['strlogsessionwarning']}</p>";
}
echo "<hr/>\n";
if ($summary->fields['nb_tables'] > 0) {
// Display per table statistics
$urlvars = $misc->getRequestVars();
$columns = array(
'schema' => array(
'title' => $lang['strschema'],
'field' => field('stat_schema'),
'url' => "schemas.php?action=list_schemas&{$misc->href}&",
'vars' => array('schema' => 'stat_schema'),
),
'table' => array(
'title' => $lang['strtable'],
'field' => field('stat_table'),
'url' => "redirect.php?subject=table&{$misc->href}&",
'vars' => array('schema' => 'stat_schema', 'table' => 'stat_table'),
));
if ($emajdb->getNumEmajVersion() >= 20300) { // version >= 2.3.0
$columns = array_merge($columns, array(
'start_mark' => array(
'upper_title' => $lang['strbegin'],
'upper_title_colspan' => 2,
'title' => $lang['strmark'],
'field' => field('stat_first_mark'),
),
'start_datetime' => array(
'title' => $lang['strdatetime'],
'field' => field('stat_first_mark_datetime'),
'type' => 'spanned',
'params'=> array(
'dateformat' => $lang['strrecenttimestampformat'],
'locale' => $lang['applocale'],
'class' => 'tooltip left-aligned-tooltip',
),
),
'end_mark' => array(
'upper_title' => $lang['strend'],
'upper_title_colspan' => 2,
'title' => $lang['strmark'],
'field' => field('stat_last_mark'),
),
'end_datetime' => array(
'title' => $lang['strdatetime'],
'field' => field('stat_last_mark_datetime'),
'type' => 'spanned',
'params'=> array(
'dateformat' => $lang['strrecenttimestampformat'],
'locale' => $lang['applocale'],
'class' => 'tooltip left-aligned-tooltip',
),
),
));
}
$columns = array_merge($columns, array(
'nbrow' => array(
'title' => $lang['strstatrows'],
'field' => field('stat_rows'),
'type' => 'numeric'
),
'actions' => array(
'title' => $lang['stractions'],
),
));
if ($emajdb->getNumEmajVersion() >= 40300) { // version >= 4.3.0
// Request parameters to prepare the SQL statement to edit
$actions = array(
'gen_sql_dump_changes' => array(
'content' => $lang['strbrowsechanges'],
'icon' => 'Eye',
'attr' => array (
'href' => array (
'url' => 'groupstat.php',
'urlvars' => array_merge($urlvars, array (
'action' => 'gen_sql_dump_changes',
'group' => field('stat_group'),
'schema' => field('stat_schema'),
'table' => field('stat_table'),
'startMark' => field('stat_first_mark'),
'startTs' => field('stat_first_mark_datetime'),
'endMark' => field('stat_last_mark'),
'endTs' => field('stat_last_mark_datetime'),
'verb' => '',
'role' => '',
'knownRoles' => ''
)))),
),
);
} else {
// Direct call to the sql editor
$actions = array(
'gen_sql_dump_changes' => array(
'content' => $lang['strbrowsechanges'],
'icon' => 'Eye',
'attr' => array (
'href' => array (
'url' => 'groupstat.php',
'urlvars' => array_merge($urlvars, array (
'action' => 'call_sqledit',
'sqlquery' => field('sql_text')
)))),
),
);
}
$misc->printTable($stats, $columns, $actions, 'logStats', null, null, array('sorter' => true, 'filter' => true));
// Dynamicaly change the behaviour of the SQL link using JQuery code: open a new window.
// The link may be either a text button with a SQL content (td of type textbutton) or an icon (td of type iconbutton)
$sql_window_id = htmlentities('emaj_sqledit:'.$_REQUEST['server']);
echo "<script>
$(\"#logStats\").find(\"td.textbutton a:contains('SQL'), td.iconbutton a\").click(function() {
window.open($(this).attr('href'),'{$sql_window_id}','toolbar=no,width=700,height=550,resizable=yes,scrollbars=yes').focus();
return false;
});
</script>\n";
}
}
/**
* This function is called by the changes_stat_group() function.
* It generates the page section corresponding to the sequences estimates statistics output
*/
function disp_sequences_estimates_stat_section($groupStat) {
global $misc, $lang, $emajdb;
// Get statistics from E-Maj
if ($_REQUEST['rangeend'] == 'currentsituation')
$stats = $emajdb->getSeqStatGroup($_REQUEST['group'],$_REQUEST['rangestart'],'');
else
$stats = $emajdb->getSeqStatGroup($_REQUEST['group'],$_REQUEST['rangestart'],$_REQUEST['rangeend']);
$summary = $emajdb->getSeqStatSummary();
// Title
if ($_REQUEST['rangeend'] == 'currentsituation')
$misc->printSubtitle(sprintf($lang['strchangesseqsince'], htmlspecialchars($_REQUEST['rangestart'])));
else
$misc->printSubtitle(sprintf($lang['strchangesseqbetween'], htmlspecialchars($_REQUEST['rangestart']), htmlspecialchars($_REQUEST['rangeend'])));
// Display summary statistics
echo "<table class=\"data\"><tr>\n";
echo "<th class=\"data\"></th>";
echo "<th class=\"data\">{$lang['strseqingroup']}</th>";
echo "<th class=\"data\">{$lang['strseqwithchanges']}</th>";
echo "</tr><tr class=\"data1\">\n";
echo "<th class=\"data\" style=\"font-size: larger;\">{$lang['strestimates']}</td>\n";
echo "<td class=\"center\">{$groupStat->fields['nb_seq_in_group']}</td>";
echo "<td class=\"center\">{$summary->fields['nb_sequences']}</td>";
echo "</tr></table>\n";
echo "<hr/>\n";
if ($summary->fields['nb_sequences'] > 0) {
// Display per sequence statistics
$urlvars = $misc->getRequestVars();
$columns = array(
'schema' => array(
'title' => $lang['strschema'],
'field' => field('stat_schema'),
'url' => "schemas.php?action=list_schemas&{$misc->href}&",
'vars' => array('schema' => 'stat_schema'),
),
'sequence' => array(
'title' => $lang['strsequence'],
'field' => field('stat_sequence'),
'url' => "redirect.php?subject=sequence&{$misc->href}&",
'vars' => array('schema' => 'stat_schema', 'sequence' => 'stat_sequence'),
),
'start_mark' => array(
'upper_title' => $lang['strbegin'],
'upper_title_colspan' => 2,
'title' => $lang['strmark'],
'field' => field('stat_first_mark'),
),
'start_datetime' => array(
'title' => $lang['strdatetime'],
'field' => field('stat_first_mark_datetime'),
'type' => 'spanned',
'params'=> array(
'dateformat' => $lang['strrecenttimestampformat'],
'locale' => $lang['applocale'],
'class' => 'tooltip left-aligned-tooltip',
),
),
'end_mark' => array(
'upper_title' => $lang['strend'],
'upper_title_colspan' => 2,
'title' => $lang['strmark'],
'field' => field('stat_last_mark'),
),
'end_datetime' => array(
'title' => $lang['strdatetime'],
'field' => field('stat_last_mark_datetime'),
'type' => 'spanned',
'params'=> array(
'dateformat' => $lang['strrecenttimestampformat'],
'locale' => $lang['applocale'],
'class' => 'tooltip left-aligned-tooltip',
),
),
'nbincrement' => array(
'title' => $lang['strstatincrements'],
'field' => field('stat_increments'),
'type' => 'numeric'
),
'hasstructurechanged' => array(
'title' => $lang['strstatstructurechanged'],
'field' => field('stat_has_structure_changed'),
'type' => 'callback',
'params'=> array('function' => 'renderBooleanIcon','align' => 'center')
),
);
$actions = '';
$misc->printTable($stats, $columns, $action, 'seqStats', null, null, array('sorter' => true, 'filter' => true));
}
}
/**
* This function is called by the changes_stat_group() function.
* It generates the page section corresponding to the detailed tables statistics output
*/
function disp_tables_details_stat_section($groupStat) {
global $misc, $lang, $emajdb;
if (!ini_get('safe_mode')) set_time_limit(0); // Prevent timeouts on large stats (non-safe mode only)
// Get statistics from E-Maj
if ($_REQUEST['rangeend']=='currentsituation')
$stats = $emajdb->getDetailedLogStatGroup($_REQUEST['group'],$_REQUEST['rangestart'],'');
else
$stats = $emajdb->getDetailedLogStatGroup($_REQUEST['group'],$_REQUEST['rangestart'],$_REQUEST['rangeend']);
$summary = $emajdb->getDetailedLogStatSummary();
$roles = $emajdb->getDetailedLogStatRoles();
$rolesList = implode(', ', $roles);
if ($emajdb->getNumEmajVersion() >= 40400) { // version >= 4.4.0
$nbLogSession = $emajdb->getNbLogSessionInPeriod($_REQUEST['group'], $_REQUEST['rangestart'], $_REQUEST['rangeend']);
} else {
$nbLogSession = 0;
}
// Title
if ($_REQUEST['rangeend'] == 'currentsituation')
$misc->printSubtitle(sprintf($lang['strchangestblsince'], htmlspecialchars($_REQUEST['rangestart'])));
else
$misc->printSubtitle(sprintf($lang['strchangestblbetween'], htmlspecialchars($_REQUEST['rangestart']), htmlspecialchars($_REQUEST['rangeend'])));
// Display summary statistics
echo "<table class=\"data\"><tr>\n";
echo "<th class=\"data\">{$lang['strtblingroup']}</th>";
echo "<th class=\"data\">{$lang['strtblwithchanges']}</th>";
echo "<th class=\"data\">{$lang['strchanges']}</th>";
echo "<th class=\"data\">{$lang['strnbinsert']}</th>";
echo "<th class=\"data\">{$lang['strnbupdate']}</th>";
echo "<th class=\"data\">{$lang['strnbdelete']}</th>";
echo "<th class=\"data\">{$lang['strnbtruncate']}</th>";
echo "<th class=\"data\">{$lang['strnbrole']}</th>";
echo "<th class=\"data\">{$lang['strroles']}</th>";
echo "</tr><tr class=\"data1\">\n";
echo "<td class=\"center\">{$groupStat->fields['nb_tbl_in_group']}</td>";
echo "<td class=\"center\">{$summary->fields['nb_tables']}</td>";
echo "<td class=\"center\">{$summary->fields['sum_rows']}</td>";
echo "<td class=\"center\">{$summary->fields['nb_ins']}</td>";
echo "<td class=\"center\">{$summary->fields['nb_upd']}</td>";
echo "<td class=\"center\">{$summary->fields['nb_del']}</td>";
echo "<td class=\"center\">{$summary->fields['nb_tru']}</td>";
echo "<td class=\"center\">{$summary->fields['nb_roles']}</td>";
echo "<td class=\"center\">{$rolesList}</td>";
echo "</tr></table>\n";
if ($nbLogSession > 1) {
echo "<p><img src=\"{$misc->icon('Warning')}\" alt=\"warning\" style=\"vertical-align:middle; height:22px;\"/> {$lang['strlogsessionwarning']}</p>";
}
echo "<hr/>\n";
if ($summary->fields['nb_tables'] > 0) {
// Display per table statistics
$urlvars = $misc->getRequestVars();
$columns = array(
'schema' => array(
'title' => $lang['strschema'],
'field' => field('stat_schema'),
'url' => "schemas.php?action=list_schemas&{$misc->href}&",
'vars' => array('schema' => 'stat_schema'),
),
'table' => array(
'title' => $lang['strtable'],
'field' => field('stat_table'),
'url' => "redirect.php?subject=table&{$misc->href}&",
'vars' => array('schema' => 'stat_schema', 'table' => 'stat_table'),
));
if ($emajdb->getNumEmajVersion() >= 20300) { // version >= 2.3.0
$columns = array_merge($columns, array(
'start_mark' => array(
'upper_title' => $lang['strbegin'],
'upper_title_colspan' => 2,
'title' => $lang['strmark'],
'field' => field('stat_first_mark'),
),
'start_datetime' => array(
'title' => $lang['strdatetime'],
'field' => field('stat_first_mark_datetime'),
'type' => 'spanned',
'params'=> array(
'dateformat' => $lang['strrecenttimestampformat'],
'locale' => $lang['applocale'],
'class' => 'tooltip left-aligned-tooltip',
),
),
'end_mark' => array(
'upper_title' => $lang['strend'],
'upper_title_colspan' => 2,
'title' => $lang['strmark'],
'field' => field('stat_last_mark'),
),
'end_datetime' => array(
'title' => $lang['strdatetime'],
'field' => field('stat_last_mark_datetime'),
'type' => 'spanned',
'params'=> array(
'dateformat' => $lang['strrecenttimestampformat'],
'locale' => $lang['applocale'],
'class' => 'tooltip left-aligned-tooltip',
),
),
));
}
$columns = array_merge($columns, array(
'role' => array(
'title' => $lang['strrole'],
'field' => field('stat_role'),
),
'statement' => array(
'title' => $lang['strstatverb'],
'field' => field('stat_verb'),
),
'nbrow' => array(
'title' => $lang['strstatrows'],
'field' => field('stat_rows'),
'type' => 'numeric'
),
'actions' => array(
'title' => $lang['stractions'],
),
));
if ($emajdb->getNumEmajVersion() >= 40300) { // version >= 4.3.0
// Request parameters to prepare the SQL statement to edit
$actions = array(
'gen_sql_dump_changes' => array(
'content' => $lang['strbrowsechanges'],
'icon' => 'Eye',
'attr' => array (
'href' => array (
'url' => 'groupstat.php',
'urlvars' => array_merge($urlvars, array (
'action' => 'gen_sql_dump_changes',
'subject' => 'table',
'group' => field('stat_group'),
'schema' => field('stat_schema'),
'table' => field('stat_table'),
'startMark' => field('stat_first_mark'),
'startTs' => field('stat_first_mark_datetime'),
'endMark' => field('stat_last_mark'),
'endTs' => field('stat_last_mark_datetime'),
'verb' => field('stat_verb'),
'role' => field('stat_role'),
'knownRoles' => $rolesList
)))),
),
);
} else {
// Direct call to the sql editor
$actions = array(
'gen_sql_dump_changes' => array(
'content' => $lang['strbrowsechanges'],
'icon' => 'Eye',
'attr' => array (
'href' => array (
'url' => 'groupstat.php',
'urlvars' => array_merge($urlvars, array (
'action' => 'call_sqledit',
'subject' => 'table',
'sqlquery' => field('sql_text'),
'paginate' => 'true',
)))),
),
);
}
$misc->printTable($stats, $columns, $actions, 'detailedLogStats', null, null, array('sorter' => true, 'filter' => true));
// Dynamicaly change the behaviour of the SQL link using JQuery code: open a new window
$sql_window_id = htmlentities('emaj_sqledit:'.$_REQUEST['server']);
echo "<script>
$(\"#detailedLogStats\").find(\"td.textbutton a:contains('SQL'), td.iconbutton a\").click(function() {
window.open($(this).attr('href'),'{$sql_window_id}','toolbar=no,width=700,height=550,resizable=yes,scrollbars=yes').focus();
return false;
});
</script>\n";
}
}
/**
* Call the sqleditor.php page passing the sqlquery to display in $_SESSION
* We are already in the target frame
*/
function call_sqledit() {
global $misc;
$_SESSION['sqlquery'] = $_REQUEST['sqlquery'];
echo "<meta http-equiv=\"refresh\" content=\"0;url=sqledit.php?subject=table&{$misc->href}&action=sql&paginate=true\">";
}
/**
* Call the sqleditor.php page passing the sqlquery to display in $_SESSION
* We are already in the target frame
*/
function gen_sql_dump_changes() {
global $misc;
echo "<meta http-equiv=\"refresh\" content=\"0;url=sqledit.php?subject=table&{$misc->href}&action=gen_sql_dump_changes" .
"&group=" . urlencode($_REQUEST['group']) .
"&schema=" . urlencode($_REQUEST['schema']) . "&table=" . urlencode($_REQUEST['table']) .
"&startMark=" . urlencode($_REQUEST['startMark']) . "&startTs=" . urlencode($_REQUEST['startTs']) .
"&endMark=" . urlencode($_REQUEST['endMark']) . "&endTs=" . urlencode($_REQUEST['endTs']) .
"&verb=" . urlencode($_REQUEST['verb']) . "&role=" . urlencode($_REQUEST['role']) .
"&knownRoles=" . urlencode($_REQUEST['knownRoles']) . "\">";
}
/********************************************************************************************************
* Main piece of code
*******************************************************************************************************/
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
if (!isset($msg)) $msg = '';
$misc->printHtmlHeader($lang['strgroupsmanagement']);
$misc->printBody();
switch ($action) {
case 'call_sqledit':
call_sqledit();
break;
case 'changes_stat_group':
changes_stat_group();
break;
case 'gen_sql_dump_changes':
gen_sql_dump_changes();
break;
default:
changes_stat_group();
}
$misc->printFooter();
?>