forked from HuubMons/HuMo-genealogy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.php
1763 lines (1519 loc) · 77.4 KB
/
list.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
include_once("header.php"); //returns CMS_ROOTPATH constant
include_once(CMS_ROOTPATH."include/language_date.php");
include_once(CMS_ROOTPATH."include/date_place.php");
include_once(CMS_ROOTPATH."include/person_cls.php");
//error_reporting(E_ALL);
@set_time_limit(300);
// *** show person ***
function show_person($personDb){
global $dbh, $db_functions, $index_list, $selected_place, $language, $user;
global $bot_visit, $humo_option, $uri_path, $search_database, $list_expanded;
global $selected_language, $privacy, $dirmark1, $dirmark2, $rtlmarker;
global $select_birth, $select_bapt, $select_place, $select_death, $select_buried;
global $selectsort;
$pers_tree_prefix=$personDb->pers_tree_prefix;
$db_functions->set_tree_prefix($pers_tree_prefix);
$db_functions->set_tree_id($personDb->pers_tree_id);
if (CMS_SPECIFIC=='Joomla'){
$start_url='index.php?option=com_humo-gen&task=family&database='.$pers_tree_prefix.
'&id='.$personDb->pers_indexnr.'&main_person='.$personDb->pers_gedcomnumber;
}
elseif ($humo_option["url_rewrite"]=="j"){ // *** url_rewrite ***
// *** $uri_path made in header.php ***
$start_url= $uri_path.'family/'.$pers_tree_prefix.'/'.$personDb->pers_indexnr.'/'.$personDb->pers_gedcomnumber.'/';
}
else{
$start_url=CMS_ROOTPATH.'family.php?database='.$pers_tree_prefix.'&id='.$personDb->pers_indexnr.'&main_person='.$personDb->pers_gedcomnumber;
}
// *** Person class used for name and person pop-up data ***
$person_cls = New person_cls;
$person_cls->construct($personDb);
$name=$person_cls->person_name($personDb);
// *** Show name ***
$index_name='';
if ($name["show_name"]==false){
$index_name=__('Name filtered');
}
else{
// *** If there is no lastname, show a - character. ***
if ($personDb->pers_lastname==""){
// Don't show a "-" by pers_patronymes
if (!isset($_GET['pers_patronym'])){ $index_name="- "; }
}
$index_name.=$name["index_name_extended"].$name["colour_mark"];
}
// *** Show extra colums before a person in index places ***
if ($index_list=='places'){
if ($selected_place!=$personDb->place_order)
echo '<td colspan="7"><b>'.$dirmark2."$personDb->place_order</b></td></tr><tr>";
$selected_place=$personDb->place_order;
echo '<td valign="top" style="white-space:nowrap;width:90px">';
if ($select_birth=='1'){
if ($selected_place==$personDb->pers_birth_place)
echo '<span class="place_index place_index_selected">'.__('*').'</span>';
else
echo '<span class="place_index"> </span>';
}
if ($select_bapt=='1'){
if ($selected_place==$personDb->pers_bapt_place)
echo '<span class="place_index place_index_selected">'.__('~').'</span>';
else
echo '<span class="place_index"> </span>';
}
if ($select_place=='1'){
if ($selected_place==$personDb->pers_place_index)
echo '<span class="place_index place_index_selected">'.__('^').'</span>';
else
echo '<span class="place_index"> </span>';
}
if ($select_death=='1'){
if ($selected_place==$personDb->pers_death_place)
echo '<span class="place_index place_index_selected">'.__('†').'</span>';
else
echo '<span class="place_index"> </span>';
}
if ($select_buried=='1'){
if ($selected_place==$personDb->pers_buried_place)
echo '<span class="place_index place_index_selected">'.__('[]').'</span>';
else
echo '<span class="place_index"> </span>';
}
echo '</td>';
}
echo '<td valign="top" style="border-right:0px; white-space:nowrap;">';
// *** Show person popup menu ***
echo $person_cls->person_popup_menu($personDb);
// *** Show picture man or wife ***
if ($personDb->pers_sexe=="M")
echo $dirmark1.' <img src="'.CMS_ROOTPATH.'images/man.gif" alt="man" style="vertical-align:top">';
elseif ($personDb->pers_sexe=="F")
echo $dirmark1.' <img src="'.CMS_ROOTPATH.'images/woman.gif" alt="woman" style="vertical-align:top">';
else
echo $dirmark1.' <img src="'.CMS_ROOTPATH.'images/unknown.gif" alt="unknown" style="vertical-align:top">';
echo '</td><td style="border-left:0px;">';
// *** Show name of person ***
echo ' <a href="'.$start_url.'">'.$index_name.'</a>';
//*** Show spouse/ partner ***
if ($list_expanded==true AND $personDb->pers_fams){
$marriage_array=explode(";",$personDb->pers_fams);
// *** Code to show only last marriage ***
//$last_relation=end($marriage_array);
//$qry="SELECT * FROM ".$pers_tree_prefix."family WHERE fam_gedcomnumber='".$last_relation."'";
$nr_marriages=count($marriage_array);
for ($x=0; $x<=$nr_marriages-1; $x++){
$fam_partnerDb = $db_functions->get_family($marriage_array[$x]);
// *** This check is better then a check like: $personDb->pers_sexe=='F', because of unknown sexe or homosexual relations. ***
if ($personDb->pers_gedcomnumber==$fam_partnerDb->fam_man)
$partner_id=$fam_partnerDb->fam_woman;
else
$partner_id=$fam_partnerDb->fam_man;
//$relation_short=__('&');
$relation_short=__('&');
if ($fam_partnerDb->fam_marr_date OR $fam_partnerDb->fam_marr_place OR $fam_partnerDb->fam_marr_church_date OR $fam_partnerDb->fam_marr_church_place OR $fam_partnerDb->fam_kind=='civil')
$relation_short=__('X');
if($fam_partnerDb->fam_div_date OR $fam_partnerDb->fam_div_place)
$relation_short=__(') (');
if ($partner_id!='0' AND $partner_id!=''){
$partnerDb = $db_functions->get_person($partner_id);
$partner_cls = New person_cls;
$name=$partner_cls->person_name($partnerDb);
}
else{
$name["standard_name"]=__('N.N.');
}
if ($nr_marriages>1 and $x>0) echo ',';
echo ' <span class="index_partner" style="font-size:10px;">';
if ($nr_marriages>1){
if ($x==0) echo __('1st');
elseif ($x==1) echo __('2nd');
elseif ($x==2) echo __('3rd');
elseif ($x>2) echo ($x+1).__('th');
}
//echo ' '.$relation_short.' '.$name["standard_name"].'</span> ';
echo ' '.$relation_short.' '.rtrim($name["standard_name"]).'</span>';
}
}
// *** End spouse/ partner ***
echo '</td><td style="white-space:nowrap;">';
$info="";
if ($personDb->pers_bapt_date)
$info=__('~').' '.date_place($personDb->pers_bapt_date, '');
if ($personDb->pers_birth_date)
$info=__('*').' '.date_place($personDb->pers_birth_date, '');
//echo "<span style='font-size:90%'>".$info.$dirmark1."</span>";
if ($privacy==1 and $info) echo ' '.__('PRIVACY FILTER');
else echo $info;
echo '</td><td>';
$info="";
if ($personDb->pers_bapt_place)
$info=__('~').' '.$personDb->pers_bapt_place;
if ($personDb->pers_birth_place)
$info=__('*').' '.$personDb->pers_birth_place;
//echo "<span style='font-size:90%'>".$info.$dirmark1."</span>";
if ($privacy==1 and $info) echo ' '.__('PRIVACY FILTER');
else echo $info;
echo '</td><td style="white-space:nowrap;">';
$info="";
if ($personDb->pers_buried_date)
$info=__('[]').' '.date_place($personDb->pers_buried_date, '');
if ($personDb->pers_death_date)
$info=__('†').' '.date_place($personDb->pers_death_date, '');
//echo "<span style='font-size:90%'>".$info.$dirmark1."</span>";
if ($privacy==1 and $info) echo ' '.__('PRIVACY FILTER');
else echo $info;
echo '</td><td>';
$info="";
if ($personDb->pers_buried_place)
$info=__('[]').' '.$personDb->pers_buried_place;
if ($personDb->pers_death_place)
$info=__('†').' '.$personDb->pers_death_place;
//echo "<span style='font-size:90%'>".$info.$dirmark1."</span>";
if ($privacy==1 and $info) echo ' '.__('PRIVACY FILTER');
else echo $info;
// *** Show name of family tree, if search in multiple family trees is used ***
if ($search_database=='all_trees' OR $search_database=='all_but_this'){
$treetext=show_tree_text($pers_tree_prefix, $selected_language);
echo '</td><td>';
echo '<i><font size="-1">'.$treetext['name'].'</font></i>';
}
echo '</td></tr>';
} // *** end function show person ***
// *** index ***
$index_list='quicksearch';
// *** Reset search fields if necessary ***
if (isset($_POST['pers_firstname']) OR isset($_GET['pers_lastname']) OR isset($_GET['reset']) OR isset($_POST['quicksearch'])){
unset ($_SESSION["save_search_tree_prefix"]);
unset ($_SESSION["save_search_database"]);
unset ($_SESSION["save_adv_search"]);
//unset ($_SESSION["save_quicksearch"]);
// *** Array containing multiple search values ***
unset ($_SESSION["save_selection"]);
$index_list='search';
}
if (isset($_POST["index_list"])) $index_list=$_POST['index_list'];
if (isset($_GET["index_list"])) $index_list=$_GET['index_list'];
// *** Extra reset needed for "search in all family trees" ***
if ($index_list!='search' AND $index_list!='quicksearch') unset ($_SESSION["save_search_database"]);
// *** Save selected "search" family tree (can be used to erase search values if tree is changed) ***
$_SESSION["save_search_tree_prefix"]=safe_text($_SESSION['tree_prefix']);
//************* SORT CHOICES *********************
$make_date=''; // we only need this when sorting by date
$desc_asc=" ASC "; $sort_desc=0;
if(isset($_SESSION['sort_desc'])) {
if($_SESSION['sort_desc'] == 1){ $desc_asc=" DESC "; $sort_desc=1; }
else{ $desc_asc=" ASC "; $sort_desc=0; }
}
if(isset($_GET['sort_desc'])) {
if($_GET['sort_desc'] == 1) { $desc_asc=" DESC "; $sort_desc=1; $_SESSION['sort_desc']=1; }
else { $desc_asc=" ASC "; $sort_desc=0; $_SESSION['sort_desc']=0; }
}
// *** SOME DEFAULTS ***
$last_or_patronym=" pers_lastname ";
if ($index_list=='patronym') $last_or_patronym = " pers_patronym ";
$orderby = $last_or_patronym.$desc_asc.", pers_firstname ".$desc_asc;
if ($user['group_kindindex']=="j" AND $index_list!='patronym'){ $orderby = " concat_name ".$desc_asc; }
$selectsort = ''; if(isset($_SESSION['sort']) AND !isset($_GET['sort'])) { $selectsort = $_SESSION['sort']; }
if(isset($_GET['sort'])) {
if($_GET['sort']=="sort_lastname") { $selectsort="sort_lastname"; $_SESSION['sort']=$selectsort; }
if($_GET['sort']=="sort_firstname") { $selectsort="sort_firstname"; $_SESSION['sort']=$selectsort; }
if($_GET['sort']=="sort_birthdate") { $selectsort="sort_birthdate"; $_SESSION['sort']=$selectsort; }
if($_GET['sort']=="sort_birthplace") { $selectsort="sort_birthplace"; $_SESSION['sort']=$selectsort; }
//if($_GET['sort']=="sort_baptdate") { $selectsort="sort_baptdate"; $_SESSION['sort']=$selectsort; }
if($_GET['sort']=="sort_deathdate") { $selectsort="sort_deathdate"; $_SESSION['sort']=$selectsort; }
if($_GET['sort']=="sort_deathplace") { $selectsort="sort_deathplace"; $_SESSION['sort']=$selectsort; }
//if($_GET['sort']=="sort_burieddate") { $selectsort="sort_burieddate"; $_SESSION['sort']=$selectsort; }
}
if ($selectsort){
if($selectsort=="sort_lastname") {
$orderby = $last_or_patronym.$desc_asc.", pers_firstname ".$desc_asc;
if ($user['group_kindindex']=="j" AND $index_list!='patronym'){ $orderby = " concat_name ".$desc_asc; }
}
if($selectsort=="sort_firstname") {
$orderby = " pers_firstname ".$desc_asc.",".$last_or_patronym.$desc_asc;
}
if($selectsort=="sort_birthdate") {
//$make_date = ", right(pers_birth_date,4) as year,
//date_format( str_to_date( substring(pers_birth_date,-8,3),'%b' ),'%m') as month,
//date_format( str_to_date( left(pers_birth_date,2),'%d' ),'%d') as day";
//$orderby = " year".$desc_asc.", month".$desc_asc.", day".$desc_asc.", ".$last_or_patronym." ASC , pers_firstname ASC";
// *** Replace ABT, AFT, BEF items and sort by birth or baptise date ***
$make_date= ", CASE
WHEN pers_birth_date = '' THEN replace(replace(replace(pers_bapt_date,'ABT ',''),'AFT ',''),'BEF ','')
ELSE replace(replace(replace(pers_birth_date,'ABT ',''),'AFT ',''),'BEF ','')
END AS year";
$orderby = " CONCAT( right(year,4),
date_format( str_to_date( substring(year,-8,3),'%b' ) ,'%m'),
date_format( str_to_date( substring(year,-11,2),'%d' ),'%d')
)".$desc_asc.", ".$last_or_patronym." ASC , pers_firstname ASC";
}
if($selectsort=="sort_birthplace") {
//$orderby = " pers_birth_place ".$desc_asc.",".$last_or_patronym.$desc_asc;
$make_date= ", CASE
WHEN pers_birth_place = '' THEN pers_bapt_place ELSE pers_birth_place
END AS place";
$orderby = " place".$desc_asc.", ".$last_or_patronym.$desc_asc;
}
if($selectsort=="sort_deathdate") {
//$make_date = ", right(pers_death_date,4) as year,
//date_format( str_to_date( substring(pers_death_date,-8,3),'%b' ),'%m') as month,
//date_format( str_to_date( left(pers_death_date,2),'%d' ),'%d') as day";
//$orderby = " year".$desc_asc.", month".$desc_asc.", day".$desc_asc.", ".$last_or_patronym." ASC , pers_firstname ASC";
// *** Replace ABT, AFT, BEF items and sort by death or buried date ***
$make_date= ", CASE
WHEN pers_death_date = '' THEN replace(replace(replace(pers_buried_date,'ABT ',''),'AFT ',''),'BEF ','')
ELSE replace(replace(replace(pers_death_date,'ABT ',''),'AFT ',''),'BEF ','')
END AS year";
$orderby = " CONCAT( right(year,4),
date_format( str_to_date( substring(year,-8,3),'%b' ) ,'%m'),
date_format( str_to_date( substring(year,-11,2),'%d' ),'%d')
)".$desc_asc.", ".$last_or_patronym." ASC , pers_firstname ASC";
}
if($selectsort=="sort_deathplace") {
//$orderby = " pers_death_place ".$desc_asc.",".$last_or_patronym.$desc_asc;
$make_date= ", CASE
WHEN pers_death_place = '' THEN pers_buried_place ELSE pers_death_place
END AS place";
$orderby = " place".$desc_asc.", ".$last_or_patronym.$desc_asc;
}
/*
// *** Old code for seperate columns baptise and buried dates ***
if($selectsort=="sort_baptdate") {
$make_date = ", right(pers_bapt_date,4) as year,
date_format( str_to_date( substring(pers_bapt_date,-8,3),'%b' ),'%m') as month,
date_format( str_to_date( left(pers_bapt_date,2),'%d' ),'%d') as day";
$orderby = " year".$desc_asc.", month".$desc_asc.", day".$desc_asc.", ".$last_or_patronym." ASC , pers_firstname ASC";
}
if($selectsort=="sort_burieddate") {
$make_date = ", right(pers_buried_date,4) as year,
date_format( str_to_date( substring(pers_buried_date,-8,3),'%b' ),'%m') as month,
date_format( str_to_date( left(pers_buried_date,2),'%d' ),'%d') as day";
$orderby = " year".$desc_asc.", month".$desc_asc.", day".$desc_asc.", ".$last_or_patronym." ASC , pers_firstname ASC";
}
*/
}
//************* END SORT CHOICES *********************
// *** Search in 1 or more family trees ***
//$search_database='';
$search_database='tree_selected';
if (isset($_POST['search_database'])){
$search_database=$_POST['search_database']; $_SESSION["save_search_database"]=$search_database;
}
if (isset($_GET["search_database"])){
$search_database=$_GET['search_database']; $_SESSION["save_search_database"]=$search_database;
}
$selection['pers_firstname']='';
if (isset($_POST['pers_firstname'])){
$selection['pers_firstname']=$_POST['pers_firstname'];
//$selection['pers_firstname']=htmlentities($_POST['pers_firstname'],ENT_QUOTES,'UTF-8');
}
$selection['part_firstname']='';
if (isset($_POST['part_firstname'])){
$selection['part_firstname']=$_POST['part_firstname'];
}
// *** Pre-fix (names list and most frequent names in main menu.) ***
$selection['pers_prefix']='';
if (isset($_POST['pers_prefix'])){ $selection['pers_prefix']=$_POST['pers_prefix']; }
if (isset($_GET['pers_prefix'])){
$selection['pers_prefix']=$_GET['pers_prefix'];
//$selection['pers_prefix']=htmlentities($_GET['pers_prefix'],ENT_QUOTES,'UTF-8');
}
// *** Lastname ***
$selection['pers_lastname']='';
if (isset($_POST['pers_lastname'])){
$selection['pers_lastname']=$_POST['pers_lastname'];
//$selection['pers_lastname']=htmlentities($_POST['pers_lastname'],ENT_QUOTES,'UTF-8');
$_SESSION["save_selection"]=$selection;
}
if (isset($_GET["pers_lastname"])){
$selection['pers_lastname']=$_GET['pers_lastname'];
//$selection['pers_lastname']=htmlentities($_GET['pers_lastname'],ENT_QUOTES,'UTF-8');
$selection['pers_lastname']=str_replace("|", "&", $selection['pers_lastname']); // Don't use a & character in a GET link
$_SESSION["save_selection"]=$selection;
}
$selection['part_lastname']='';
if (isset($_POST['part_lastname'])){
$selection['part_lastname']=$_POST['part_lastname'];
$_SESSION["save_selection"]=$selection;
}
// *** Used for clicking in the names list ***
if (isset($_GET['part_lastname'])){
$selection['part_lastname']=$_GET['part_lastname'];
$_SESSION["save_selection"]=$selection;
}
// *** ADVANCED SEARCH added by Yossi Beck, translated and integrated in person search screen by Huub. *** //
$selection['birth_place']=''; if (isset($_POST['birth_place'])){ $selection['birth_place']=$_POST['birth_place']; }
$selection['part_birth_place']=''; if (isset($_POST['part_birth_place'])){ $selection['part_birth_place']=$_POST['part_birth_place']; }
$selection['death_place']=''; if (isset($_POST['death_place'])){ $selection['death_place']=$_POST['death_place']; }
$selection['part_death_place']=''; if (isset($_POST['part_death_place'])){ $selection['part_death_place']=$_POST['part_death_place']; }
$selection['birth_year']=''; if (isset($_POST['birth_year'])){ $selection['birth_year']=$_POST['birth_year']; }
$selection['birth_year_end']=''; if (isset($_POST['birth_year_end'])){ $selection['birth_year_end']=$_POST['birth_year_end']; }
$selection['death_year']=''; if (isset($_POST['death_year'])){ $selection['death_year']=$_POST['death_year']; }
$selection['death_year_end']=''; if (isset($_POST['death_year_end'])){ $selection['death_year_end']=$_POST['death_year_end']; }
$selection['spouse_firstname']='';
if (isset($_POST['spouse_firstname'])){
$selection['spouse_firstname']=$_POST['spouse_firstname'];
//$selection['spouse_firstname']=htmlentities($_POST['spouse_firstname'],ENT_QUOTES,'UTF-8');
}
$selection['part_spouse_firstname']='';
if (isset($_POST['part_spouse_firstname'])){ $selection['part_spouse_firstname']=$_POST['part_spouse_firstname']; }
$selection['spouse_lastname']='';
if (isset($_POST['spouse_lastname'])){
$selection['spouse_lastname']=$_POST['spouse_lastname'];
//$selection['spouse_lastname']=htmlentities($_POST['spouse_lastname'],ENT_QUOTES,'UTF-8');
}
$selection['part_spouse_lastname']='';
if (isset($_POST['part_spouse_lastname'])){ $selection['part_spouse_lastname']=$_POST['part_spouse_lastname']; }
$selection['sexe']=''; if (isset($_POST['sexe'])){ $selection['sexe']=$_POST['sexe']; }
$selection['own_code']=''; if (isset($_POST['own_code'])){ $selection['own_code']=$_POST['own_code']; }
$selection['part_own_code']=''; if (isset($_POST['part_own_code'])){ $selection['part_own_code']=$_POST['part_own_code']; }
// *** Profession ***
$selection['pers_profession']=''; if (isset($_POST['pers_profession'])){ $selection['pers_profession']=$_POST['pers_profession']; }
$selection['part_profession']=''; if (isset($_POST['part_profession'])){ $selection['part_profession']=$_POST['part_profession']; }
// *** Text ***
$selection['text']=''; if (isset($_POST['text'])){ $selection['text']=$_POST['text']; }
$selection['part_text']=''; if (isset($_POST['part_text'])){ $selection['part_text']=$_POST['part_text']; }
// *** Place ***
$selection['pers_place']=''; if (isset($_POST['pers_place'])){ $selection['pers_place']=$_POST['pers_place']; }
$selection['part_place']=''; if (isset($_POST['part_place'])){ $selection['part_place']=$_POST['part_place']; }
// *** Zip code ***
$selection['zip_code']=''; if (isset($_POST['zip_code'])){ $selection['zip_code']=$_POST['zip_code']; }
$selection['part_zip_code']=''; if (isset($_POST['part_zip_code'])){ $selection['part_zip_code']=$_POST['part_zip_code']; }
// *** Witness ***
$selection['witness']=''; if (isset($_POST['witness'])){ $selection['witness']=$_POST['witness']; }
$selection['part_witness']='';
if (isset($_POST['part_witness'])){
$selection['part_witness']=$_POST['part_witness'];
// ******************************************************
// *** THIS LAST LINE WILL SAVE ALL $selection VALUES ***
// ******************************************************
$_SESSION["save_selection"]=$selection;
}
$quicksearch='';
if (isset($_POST['quicksearch'])){
//$quicksearch=htmlentities($_POST['quicksearch'],ENT_QUOTES,'UTF-8');
$quicksearch=$_POST['quicksearch'];
$_SESSION["save_quicksearch"]=$quicksearch;
}
$adv_search=false;
// *** Link from "names" list, automatically use advanced search ***
if (isset($_GET['part_lastname'])){
$_GET['adv_search']='1';
$_SESSION["save_selection"]=$selection;
}
if (isset($_GET['adv_search'])){
if ($_GET['adv_search']=='1'){
$adv_search=true;
//$quicksearch=''; $_SESSION["save_quicksearch"]=$quicksearch;
}
$_SESSION["save_adv_search"]=$adv_search;
// *** Switch from advanced search to standard search (now quick search) ***
if (isset($_SESSION["save_quicksearch"]) AND $_GET['adv_search']=='0'){
$quicksearch=$_SESSION["save_quicksearch"];
}
}
if (isset($_POST['adv_search'])){
if ($_POST['adv_search']=='1'){ $adv_search=true; }
$_SESSION["save_adv_search"]=$adv_search;
}
// *** For index places ***
$place_name='';
$select_birth='0'; $select_bapt='0'; $select_place='0'; $select_death='0'; $select_buried='0';
if (isset($_POST['place_name'])){
$place_name=$_POST['place_name'];
//$place_name=htmlentities($_POST['place_name'],ENT_QUOTES,'UTF-8');
$_SESSION["save_place_name"]=$place_name;
if (isset($_POST['select_birth'])){ $select_birth='1'; $_SESSION["save_select_birth"]='1'; }
else{ $_SESSION["save_select_birth"]='0'; }
if (isset($_POST['select_bapt'])){ $select_bapt='1'; $_SESSION["save_select_bapt"]='1'; }
else{ $_SESSION["save_select_bapt"]='0'; }
if (isset($_POST['select_place'])){ $select_place='1'; $_SESSION["save_select_place"]='1'; }
else{ $_SESSION["save_select_place"]='0'; }
if (isset($_POST['select_death'])){ $select_death='1'; $_SESSION["save_select_death"]='1'; }
else{ $_SESSION["save_select_death"]='0'; }
if (isset($_POST['select_buried'])){ $select_buried='1'; $_SESSION["save_select_buried"]='1'; }
else{ $_SESSION["save_select_buried"]='0'; }
}
$part_place_name='';
if (isset($_POST['part_place_name'])){
$part_place_name=$_POST['part_place_name'];
$_SESSION["save_part_place_name"]=$part_place_name;
}
// *** Read session for multiple pages ***
if (isset($_GET['item'])){
if (isset($_SESSION["save_search_database"])){ $search_database=$_SESSION["save_search_database"]; }
if (isset($_SESSION["save_quicksearch"])) $quicksearch=$_SESSION["save_quicksearch"];
if (isset($_SESSION["save_adv_search"])) $adv_search=$_SESSION["save_adv_search"];
// *** Multiple search values ***
if (isset($_SESSION["save_selection"])) $selection=$_SESSION["save_selection"];
}
// *** Search for places in birth-baptise-died places etc. ***
if ($index_list=='places'){
if (isset($_SESSION["save_place_name"])) $place_name=$_SESSION["save_place_name"];
if (isset($_SESSION["save_part_place_name"])) $part_place_name=$_SESSION["save_part_place_name"];
// *** Enable select boxes ***
if (isset($_GET['reset'])){
$select_birth='1'; $_SESSION["save_select_birth"]='1';
$select_bapt='1'; $_SESSION["save_select_bapt"]='1';
$select_place='1'; $_SESSION["save_select_place"]='1';
$select_death='1'; $_SESSION["save_select_death"]='1';
$select_buried='1'; $_SESSION["save_select_buried"]='1';
}
else{
// *** Read and set select boxes for multiple pages ***
if (isset($_SESSION["save_select_birth"])){ $select_birth=$_SESSION["save_select_birth"]; }
if (isset($_SESSION["save_select_bapt"])){ $select_bapt=$_SESSION["save_select_bapt"]; }
if (isset($_SESSION["save_select_place"])){ $select_place=$_SESSION["save_select_place"]; }
if (isset($_SESSION["save_select_death"])){ $select_death=$_SESSION["save_select_death"]; }
if (isset($_SESSION["save_select_buried"])){ $select_buried=$_SESSION["save_select_buried"]; }
}
}
// *** Search for (part of) first or lastname ***
function name_qry($search_name, $search_part){
$text="LIKE '%".safe_text($search_name)."%'"; // *** Default value: "contains" ***
if ($search_part=='equals'){ $text="='".safe_text($search_name)."'"; }
if ($search_part=='starts_with'){ $text="LIKE '".safe_text($search_name)."%'"; }
return $text;
}
// *******************
// *** BUILD QUERY ***
// *******************
$query='';
$count_qry='';
//*** Results of searchform in mainmenu ***
//*** Or: search in lastnames ***
if ($selection['pers_firstname'] OR $selection['pers_prefix'] OR $selection['pers_lastname'] OR $selection['birth_place'] OR $selection['death_place']
OR $selection['birth_year'] OR $selection['death_year'] OR ($selection['sexe'] AND $selection['sexe']!='both')
OR $selection['own_code'] OR $selection['pers_profession'] OR $selection['pers_place'] OR $selection['text']
OR $selection['zip_code'] OR $selection['witness'] ){
// *** Build query ***
//$and=" ";
$and=" AND ";
$add_address_qry=false;
$add_event_qry=false;
if ($selection['pers_lastname']) {
if ($selection['pers_lastname']==__('...')){
$query.=$and." pers_lastname=''"; $and=" AND ";
}
elseif ($user['group_kindindex']=="j"){
$query.=$and." CONCAT( REPLACE(pers_prefix,'_',' ') ,pers_lastname) ".
name_qry($selection['pers_lastname'], $selection['part_lastname']); $and=" AND ";
}
else {
$query.=$and." pers_lastname ".name_qry($selection['pers_lastname'], $selection['part_lastname']); $and=" AND ";
}
}
// *** Namelist: search persons without pers_prefix ***
if ($selection['pers_prefix']=='EMPTY'){
$query.=$and."pers_prefix=''"; $and=" AND ";
}
elseif ($selection['pers_prefix']){
//$query.=$and."pers_prefix='".$selection['pers_prefix']."'"; $and=" AND ";
//$query.=$and."pers_prefix='".safe_text( str_replace(' ', '_', $selection['pers_prefix']) )."'"; $and=" AND ";
// *** Search results for: "van", "van " and "van_" ***
$pers_prefix=safe_text( str_replace(' ', '_', $selection['pers_prefix']));
//$query.=$and."(pers_prefix='".$pers_prefix."' OR SUBSTRING(pers_prefix,-1) ='".$pers_prefix."')"; $and=" AND ";
$query.=$and."(pers_prefix='".$pers_prefix."' OR pers_prefix ='".$pers_prefix.'_'."')"; $and=" AND ";
}
if ($selection['pers_firstname']){
$query.=$and."(pers_firstname ".name_qry($selection['pers_firstname'], $selection['part_firstname']);
//$query.=" OR event_event ".name_qry($selection['pers_firstname'], $selection['part_firstname']).')';
$query.=" OR (event_kind='name' AND event_event ".name_qry($selection['pers_firstname'], $selection['part_firstname']).') )';
$and=" AND ";
$add_event_qry=true;
}
// *** Search for born AND baptised place ***
if ($selection['birth_place']){
//$query.=$and."pers_birth_place ".name_qry($selection['birth_place'], $selection['part_birth_place']); $and=" AND ";
$query.=$and."(pers_birth_place ".name_qry($selection['birth_place'], $selection['part_birth_place']); $and=" AND ";
$query.=" OR pers_bapt_place ".name_qry($selection['birth_place'], $selection['part_birth_place']).')'; $and=" AND ";
}
// *** Search for death AND buried place ***
if ($selection['death_place']){
//$query.=$and."pers_death_place ".name_qry($selection['death_place'], $selection['part_death_place']); $and=" AND ";
$query.=$and."(pers_death_place ".name_qry($selection['death_place'], $selection['part_death_place']); $and=" AND ";
$query.=" OR pers_buried_place ".name_qry($selection['death_place'], $selection['part_death_place']).')'; $and=" AND ";
}
if ($selection['birth_year']){
if (!$selection['birth_year_end']){ // filled in one year: exact date
//$query.=$and."pers_birth_date LIKE '%".safe_text($selection['birth_year'])."%'"; $and=" AND ";
// *** Also search for baptise ***
$query.=$and."(pers_birth_date LIKE '%".safe_text($selection['birth_year'])."%'"; $and=" AND ";
$query.=" OR pers_bapt_date LIKE '%".safe_text($selection['birth_year'])."%')"; $and=" AND ";
} else{
//$query.=$and."RIGHT(pers_birth_date, 4)>='".safe_text($selection['birth_year'])."' AND RIGHT(pers_birth_date, 4)<='".safe_text($selection['birth_year_end'])."'"; $and=" AND ";
// *** Also search for baptise ***
$query.=$and."(RIGHT(pers_birth_date, 4)>='".safe_text($selection['birth_year'])."' AND RIGHT(pers_birth_date, 4)<='".safe_text($selection['birth_year_end'])."'"; $and=" AND ";
$query.=" OR RIGHT(pers_bapt_date, 4)>='".safe_text($selection['birth_year'])."' AND RIGHT(pers_bapt_date, 4)<='".safe_text($selection['birth_year_end'])."')"; $and=" AND ";
}
}
if ($selection['death_year']){
if (!$selection['death_year_end']){ // filled in one year: exact date
//$query.=$and."pers_death_date LIKE '%".safe_text($selection['death_year'])."%'"; $and=" AND ";
// ** Also search for buried date ***
$query.=$and."(pers_death_date LIKE '%".safe_text($selection['death_year'])."%'"; $and=" AND ";
$query.="OR pers_buried_date LIKE '%".safe_text($selection['death_year'])."%')"; $and=" AND ";
} else {
//$query.=$and."RIGHT(pers_death_date, 4)>='".safe_text($selection['death_year'])."' AND RIGHT(pers_death_date, 4)<='".safe_text($selection['death_year_end'])."'"; $and=" AND ";
// ** Also search for buried date ***
$query.=$and."(RIGHT(pers_death_date, 4)>='".safe_text($selection['death_year'])."' AND RIGHT(pers_death_date, 4)<='".safe_text($selection['death_year_end'])."'"; $and=" AND ";
$query.=" OR RIGHT(pers_buried_date, 4)>='".safe_text($selection['death_year'])."' AND RIGHT(pers_buried_date, 4)<='".safe_text($selection['death_year_end'])."')"; $and=" AND ";
}
}
if ($selection['sexe']=="M" OR $selection['sexe']=="F"){
$query.=$and."pers_sexe='".$selection['sexe']."'"; $and=" AND ";
}
if ($selection['sexe']=="Unknown"){
$query.=$and."(pers_sexe!='M' AND pers_sexe!='F')"; $and=" AND ";
}
if ($selection['own_code']){
$query.=$and."pers_own_code ".name_qry($selection['own_code'], $selection['part_own_code']); $and=" AND ";
}
if ($selection['pers_profession']){
$query.=$and." (event_kind='profession' AND event_event ".name_qry($selection['pers_profession'], $selection['part_profession']).')';
$and=" AND ";
$add_event_qry=true;
}
if ($selection['text']){
$query.=$and."pers_text ".name_qry($selection['text'], $selection['part_text']); $and=" AND ";
}
if ($selection['pers_place']){
$query.=$and." address_place ".name_qry($selection['pers_place'], $selection['part_place']);
$and=" AND ";
$add_address_qry=true;
}
if ($selection['zip_code']){
$query.=$and." address_zip ".name_qry($selection['zip_code'], $selection['part_zip_code']);
$and=" AND ";
$add_address_qry=true;
}
if ($selection['witness']){
$query.=$and." ( RIGHT(event_kind,7)='witness' AND event_event ".name_qry($selection['witness'], $selection['part_witness']).')';
$and=" AND ";
$add_event_qry=true;
}
// *** Change querie if searched for spouse ***
if($selection['spouse_firstname'] OR $selection['spouse_lastname']) {
$query.=$and."pers_fams!=''"; $and=" AND ";
}
// *** Build SELECT part of query. Search with option "ALL family trees" or "All but selected" ***
if ($search_database=='all_trees' OR $search_database=='all_but_this') {
$query_part=$query;
//$query='';
$counter=0;
$multi_tree='';
foreach($dbh->query("SELECT * FROM humo_trees WHERE tree_prefix!='EMPTY' ORDER BY tree_order") AS $datapdo) {
if($search_database=="all_but_this" AND $datapdo['tree_prefix']==safe_text($_SESSION['tree_prefix'])) {
continue;
}
// *** Check is family tree is shown or hidden for user group ***
$hide_tree_array=explode(";",$user['group_hide_trees']);
$hide_tree=false;
for ($x=0; $x<=count($hide_tree_array)-1; $x++){
if ($hide_tree_array[$x]==$datapdo['tree_id']){ $hide_tree=true; }
}
if ($hide_tree==false){
if ($counter > 0) $multi_tree.=' OR ';
$multi_tree.='pers_tree_id='.$datapdo['tree_id'];
$counter++;
//$tree_prefix=$datapdo['tree_prefix'];
// *** EXAMPLE ***
//$qry = "(SELECT * FROM humo1_persoon ".$query.') ';
//$qry.= " UNION (SELECT * FROM humo2_persoon ".$query.')';
//$qry.= " UNION (SELECT * FROM humo3_persoon ".$query.')';
//$qry.= " ORDER BY pers_lastname, pers_firstname";
//$union=''; if ($counter>1){ $union=' UNION '; }
/*
if ($user['group_kindindex']=="j"){
if ($counter>1) $query.=$union.'(SELECT ';
else $query.=$union.'(SELECT SQL_CALC_FOUND_ROWS ';
//$query.=safe_text($tree_prefix)."person.*, event_person_id, event_kind, event_event, address_place, address_zip ";
//$query.='CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name '.$make_date.'
//FROM '.safe_text($tree_prefix).'person
//LEFT JOIN '.safe_text($tree_prefix).'events ON pers_gedcomnumber=event_person_id
//LEFT JOIN '.safe_text($tree_prefix).'addresses ON pers_gedcomnumber=address_person_id
//WHERE'.$query_part.' GROUP BY pers_gedcomnumber)';
}
else{
if ($counter>1) $query.=$union.'(SELECT ';
else $query.=$union.'(SELECT SQL_CALC_FOUND_ROWS ';
//$query.=safe_text($tree_prefix)."person.*, event_kind, event_event, address_place, address_zip ";
//$query.=$make_date.'
//FROM '.safe_text($tree_prefix).'person
//LEFT JOIN '.safe_text($tree_prefix).'events ON pers_gedcomnumber=event_person_id
//LEFT JOIN '.safe_text($tree_prefix).'addresses ON pers_gedcomnumber=address_person_id
//WHERE'.$query_part.' GROUP BY pers_gedcomnumber)';
}
*/
}
}
}
else{
// *** Start building query, search in 1 database ***
$multi_tree=" pers_tree_id='".$tree_id."'";
/*
$query_select= "SELECT SQL_CALC_FOUND_ROWS ".safe_text($_SESSION['tree_prefix'])."person.*,
event_kind, event_event, address_place, address_zip,
CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name ".$make_date."
FROM ".safe_text($_SESSION['tree_prefix'])."person
LEFT JOIN ".safe_text($_SESSION['tree_prefix'])."events ON pers_gedcomnumber=event_person_id
LEFT JOIN ".safe_text($_SESSION['tree_prefix'])."addresses ON pers_gedcomnumber=address_person_id
WHERE";
$query=$query_select.' ('.$query.')';
$query.=" GROUP BY pers_gedcomnumber";
*/
}
// *** Build query, only add events and addresses tables if necessary ***
$query_select = "SELECT SQL_CALC_FOUND_ROWS humo_persons.*";
if ($add_event_qry)
$query_select .= ", event_kind, event_event";
if ($add_address_qry)
$query_select .= ", address_place, address_zip";
if ($user['group_kindindex']=="j"){
// *** Change ordering of index, using concat name ***
$query_select .= ", CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name ";
}
$query_select .= $make_date." FROM humo_persons";
if ($add_event_qry)
$query_select .= " LEFT JOIN humo_events ON event_person_id=pers_gedcomnumber AND event_tree_id=pers_tree_id";
if ($add_address_qry)
$query_select .= " LEFT JOIN humo_addresses ON address_person_id=pers_gedcomnumber AND address_tree_id=pers_tree_id";
$query_select .= " WHERE (".$multi_tree.") ".$query;
$query_select.=" GROUP BY pers_gedcomnumber";
$query_select.=" ORDER BY ".$orderby;
$query=$query_select;
}
// *** Menu quicksearch ***
if ($index_list=='quicksearch'){
// *** Replace space by % to find first AND lastname in one search "Huub Mons" ***
$quicksearch=str_replace(' ', '%', $quicksearch);
// *** In case someone entered "Mons, Huub" using a comma ***
$quicksearch = str_replace(',','',$quicksearch);
// One can enter "Huub Mons", "Mons Huub", "Huub van Mons", "van Mons, Huub", "Mons, Huub van" and even "Mons van, Huub"
// *** Build SELECT part of query. Search in ALL family trees ***
if ($search_database=='all_trees' OR $search_database=='all_but_this') {
$query='';
$counter=0;
$multi_tree='';
foreach($dbh->query("SELECT * FROM humo_trees WHERE tree_prefix!='EMPTY' ORDER BY tree_order") as $pdoresult) {
if($search_database=="all_but_this" AND $pdoresult['tree_prefix']==safe_text($_SESSION['tree_prefix'])) {
continue;
}
// *** Check if family tree is shown or hidden for user group ***
$hide_tree_array=explode(";",$user['group_hide_trees']);
$hide_tree=false;
for ($x=0; $x<=count($hide_tree_array)-1; $x++){
if ($hide_tree_array[$x]==$pdoresult['tree_id']){ $hide_tree=true; }
}
if ($hide_tree==false){
if ($counter > 0) $multi_tree.=' OR ';
$multi_tree.='pers_tree_id='.$pdoresult['tree_id'];
$counter++;
//$tree_prefix=$pdoresult['tree_prefix'];
// *** EXAMPLE ***
//$qry = "(SELECT * FROM humo1_person ".$query.') ';
//$qry.= " UNION (SELECT * FROM humo2_person ".$query.')';
//$qry.= " UNION (SELECT * FROM humo3_person ".$query.')';
//$qry.= " ORDER BY pers_lastname, pers_firstname";
//$union=''; if ($counter>1){ $union=' UNION '; }
/*
if ($counter>1) $query.=$union.'(SELECT';
else $query.=$union.'(SELECT SQL_CALC_FOUND_ROWS';
$query.=" *, CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name ".$make_date."
FROM ".safe_text($tree_prefix)."person
LEFT JOIN ".safe_text($tree_prefix)."events
ON pers_gedcomnumber=event_person_id AND event_kind='name'
WHERE CONCAT(pers_firstname,pers_callname,REPLACE(pers_prefix,'_',' '),pers_lastname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,REPLACE(pers_prefix,'_',' '),pers_firstname,pers_callname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,pers_firstname,pers_callname,REPLACE(pers_prefix,'_',' ')) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(REPLACE(pers_prefix,'_',' '), pers_lastname,pers_firstname,pers_callname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(event_event,REPLACE(pers_prefix,'_',' '),pers_lastname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,REPLACE(pers_prefix,'_',' '),event_event) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,event_event,REPLACE(pers_prefix,'_',' ')) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(REPLACE(pers_prefix,'_',' '), pers_lastname,event_event) LIKE '%".safe_text($quicksearch)."%'
GROUP BY pers_gedcomnumber)";
*/
}
}
}
else{
// *** Start building query, search in 1 database ***
$multi_tree="pers_tree_id='".$tree_id."'";
/*
$query= "SELECT SQL_CALC_FOUND_ROWS *, CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name ".$make_date."
FROM ".safe_text($_SESSION['tree_prefix'])."person
LEFT JOIN ".safe_text($_SESSION['tree_prefix'])."events
ON pers_gedcomnumber=event_person_id AND event_kind='name'
WHERE CONCAT(pers_firstname,pers_callname,REPLACE(pers_prefix,'_',' '),pers_lastname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,REPLACE(pers_prefix,'_',' '),pers_firstname,pers_callname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,pers_firstname,pers_callname,REPLACE(pers_prefix,'_',' ')) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(REPLACE(pers_prefix,'_',' '), pers_lastname,pers_firstname,pers_callname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(event_event,REPLACE(pers_prefix,'_',' '),pers_lastname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,REPLACE(pers_prefix,'_',' '),event_event) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,event_event,REPLACE(pers_prefix,'_',' ')) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(REPLACE(pers_prefix,'_',' '), pers_lastname,event_event) LIKE '%".safe_text($quicksearch)."%'
GROUP BY pers_gedcomnumber";
*/
}
$query.="SELECT SQL_CALC_FOUND_ROWS *,
CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name
".$make_date."
FROM humo_persons
LEFT JOIN humo_events ON event_person_id=pers_gedcomnumber AND event_kind='name' AND event_tree_id=pers_tree_id
WHERE (".$multi_tree.")
AND
( CONCAT(pers_firstname,pers_callname,REPLACE(pers_prefix,'_',' '),pers_lastname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,REPLACE(pers_prefix,'_',' '),pers_firstname,pers_callname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,pers_firstname,pers_callname,REPLACE(pers_prefix,'_',' ')) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(REPLACE(pers_prefix,'_',' '), pers_lastname,pers_firstname,pers_callname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(event_event,REPLACE(pers_prefix,'_',' '),pers_lastname) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,REPLACE(pers_prefix,'_',' '),event_event) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(pers_lastname,event_event,REPLACE(pers_prefix,'_',' ')) LIKE '%".safe_text($quicksearch)."%'
OR CONCAT(REPLACE(pers_prefix,'_',' '), pers_lastname,event_event) LIKE '%".safe_text($quicksearch)."%'
)
GROUP BY pers_gedcomnumber";
$query.=" ORDER BY ".$orderby;
}
//*** Places index ***
if ($index_list=='places'){
// *** EXAMPLE of a UNION querie ***
//$qry = "(SELECT * FROM humo1_person ".$query.') ';
//$qry.= " UNION (SELECT * FROM humo2_person ".$query.')';
//$qry.= " UNION (SELECT * FROM humo3_person ".$query.')';
//$qry.= " ORDER BY pers_lastname, pers_firstname";
$query='';
$start=false;
// *** Search birth place ***
if ($select_birth=='1'){
if ($user['group_kindindex']=="j"){
//$query = "(SELECT SQL_CALC_FOUND_ROWS *, CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name, pers_birth_place as place_order
// FROM ".safe_text($_SESSION['tree_prefix'])."person";
$query = "(SELECT SQL_CALC_FOUND_ROWS *, CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name, pers_birth_place as place_order
FROM humo_persons WHERE pers_tree_id='".$tree_id."'";
}
else{
//$query = "(SELECT SQL_CALC_FOUND_ROWS *, pers_birth_place as place_order FROM ".safe_text($_SESSION['tree_prefix'])."person";
$query = "(SELECT SQL_CALC_FOUND_ROWS *, pers_birth_place as place_order
FROM humo_persons WHERE pers_tree_id='".$tree_id."'";
}
if($place_name) {
//$query.= " WHERE pers_birth_place ".name_qry($place_name,$part_place_name);
$query.= " AND pers_birth_place ".name_qry($place_name,$part_place_name);
}
else {
//$query.= " WHERE pers_birth_place LIKE '_%'";
$query.= " AND pers_birth_place LIKE '_%'";
}
$query.=')';
$start=true;
}
// *** Search baptise place ***
if ($select_bapt=='1'){
if ($start==true){
$query.=' UNION '; $calc='';
}
else{
$calc='SQL_CALC_FOUND_ROWS ';
}
if ($user['group_kindindex']=="j"){
//$query.= "(SELECT ".$calc."*,CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name, pers_bapt_place as place_order
//FROM ".safe_text($_SESSION['tree_prefix'])."person";
$query.= "(SELECT ".$calc."*,CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name, pers_bapt_place as place_order
FROM humo_persons WHERE pers_tree_id='".$tree_id."'";
}
else{
//$query.= "(SELECT ".$calc."*, pers_bapt_place as place_order FROM ".safe_text($_SESSION['tree_prefix'])."person";
$query.= "(SELECT ".$calc."*, pers_bapt_place as place_order FROM humo_persons WHERE pers_tree_id='".$tree_id."'";
}
if ($place_name) {
//$query.= " WHERE pers_bapt_place ".name_qry($place_name,$part_place_name);
$query.= " AND pers_bapt_place ".name_qry($place_name,$part_place_name);
}
else {
//$query.= " WHERE pers_bapt_place LIKE '_%'";
$query.= " AND pers_bapt_place LIKE '_%'";
}
$query.=')';
$start=true;
}
// *** Search residence ***
if ($select_place=='1'){
if ($start==true){
$query.=' UNION '; $calc='';
}
else{
$calc='SQL_CALC_FOUND_ROWS ';
}
if ($user['group_kindindex']=="j"){
//$query.= "(SELECT ".$calc."*, CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name, pers_place_index as place_order
//FROM ".safe_text($_SESSION['tree_prefix'])."person";
$query.= "(SELECT ".$calc."*, CONCAT(pers_prefix,pers_lastname,pers_firstname) as concat_name, pers_place_index as place_order
FROM humo_persons WHERE pers_tree_id='".$tree_id."'";
}
else{
//$query.= "(SELECT ".$calc."*, pers_place_index as place_order FROM ".safe_text($_SESSION['tree_prefix'])."person";
$query.= "(SELECT ".$calc."*, pers_place_index as place_order
FROM humo_persons WHERE pers_tree_id='".$tree_id."'";
}
if($place_name) {
//$query.= " WHERE pers_place_index ".name_qry($place_name,$part_place_name);
$query.= " AND pers_place_index ".name_qry($place_name,$part_place_name);
}
else {
//$query .= " WHERE pers_place_index LIKE '_%'";