forked from fisharebest/webtrees
-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_pgv_to_wt.php
1164 lines (1063 loc) · 48.6 KB
/
admin_pgv_to_wt.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
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* webtrees: online genealogy
* Copyright (C) 2016 webtrees development team
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Fisharebest\Webtrees;
use Fisharebest\Webtrees\Controller\PageController;
use PDO;
use PDOException;
/**
* Defined in session.php
*
* @global Tree $WT_TREE
*/
global $WT_TREE;
define('WT_SCRIPT_NAME', 'admin_pgv_to_wt.php');
require './includes/session.php';
// We can only import into an empty system, so deny access if we have already created a gedcom or added users.
if ($WT_TREE || count(User::all()) > 1) {
header('Location: ' . WT_BASE_URL);
return;
}
$controller = new PageController;
$controller
->restrictAccess(Auth::isAdmin())
->setPageTitle(I18N::translate('PhpGedView to webtrees transfer wizard'));
$error = false;
$PGV_PATH = Filter::post('PGV_PATH');
// We read these variables from PhpGedView's config.php, and set them here in case any are missing.
$INDEX_DIRECTORY = '';
$DBHOST = '';
$DBNAME = '';
$TBLPREFIX = '';
$PGV_SCHEMA_VERSION = '';
$USE_REGISTRATION_MODULE = '';
$ALLOW_USER_THEMES = '';
$ALLOW_CHANGE_GEDCOM = '';
$PGV_SESSION_TIME = '';
$PGV_SMTP_ACTIVE = '';
$PGV_SMTP_HOST = '';
$PGV_SMTP_HELO = '';
$PGV_SMTP_PORT = '';
$PGV_SMTP_AUTH = '';
$PGV_SMTP_AUTH_USER = '';
$PGV_SMTP_AUTH_PASS = '';
$PGV_SMTP_SSL = '';
$PGV_SMTP_FROM_NAME = '';
if ($PGV_PATH) {
if (!is_dir($PGV_PATH) || !is_readable($PGV_PATH . '/config.php')) {
FlashMessages::addMessage('The specified folder does not contain an installation of PhpGedView', 'danger');
$PGV_PATH = null;
} else {
// Load the configuration settings
$config_php = file_get_contents($PGV_PATH . '/config.php');
// The easiest way to do this is to exec() the file - but not lines containing require or PHP tags
$config_php = preg_replace(
array(
'/^\s*(include|require).*/m',
'/.*<\?php.*/',
'/.*\?>.*/',
), '', $config_php
);
eval($config_php);
// $INDEX_DIRECTORY can be either absolute or relative to the PhpGedView root.
if (preg_match('/^(\/|\\|[A-Z]:)/', $INDEX_DIRECTORY)) {
$INDEX_DIRECTORY = realpath($INDEX_DIRECTORY) . DIRECTORY_SEPARATOR;
} else {
$INDEX_DIRECTORY = realpath($PGV_PATH . '/' . $INDEX_DIRECTORY) . DIRECTORY_SEPARATOR;
}
$wt_config = parse_ini_file(WT_ROOT . 'data/config.ini.php');
if ($DBHOST != $wt_config['dbhost']) {
FlashMessages::addMessage(I18N::translate('PhpGedView must use the same database as webtrees.', 'danger'));
$PGV_PATH = null;
unset($wt_config);
} else {
unset($wt_config);
try {
$PGV_SCHEMA_VERSION = Database::prepare(
"SELECT site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting` WHERE site_setting_name='PGV_SCHEMA_VERSION'"
)->fetchOne();
if ($PGV_SCHEMA_VERSION < 10) {
FlashMessages::addMessage(I18N::translate('The version of %s is too old.', 'PhpGedView'), 'danger');
$PGV_PATH = null;
} elseif ($PGV_SCHEMA_VERSION > 14) {
FlashMessages::addMessage(I18N::translate('The version of %s is too new.', 'PhpGedView'), 'danger');
$PGV_PATH = null;
}
} catch (PDOException $ex) {
FlashMessages::addMessage(
/* I18N: %s is a database name/identifier */
I18N::translate('webtrees cannot connect to the PhpGedView database: %s.', $DBNAME . '@' . $DBHOST) .
'<br>' .
/* I18N: %s is an error message */
I18N::translate('MySQL gave the error: %s', $ex->getMessage()), 'danger');
$PGV_PATH = null;
}
}
}
}
if ($PGV_PATH) {
// The account we are using is about to be deleted.
Session::forget('wt_user');
}
$controller->pageHeader();
?>
<ol class="breadcrumb small">
<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
<li><a href="admin_trees_manage.php"><?php echo I18N::translate('Manage family trees'); ?></a></li>
<li class="active"><?php echo $controller->getPageTitle(); ?></li>
</ol>
<h1><?php echo $controller->getPageTitle(); ?></h1>
<?php
if (!$PGV_PATH) {
// Look for PhpGedView in some nearby directories
$pgv_dirs = array();
$dir = opendir(realpath('..'));
while (($subdir = readdir($dir)) !== false) {
// Exclude '..' as ascending too many levels can trigger open_basedir_restriction errors.
if ($subdir !== '..' && is_dir('../' . $subdir) && file_exists('../' . $subdir . '/config.php')) {
$pgv_dirs[] = '../' . $subdir;
}
}
closedir($dir);
if (count($pgv_dirs) > 1) {
$html = I18N::translate('PhpGedView might be installed in one of these folders:');
foreach ($pgv_dirs as $pgv_dir) {
$html .= '<div onclick="jQuery(\'#PGV_PATH\').val(\'' . Filter::escapeHtml($pgv_dir) . '\')">' . Filter::escapeHtml($pgv_dir) . '</div>';
}
echo Theme::theme()->htmlAlert($html, 'info', true);
}
?>
<form class="form-horizontal" method="post">
<div class="form-group">
<label class="control-label col-sm-3" for="PGV_PATH">
<?php echo I18N::translate('Where is your PhpGedView installation?'); ?>
</label>
<div class="col-sm-9">
<input
type="text"
class="form-control"
dir="ltr"
id="PGV_PATH"
name="PGV_PATH"
size="40"
placeholder="<?php echo I18N::translate('Installation folder'); ?>"
value="<?php echo count($pgv_dirs) === 1 ? Filter::escapeHtml($pgv_dirs[0]) : ''; ?>"
required
>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-primary">
<?php echo I18N::translate('continue'); ?>
</button>
</div>
</div>
</form>
<?php
return;
}
// Run in a transaction
Database::beginTransaction();
// Delete the existing user accounts, and any information associated with it
Database::exec("UPDATE `##log` SET user_id=NULL");
Database::exec("DELETE FROM `##change`");
Database::exec("DELETE `##block_setting` FROM `##block_setting` JOIN `##block` USING (block_id) WHERE user_id>0 OR gedcom_id>0");
Database::exec("DELETE FROM `##block` WHERE user_id>0 OR gedcom_id>0");
Database::exec("DELETE FROM `##message`");
Database::exec("DELETE FROM `##user_gedcom_setting` WHERE user_id>0");
Database::exec("DELETE FROM `##user_setting` WHERE user_id>0");
Database::exec("DELETE FROM `##user` WHERE user_id>0");
////////////////////////////////////////////////////////////////////////////////
echo '<p>', $INDEX_DIRECTORY, 'config.php => wt_site_setting…</p>';
Site::setPreference('USE_REGISTRATION_MODULE', $USE_REGISTRATION_MODULE);
Site::setPreference('ALLOW_USER_THEMES', $ALLOW_USER_THEMES);
Site::setPreference('ALLOW_CHANGE_GEDCOM', $ALLOW_CHANGE_GEDCOM);
Site::setPreference('SESSION_TIME', $PGV_SESSION_TIME);
Site::setPreference('SMTP_ACTIVE', $PGV_SMTP_ACTIVE ? 'external' : 'internal');
Site::setPreference('SMTP_HOST', $PGV_SMTP_HOST);
Site::setPreference('SMTP_HELO', $PGV_SMTP_HELO);
Site::setPreference('SMTP_PORT', $PGV_SMTP_PORT);
Site::setPreference('SMTP_AUTH', $PGV_SMTP_AUTH);
Site::setPreference('SMTP_AUTH_USER', $PGV_SMTP_AUTH_USER);
Site::setPreference('SMTP_AUTH_PASS', $PGV_SMTP_AUTH_PASS);
Site::setPreference('SMTP_SSL', $PGV_SMTP_SSL);
Site::setPreference('SMTP_FROM_NAME', $PGV_SMTP_FROM_NAME);
////////////////////////////////////////////////////////////////////////////////
echo '<p>pgv_site_setting => wt_site_setting…</p>';
Database::prepare(
"REPLACE INTO `##site_setting` (setting_name, setting_value)" .
" SELECT site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`" .
" WHERE site_setting_name IN ('DEFAULT_GEDCOM', 'LAST_CHANGE_EMAIL')"
)->execute();
////////////////////////////////////////////////////////////////////////////////
if ($PGV_SCHEMA_VERSION >= 12) {
echo '<p>pgv_gedcom => wt_gedcom…</p>';
Database::prepare(
"INSERT INTO `##gedcom` (gedcom_id, gedcom_name)" .
" SELECT gedcom_id, gedcom_name FROM `{$DBNAME}`.`{$TBLPREFIX}gedcom`"
)->execute();
echo '<p>pgv_gedcom_setting => wt_gedcom_setting…</p>';
Database::prepare(
"INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" .
" SELECT gedcom_id, setting_name," .
" CASE setting_name" .
" WHEN 'THEME_DIR' THEN" .
" CASE setting_value" .
" WHEN '' THEN ''" .
" WHEN 'themes/cloudy/' THEN 'clouds'" .
" WHEN 'themes/minimal/' THEN 'minimal'" .
" WHEN 'themes/simplyblue/' THEN 'colors'" .
" WHEN 'themes/simplygreen/' THEN 'colors'" .
" WHEN 'themes/simplyred/' THEN 'colors'" .
" WHEN 'themes/xenea/' THEN 'xenea'" .
" ELSE 'themes/webtrees/'" . // ocean, simplyred/blue/green, standard, wood
" END" .
" WHEN 'LANGUAGE' THEN" .
" CASE setting_value" .
" WHEN 'arabic' THEN 'ar'" .
" WHEN 'catalan' THEN 'ca'" .
" WHEN 'chinese' THEN 'zh_CN'" .
" WHEN 'croatian' THEN 'hr'" .
" WHEN 'danish' THEN 'da'" .
" WHEN 'dutch' THEN 'nl'" .
" WHEN 'english' THEN 'en_US'" .
" WHEN 'english-uk' THEN 'en_GB'" . // PhpGedView once had the config for this, but no language files
" WHEN 'estonian' THEN 'et'" .
" WHEN 'finnish' THEN 'fi'" .
" WHEN 'french' THEN 'fr'" .
" WHEN 'german' THEN 'de'" .
" WHEN 'greek' THEN 'el'" .
" WHEN 'hebrew' THEN 'he'" .
" WHEN 'hungarian' THEN 'hu'" .
" WHEN 'indonesian' THEN 'id'" .
" WHEN 'italian' THEN 'it'" .
" WHEN 'lithuanian' THEN 'lt'" .
" WHEN 'norwegian' THEN 'nn'" .
" WHEN 'polish' THEN 'pl'" .
" WHEN 'portuguese' THEN 'pt'" .
" WHEN 'romainian' THEN 'ro'" .
" WHEN 'russian' THEN 'ru'" .
" WHEN 'serbian-la' THEN 'sr@Latn'" .
" WHEN 'slovak' THEN 'sk'" .
" WHEN 'slovenian' THEN 'sl'" .
" WHEN 'spanish' THEN 'es'" .
" WHEN 'spanish-ar' THEN 'es'" . // webtrees does not yet have this variant
" WHEN 'swedish' THEN 'sv'" .
" WHEN 'turkish' THEN 'tr'" .
" WHEN 'vietnamese' THEN 'vi'" .
" ELSE 'en_US'" .
" END" .
" ELSE setting_value" .
" END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}gedcom_setting`" .
" WHERE setting_name NOT IN ('HOME_SITE_TEXT', 'HOME_SITE_URL')"
)->execute();
echo '<p>pgv_user => wt_user…</p>';
try {
// "INSERT IGNORE" is needed to allow for PhpGedView users with duplicate emails. Only the first will be imported.
Database::prepare(
"INSERT IGNORE INTO `##user` (user_id, user_name, real_name, email, password)" .
" SELECT user_id, user_name, CONCAT_WS(' ', us1.setting_value, us2.setting_value), us3.setting_value, password FROM `{$DBNAME}`.`{$TBLPREFIX}user`" .
" LEFT JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us1 USING (user_id)" .
" LEFT JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us2 USING (user_id)" .
" JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us3 USING (user_id)" .
" WHERE us1.setting_name='firstname'" .
" AND us2.setting_name='lastname'" .
" AND us3.setting_name='email'"
)->execute();
} catch (PDOException $ex) {
// Ignore duplicates
}
echo '<p>pgv_user_setting => wt_user_setting…</p>';
Database::prepare(
"INSERT INTO `##user_setting` (user_id, setting_name, setting_value)" .
" SELECT user_id, setting_name," .
" CASE setting_name" .
" WHEN 'language' THEN " .
" CASE setting_value" .
" WHEN 'arabic' THEN 'ar'" .
" WHEN 'catalan' THEN 'ca'" .
" WHEN 'chinese' THEN 'zh_CN'" .
" WHEN 'croatian' THEN 'hr'" .
" WHEN 'danish' THEN 'da'" .
" WHEN 'dutch' THEN 'nl'" .
" WHEN 'english' THEN 'en_US'" .
" WHEN 'english-uk' THEN 'en_GB'" . // PhpGedView once had the config for this, but no language files
" WHEN 'estonian' THEN 'et'" .
" WHEN 'finnish' THEN 'fi'" .
" WHEN 'french' THEN 'fr'" .
" WHEN 'german' THEN 'de'" .
" WHEN 'greek' THEN 'el'" .
" WHEN 'hebrew' THEN 'he'" .
" WHEN 'hungarian' THEN 'hu'" .
" WHEN 'indonesian' THEN 'id'" .
" WHEN 'italian' THEN 'it'" .
" WHEN 'lithuanian' THEN 'lt'" .
" WHEN 'norwegian' THEN 'nn'" .
" WHEN 'polish' THEN 'pl'" .
" WHEN 'portuguese' THEN 'pt'" .
" WHEN 'romainian' THEN 'ro'" .
" WHEN 'russian' THEN 'ru'" .
" WHEN 'serbian-la' THEN 'sr@Latn'" .
" WHEN 'slovak' THEN 'sk'" .
" WHEN 'slovenian' THEN 'sl'" .
" WHEN 'spanish' THEN 'es'" .
" WHEN 'spanish-ar' THEN 'es'" . // webtrees does not yet have this variant
" WHEN 'swedish' THEN 'sv'" .
" WHEN 'turkish' THEN 'tr'" .
" WHEN 'vietnamese' THEN 'vi'" .
" ELSE 'en_US'" .
" END" .
" WHEN 'theme' THEN" .
" CASE setting_value" .
" WHEN '' THEN ''" .
" WHEN 'themes/cloudy/' THEN 'clouds'" .
" WHEN 'themes/minimal/' THEN 'minimal'" .
" WHEN 'themes/simplyblue/' THEN 'colors'" .
" WHEN 'themes/simplygreen/' THEN 'colors'" .
" WHEN 'themes/simplyred/' THEN 'colors'" .
" WHEN 'themes/xenea/' THEN 'xenea'" .
" ELSE 'themes/webtrees/'" . // ocean, simplyred/blue/green, standard, wood
" END" .
" ELSE" .
" CASE" .
" WHEN setting_value IN ('Y', 'yes') THEN 1 WHEN setting_value IN ('N', 'no') THEN 0 ELSE setting_value END" .
" END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}user_setting`" .
" JOIN `##user` USING (user_id)" .
" WHERE setting_name NOT IN ('email', 'firstname', 'lastname', 'loggedin')"
)->execute();
echo '<p>pgv_user_gedcom_setting => wt_user_gedcom_setting…</p>';
Database::prepare(
"INSERT INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value)" .
" SELECT user_id, gedcom_id, setting_name, setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}user_gedcom_setting`" .
" JOIN `##user` USING (user_id)"
)->execute();
} else {
// Copied from PhpGedView's db_schema_11_12
if (file_exists($INDEX_DIRECTORY . 'gedcoms.php')) {
require_once $INDEX_DIRECTORY . 'gedcoms.php';
echo '<p>', $INDEX_DIRECTORY . 'gedcoms.php', ' => wt_gedcom…</p>';
if (isset($GEDCOMS) && is_array($GEDCOMS)) {
foreach ($GEDCOMS as $array) {
try {
Database::prepare("INSERT INTO `##gedcom` (gedcom_id, gedcom_name) VALUES (?,?)")
->execute(array($array['id'], $array['gedcom']));
} catch (PDOException $ex) {
// Ignore duplicates
}
// insert gedcom
foreach ($array as $key => $value) {
if ($key != 'id' && $key != 'gedcom' && $key != 'commonsurnames') {
try {
Database::prepare("INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES (?,?, ?)")
->execute(array($array['id'], $key, $value));
} catch (PDOException $ex) {
// Ignore duplicates
}
}
}
}
}
}
// Migrate the data from pgv_users into pgv_user/pgv_user_setting/pgv_user_gedcom_setting
echo '<p>pgv_users => wt_user…</p>';
try {
// "INSERT IGNORE" is needed to allow for PhpGedView users with duplicate emails. Only the first will be imported.
Database::prepare(
"INSERT IGNORE INTO `##user` (user_name, real_name, email, password)" .
" SELECT u_username, CONCAT_WS(' ', u_firstname, u_lastname), u_email, u_password FROM `{$DBNAME}`.`{$TBLPREFIX}users`"
)->execute();
} catch (PDOException $ex) {
// This could only fail if;
// a) we've already done it (upgrade)
// b) it doesn't exist (new install)
}
echo '<p>pgv_users => wt_user_setting…</p>';
try {
Database::prepare(
"INSERT INTO `##user_setting` (user_id, setting_name, setting_value)" .
" SELECT user_id, 'canadmin', " .
" CASE WHEN u_canadmin IN ('Y', 'yes') THEN 1 WHEN u_canadmin IN ('N', 'no') THEN 0 ELSE u_canadmin END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'verified', " .
" CASE WHEN u_verified IN ('Y', 'yes') THEN 1 WHEN u_verified IN ('N', 'no') THEN 0 ELSE u_verified END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'verified_by_admin', " .
" CASE WHEN u_verified_by_admin IN ('Y', 'yes') THEN 1 WHEN u_verified_by_admin IN ('N', 'no') THEN 0 ELSE u_verified_by_admin END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'language', " .
" CASE u_language" .
" WHEN 'catalan' THEN 'ca'" .
" WHEN 'danish' THEN 'da'" .
" WHEN 'dutch' THEN 'nl'" .
" WHEN 'english' THEN 'en_US'" .
" WHEN 'english-uk' THEN 'en_GB'" . // PhpGedView had the config for en_GB, but no language files
" WHEN 'estonian' THEN 'et'" .
" WHEN 'finnish' THEN 'fi'" .
" WHEN 'french' THEN 'fr'" .
" WHEN 'german' THEN 'de'" .
" WHEN 'hebrew' THEN 'he'" .
" WHEN 'hungarian' THEN 'hu'" .
" WHEN 'italian' THEN 'it'" .
" WHEN 'norwegian' THEN 'nn'" .
" WHEN 'polish' THEN 'pl'" .
" WHEN 'portuguese' THEN 'pt'" .
" WHEN 'russian' THEN 'ru'" .
" WHEN 'slovak' THEN 'sk'" .
" WHEN 'slovenian' THEN 'sl'" .
" WHEN 'spanish' THEN 'es'" .
" WHEN 'swedish' THEN 'sv'" .
" WHEN 'turkish' THEN 'tr'" .
" ELSE 'en_US'" . // PhpGedView supports other languages that webtrees does not (yet)
" END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'reg_timestamp', u_reg_timestamp" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'reg_hashcode', u_reg_hashcode" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'theme', " .
" CASE u_theme" .
" WHEN '' THEN ''" .
" WHEN 'themes/cloudy/' THEN 'clouds'" .
" WHEN 'themes/minimal/' THEN 'minimal'" .
" WHEN 'themes/simplyblue/' THEN 'colors'" .
" WHEN 'themes/simplygreen/' THEN 'colors'" .
" WHEN 'themes/simplyred/' THEN 'colors'" .
" WHEN 'themes/xenea/' THEN 'xenea'" .
" ELSE 'themes/webtrees/'" . // ocean, simplyred/blue/green, standard, wood
" END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'sessiontime', u_sessiontime" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'contactmethod', u_contactmethod" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'visibleonline', " .
" CASE WHEN u_visibleonline IN ('Y', 'yes') THEN 1 WHEN u_visibleonline IN ('N', 'no') THEN 0 ELSE u_visibleonline END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'comment', u_comment" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'relationship_privacy', " .
" CASE WHEN u_relationship_privacy IN ('Y', 'yes') THEN 1 WHEN u_relationship_privacy IN ('N', 'no') THEN 0 ELSE u_relationship_privacy END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'max_relation_path', u_max_relation_path" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" .
" UNION ALL" .
" SELECT user_id, 'auto_accept', " .
" CASE WHEN u_auto_accept IN ('Y', 'yes') THEN 1 WHEN u_auto_accept IN ('N', 'no') THEN 0 ELSE u_auto_accept END" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)"
)->execute();
} catch (PDOException $ex) {
// This could only fail if;
// a) we've already done it (upgrade)
// b) it doesn't exist (new install)
}
// Some PhpGedView installations store the u_reg_timestamp in the format "2010-03-07 21:41:07"
Database::prepare(
"UPDATE `##user_setting` SET setting_value=UNIX_TIMESTAMP(setting_value) WHERE setting_name='reg_timestamp' AND setting_value LIKE '____-__-__ __:__:__'"
)->execute();
// Some PhpGedView installations have empty/invalid values for reg_timestamp
Database::prepare(
"UPDATE `##user_setting` SET setting_value=CAST(setting_value AS UNSIGNED) WHERE setting_name='reg_timestamp'"
)->execute();
echo '<p>pgv_users => wt_user_gedcom_setting…</p>';
$user_gedcom_settings =
Database::prepare(
"SELECT user_id, u_gedcomid, u_rootid, u_canedit" .
" FROM `{$DBNAME}`.`{$TBLPREFIX}users`" .
" JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)"
)->fetchAll();
foreach ($user_gedcom_settings as $setting) {
try {
$array = unserialize($setting->u_gedcomid);
foreach ($array as $gedcom => $value) {
$tree = Tree::findByName($gedcom);
if ($tree !== null) {
Database::prepare(
"INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)"
)->execute(array($setting->user_id, $tree->getTreeId(), 'gedcomid', $value));
}
}
} catch (\ErrorException $ex) {
// Invalid serialized data?
}
try {
$array = unserialize($setting->u_rootid);
foreach ($array as $gedcom => $value) {
$tree = Tree::findByName($gedcom);
if ($tree !== null) {
Database::prepare(
"INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)"
)->execute(array($setting->user_id, $tree->getTreeId(), 'rootid', $value));
}
}
} catch (\ErrorException $ex) {
// Invalid serialized data?
}
try {
$array = unserialize($setting->u_canedit);
foreach ($array as $gedcom => $value) {
$tree = Tree::findByName($gedcom);
if ($tree !== null) {
Database::prepare(
"INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)"
)->execute(array($setting->user_id, $tree->getTreeId(), 'canedit', $value));
}
}
} catch (\ErrorException $ex) {
// Invalid serialized data?
}
}
}
define('PGV_PHPGEDVIEW', true);
define('PGV_PRIV_PUBLIC', Auth::PRIV_PRIVATE);
define('PGV_PRIV_USER', Auth::PRIV_USER);
define('PGV_PRIV_NONE', Auth::PRIV_NONE);
define('PGV_PRIV_HIDE', Auth::PRIV_HIDE);
$PRIV_PUBLIC = Auth::PRIV_PRIVATE;
$PRIV_USER = Auth::PRIV_USER;
$PRIV_NONE = Auth::PRIV_NONE;
$PRIV_HIDE = Auth::PRIV_HIDE;
// Old versions of PhpGedView used a $GEDCOMS[] array.
// New versions used a database.
$GEDCOMS = Database::prepare(
"SELECT" .
" gedcom_id AS id," .
" gedcom_name AS gedcom," .
" gs1.setting_value AS config," .
" gs2.setting_value AS privacy" .
" FROM `##gedcom`" .
" JOIN `##gedcom_setting` AS gs1 USING (gedcom_id)" .
" JOIN `##gedcom_setting` AS gs2 USING (gedcom_id)" .
" WHERE gedcom_id>0" .
" AND gs1.setting_name='config'" .
" AND gs2.setting_name='privacy'"
)->fetchAll(PDO::FETCH_ASSOC);
foreach ($GEDCOMS as $GEDCOM => $GED_DATA) {
// We read these variables from PhpGedView's index/*_conf.php, and set them here in case any are missing.
$ADVANCED_NAME_FACTS = '';
$ADVANCED_PLAC_FACTS = '';
$ALLOW_THEME_DROPDOWN = '';
$CALENDAR_FORMAT = '';
$CHART_BOX_TAGS = '';
$COMMON_NAMES_ADD = '';
$COMMON_NAMES_REMOVE = '';
$COMMON_NAMES_THRESHOLD = '';
$CONTACT_EMAIL = '';
$DEFAULT_PEDIGREE_GENERATIONS = '';
$EXPAND_NOTES = '';
$EXPAND_RELATIVES_EVENTS = '';
$EXPAND_SOURCES = '';
$FAM_FACTS_ADD = '';
$FAM_FACTS_QUICK = '';
$FAM_FACTS_UNIQUE = '';
$FAM_ID_PREFIX = '';
$FULL_SOURCES = '';
$GEDCOM_ID_PREFIX = '';
$GENERATE_UIDS = '';
$HIDE_GEDCOM_ERRORS = '';
$HIDE_LIVE_PEOPLE = '';
$INDI_FACTS_ADD = '';
$INDI_FACTS_QUICK = '';
$INDI_FACTS_UNIQUE = '';
$LANGUAGE = '';
$MAX_ALIVE_AGE = '';
$MAX_DESCENDANCY_GENERATIONS = '';
$MAX_PEDIGREE_GENERATIONS = '';
$MAX_RELATION_PATH_LENGTH = '';
$MEDIA_ID_PREFIX = '';
$META_DESCRIPTION = '';
$META_TITLE = '';
$MULTI_MEDIA = '';
$NOTE_FACTS_ADD = '';
$NOTE_FACTS_QUICK = '';
$NOTE_FACTS_UNIQUE = '';
$NO_UPDATE_CHAN = '';
$PEDIGREE_FULL_DETAILS = '';
$PEDIGREE_LAYOUT = '';
$PEDIGREE_ROOT_ID = '';
$PEDIGREE_SHOW_GENDER = '';
$PREFER_LEVEL2_SOURCES = '';
$QUICK_REQUIRED_FACTS = '';
$QUICK_REQUIRED_FAMFACTS = '';
$REPO_FACTS_ADD = '';
$REPO_FACTS_QUICK = '';
$REPO_FACTS_UNIQUE = '';
$REPO_ID_PREFIX = '';
$REQUIRE_AUTHENTICATION = '';
$SAVE_WATERMARK_IMAGE = '';
$SAVE_WATERMARK_THUMB = '';
$SHOW_AGE_DIFF = '';
$SHOW_COUNTER = '';
$SHOW_DEAD_PEOPLE = '';
$SHOW_EST_LIST_DATES = '';
$SHOW_FACT_ICONS = '';
$SHOW_GEDCOM_RECORD = '';
$SHOW_HIGHLIGHT_IMAGES = '';
$SHOW_LDS_AT_GLANCE = '';
$SHOW_LEVEL2_NOTES = '';
$SHOW_LIST_PLACES = '';
$SHOW_LIVING_NAMES = '';
$SHOW_MEDIA_DOWNLOAD = '';
$SHOW_PARENTS_AGE = '';
$SHOW_PEDIGREE_PLACES = '';
$SHOW_PRIVATE_RELATIONSHIPS = '';
$SHOW_RELATIVES_EVENTS = '';
$SOURCE_ID_PREFIX = '';
$SOUR_FACTS_ADD = '';
$SOUR_FACTS_QUICK = '';
$SOUR_FACTS_UNIQUE = '';
$SUBLIST_TRIGGER_I = '';
$SURNAME_LIST_STYLE = '';
$SURNAME_TRADITION = '';
$THEME_DIR = '';
$THUMBNAIL_WIDTH = '';
$USE_RELATIONSHIP_PRIVACY = '';
$USE_RIN = '';
$WATERMARK_THUMB = '';
$WEBMASTER_EMAIL = '';
$WORD_WRAPPED_NOTES = '';
$config = str_replace(array('$INDEX_DIRECTORY', '${INDEX_DIRECTORY}'), $INDEX_DIRECTORY, $GED_DATA['config']);
if (substr($config, 0, 1) === '.') {
$config = $PGV_PATH . '/' . $config;
}
if (is_readable($config)) {
echo '<p>Reading configuration file ', $config, '</p>';
require $config;
} else {
echo '<p>Error - could not read configuration file ', $config, '</p>';
}
$stmt_default_resn = Database::prepare("INSERT INTO `##default_resn` (gedcom_id, xref, tag_type, resn) VALUES (?, ?, ?, CASE ? WHEN -1 THEN 'hidden' WHEN 0 THEN 'confidential' WHEN 1 THEN 'privacy' ELSE 'none' END)");
$stmt_gedcom_setting = Database::prepare("INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES (?,?,?)");
$privacy = str_replace(array('$INDEX_DIRECTORY', '${INDEX_DIRECTORY}'), $INDEX_DIRECTORY, $GED_DATA['privacy']);
if (substr($config, 0, 1) == '.') {
$privacy = $PGV_PATH . '/' . $privacy;
}
if (is_readable($privacy)) {
// initialise this, in case it is missing from the file
$person_privacy = array();
$person_facts = array();
$global_facts = array();
echo '<p>Reading privacy file ', $privacy, '</p>';
require $privacy;
foreach ($global_facts as $key => $value) {
if (isset($value['details'])) {
$stmt_default_resn->execute(array($GED_DATA['id'], null, $key, $value['details']));
}
}
foreach ($person_privacy as $key => $value) {
if (isset($value['details'])) {
$stmt_default_resn->execute(array($GED_DATA['id'], $key, null, $value['details']));
}
}
foreach ($person_facts as $key1 => $array) {
foreach ($array as $key2 => $value) {
if (isset($value['details'])) {
$stmt_default_resn->execute(array($GED_DATA['id'], $key1, $key2, $value['details']));
}
}
}
} else {
echo '<p>Could not read privacy file ', $privacy, '</p>';
}
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'ADVANCED_NAME_FACTS', $ADVANCED_NAME_FACTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'ADVANCED_PLAC_FACTS', $ADVANCED_PLAC_FACTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'ALLOW_THEME_DROPDOWN', $ALLOW_THEME_DROPDOWN));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'CALENDAR_FORMAT', $CALENDAR_FORMAT));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'CHART_BOX_TAGS', $CHART_BOX_TAGS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'COMMON_NAMES_ADD', $COMMON_NAMES_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'COMMON_NAMES_REMOVE', $COMMON_NAMES_REMOVE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'COMMON_NAMES_THRESHOLD', $COMMON_NAMES_THRESHOLD));
$user = User::findByIdentifier($CONTACT_EMAIL);
if ($user) {
$stmt_gedcom_setting->execute([$GED_DATA['id'], 'CONTACT_USER_ID', $user->getUserId()]);
}
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'DEFAULT_PEDIGREE_GENERATIONS', $DEFAULT_PEDIGREE_GENERATIONS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'EXPAND_NOTES', $EXPAND_NOTES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'EXPAND_RELATIVES_EVENTS', $EXPAND_RELATIVES_EVENTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'EXPAND_SOURCES', $EXPAND_SOURCES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_FACTS_ADD', $FAM_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_FACTS_QUICK', $FAM_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_FACTS_UNIQUE', $FAM_FACTS_UNIQUE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_ID_PREFIX', $FAM_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FULL_SOURCES', $FULL_SOURCES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'GEDCOM_ID_PREFIX', $GEDCOM_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'GENERATE_UIDS', $GENERATE_UIDS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'HIDE_GEDCOM_ERRORS', $HIDE_GEDCOM_ERRORS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'HIDE_LIVE_PEOPLE', $HIDE_LIVE_PEOPLE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'INDI_FACTS_ADD', $INDI_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'INDI_FACTS_QUICK', $INDI_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'INDI_FACTS_UNIQUE', $INDI_FACTS_UNIQUE));
switch ($LANGUAGE) {
case 'catalan':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'ca'));
break;
case 'english-uk':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'en-GB'));
break;
case 'polish':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'pl'));
break;
case 'italian':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'it'));
break;
case 'spanish':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'es'));
break;
case 'finnish':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'fi'));
break;
case 'french':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'fr'));
break;
case 'german':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'de'));
break;
case 'danish':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'da'));
break;
case 'portuguese':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'pt'));
break;
case 'hebrew':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'he'));
break;
case 'estonian':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'et'));
break;
case 'turkish':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'tr'));
break;
case 'dutch':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'nl'));
break;
case 'slovak':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'sk'));
break;
case 'norwegian':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'nn'));
break;
case 'slovenian':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'sl'));
break;
case 'hungarian':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'hu'));
break;
case 'swedish':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'sv'));
break;
case 'russian':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'ru'));
break;
default:
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'en-US'));
break;
}
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_ALIVE_AGE', $MAX_ALIVE_AGE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_DESCENDANCY_GENERATIONS', $MAX_DESCENDANCY_GENERATIONS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_PEDIGREE_GENERATIONS', $MAX_PEDIGREE_GENERATIONS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_RELATION_PATH_LENGTH', $MAX_RELATION_PATH_LENGTH));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MEDIA_DIRECTORY', 'media/'));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MEDIA_ID_PREFIX', $MEDIA_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'META_DESCRIPTION', $META_DESCRIPTION));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'META_TITLE', $META_TITLE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MEDIA_UPLOAD', $MULTI_MEDIA)); // see schema v12-13
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_FACTS_ADD', $NOTE_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_FACTS_QUICK', $NOTE_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_FACTS_UNIQUE', $NOTE_FACTS_UNIQUE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_ID_PREFIX', 'N'));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NO_UPDATE_CHAN', $NO_UPDATE_CHAN));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_FULL_DETAILS', $PEDIGREE_FULL_DETAILS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_LAYOUT', $PEDIGREE_LAYOUT));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_ROOT_ID', $PEDIGREE_ROOT_ID));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_SHOW_GENDER', $PEDIGREE_SHOW_GENDER));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PREFER_LEVEL2_SOURCES', $PREFER_LEVEL2_SOURCES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'QUICK_REQUIRED_FACTS', $QUICK_REQUIRED_FACTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'QUICK_REQUIRED_FAMFACTS', $QUICK_REQUIRED_FAMFACTS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_FACTS_ADD', $REPO_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_FACTS_QUICK', $REPO_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_FACTS_UNIQUE', $REPO_FACTS_UNIQUE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_ID_PREFIX', $REPO_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REQUIRE_AUTHENTICATION', $REQUIRE_AUTHENTICATION));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SAVE_WATERMARK_IMAGE', $SAVE_WATERMARK_IMAGE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SAVE_WATERMARK_THUMB', $SAVE_WATERMARK_THUMB));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_AGE_DIFF', $SHOW_AGE_DIFF));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_COUNTER', $SHOW_COUNTER));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_DEAD_PEOPLE', $SHOW_DEAD_PEOPLE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_EST_LIST_DATES', $SHOW_EST_LIST_DATES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_FACT_ICONS', $SHOW_FACT_ICONS));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_GEDCOM_RECORD', $SHOW_GEDCOM_RECORD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_HIGHLIGHT_IMAGES', $SHOW_HIGHLIGHT_IMAGES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LDS_AT_GLANCE', $SHOW_LDS_AT_GLANCE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LEVEL2_NOTES', $SHOW_LEVEL2_NOTES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LIST_PLACES', $SHOW_LIST_PLACES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LIVING_NAMES', $SHOW_LIVING_NAMES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_MEDIA_DOWNLOAD', $SHOW_MEDIA_DOWNLOAD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_PARENTS_AGE', $SHOW_PARENTS_AGE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_PEDIGREE_PLACES', $SHOW_PEDIGREE_PLACES));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_PRIVATE_RELATIONSHIPS', $SHOW_PRIVATE_RELATIONSHIPS));
// Update these - see db_schema_5_6.php
$SHOW_RELATIVES_EVENTS = preg_replace('/_(BIRT|MARR|DEAT)_(COUS|MSIB|FSIB|GGCH|NEPH|GGPA)/', '', $SHOW_RELATIVES_EVENTS);
$SHOW_RELATIVES_EVENTS = preg_replace('/_FAMC_(RESI_EMIG)/', '', $SHOW_RELATIVES_EVENTS);
$SHOW_RELATIVES_EVENTS = preg_replace('/_MARR_(MOTH|FATH|FAMC)/', '_MARR_PARE', $SHOW_RELATIVES_EVENTS);
$SHOW_RELATIVES_EVENTS = preg_replace('/_DEAT_(MOTH|FATH)/', '_DEAT_PARE', $SHOW_RELATIVES_EVENTS);
preg_match_all('/[_A-Z]+/', $SHOW_RELATIVES_EVENTS, $match);
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_RELATIVES_EVENTS', implode(',', array_unique($match[0]))));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOURCE_ID_PREFIX', $SOURCE_ID_PREFIX));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOUR_FACTS_ADD', $SOUR_FACTS_ADD));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOUR_FACTS_QUICK', $SOUR_FACTS_QUICK));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOUR_FACTS_UNIQUE', $SOUR_FACTS_UNIQUE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SUBLIST_TRIGGER_I', $SUBLIST_TRIGGER_I));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SURNAME_LIST_STYLE', $SURNAME_LIST_STYLE));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SURNAME_TRADITION', $SURNAME_TRADITION));
switch ($THEME_DIR) {
case '':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', ''));
break;
case 'themes/cloudy/':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'clouds'));
break;
case 'themes/minimal/':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'minimal'));
break;
case 'themes/simplyblue/':
case 'themes/simplygreen/':
case 'themes/simplyred/':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'colors'));
break;
case 'themes/xenea/':
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'xenea'));
break;
default:
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'webtrees'));
break;
}
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THUMBNAIL_WIDTH', $THUMBNAIL_WIDTH));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'USE_RELATIONSHIP_PRIVACY', $USE_RELATIONSHIP_PRIVACY));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'USE_RIN', $USE_RIN));
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WATERMARK_THUMB', $WATERMARK_THUMB));
$user = User::findByIdentifier($WEBMASTER_EMAIL);
if ($user) {
$stmt_gedcom_setting->execute([$GED_DATA['id'], 'WEBMASTER_USER_ID', $user->getUserId()]);
}
$stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES));
}
Database::prepare("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('config', 'privacy', 'path', 'pgv_ver', 'imported')")->execute();
// webtrees 1.0.5 combines user and gedcom settings for relationship privacy
// into a combined user-gedcom setting, for more granular control
Database::exec(
"INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value)" .
" SELECT u.user_id, g.gedcom_id, 'RELATIONSHIP_PATH_LENGTH', LEAST(us1.setting_value, gs1.setting_value)" .
" FROM `##user` u" .
" CROSS JOIN `##gedcom` g" .
" LEFT JOIN `##user_setting` us1 ON (u.user_id =us1.user_id AND us1.setting_name='max_relation_path')" .
" LEFT JOIN `##user_setting` us2 ON (u.user_id =us2.user_id AND us2.setting_name='relationship_privacy')" .
" LEFT JOIN `##gedcom_setting` gs1 ON (g.gedcom_id=gs1.gedcom_id AND gs1.setting_name='MAX_RELATION_PATH_LENGTH')" .
" LEFT JOIN `##gedcom_setting` gs2 ON (g.gedcom_id=gs2.gedcom_id AND gs2.setting_name='USE_RELATIONSHIP_PRIVACY')" .
" WHERE us2.setting_value AND gs2.setting_value"
);
Database::exec(
"DELETE FROM `##gedcom_setting` WHERE setting_name IN ('MAX_RELATION_PATH_LENGTH', 'USE_RELATIONSHIP_PRIVACY')"
);
Database::exec(
"DELETE FROM `##user_setting` WHERE setting_name IN ('relationship_privacy', 'max_relation_path_length')"
);
////////////////////////////////////////////////////////////////////////////////
// The PhpGedView blocks don't migrate easily.
// Just give everybody and every tree default blocks
////////////////////////////////////////////////////////////////////////////////
Database::prepare(
"INSERT INTO `##block` (user_id, location, block_order, module_name)" .
" SELECT `##user`.user_id, location, block_order, module_name" .
" FROM `##block`" .
" JOIN `##user`" .
" WHERE `##block`.user_id = -1" .
" AND `##user`.user_id > 0"
)->execute();
Database::prepare(
"INSERT INTO `##block` (gedcom_id, location, block_order, module_name)" .
" SELECT `##gedcom`.gedcom_id, location, block_order, module_name" .
" FROM `##block`" .
" JOIN `##gedcom`" .
" WHERE `##block`.gedcom_id = -1" .
" AND `##gedcom`.gedcom_id > 0"
)->execute();
////////////////////////////////////////////////////////////////////////////////
// Hit counter
////////////////////////////////////////////////////////////////////////////////
//
if ($PGV_SCHEMA_VERSION >= 13) {
echo '<p>pgv_hit_counter => wt_hit_counter…</p>';
Database::prepare(
"REPLACE INTO `##hit_counter` (gedcom_id, page_name, page_parameter, page_count)" .