-
Notifications
You must be signed in to change notification settings - Fork 0
/
editEvent.php
2110 lines (1960 loc) · 86.9 KB
/
editEvent.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
namespace Genealogy;
use \PDO;
use \Exception;
use \Templating\Template;
/************************************************************************
* editEvent.php *
* *
* Display a web page for editting one event from the family tree *
* database which is represented by an instance of Event. *
* *
* Parameters (passed by method="get"): *
* type numeric type value as used by the Citation *
* record to identify a specific event and which *
* record type it is defined in. If omitted the default *
* value is 0. *
* *
* idir parameter must point to Person record *
* STYPE_NAME = 1 *
* STYPE_BIRTH = 2 *
* STYPE_CHRISTEN = 3 *
* STYPE_DEATH = 4 *
* STYPE_BURIED = 5 *
* STYPE_NOTESGENERAL = 6 *
* STYPE_NOTESRESEARCH = 7 *
* STYPE_NOTESMEDICAL = 8 *
* STYPE_DEATHCAUSE = 9 *
* STYPE_LDSB = 15 LDS Baptism *
* STYPE_LDSE = 16 LDS Endowment *
* STYPE_LDSC = 26 LDS Confirmation *
* STYPE_LDSI = 27 LDS Initiatory *
* *
* idnx parameter points to Alternate Name Record tblNX *
* STYPE_ALTNAME = 10 *
* *
* idcr parameter points to Child Record tblCR *
* STYPE_CHILDSTATUS = 11 Child Status *
* STYPE_CPRELDAD = 12 Relationship to Father *
* STYPE_CPRELMOM = 13 Relationship to Mother *
* STYPE_LDSP = 17 Sealed to Parents *
* *
* idmr parameter points to LegacyMarriage Record *
* STYPE_LDSS = 18 Sealed to Spouse *
* STYPE_NEVERMARRIED = 19 This individual nvr married*
* STYPE_MAR = 20 Marriage *
* STYPE_MARNOTE = 21 Marriage Note *
* STYPE_MARNEVER = 22 Never Married *
* STYPE_MARNOKIDS = 23 This couple had no children*
* STYPE_MAREND = 24 marriage ended **added** *
* *
* ider parameter points to Event Record *
* STYPE_EVENT = 30 Individual Event, *
* idir mandatory *
* STYPE_MAREVENT = 31 Marriage Event, *
* idmr mandatory *
* *
* idtd parameter points to To-Do records tblTD.IDTD *
* STYPE_TODO = 40 To-Do Item *
* *
* a temp source type, also any negative numbers are temporary *
* STYPE_TEMP = 100 used to swap sources. *
* *
* idir unique numeric key of instance of Person *
* required as defined above or *
* ider unique numeric key of instance of Event *
* if set to zero with type=STYPE_EVENT or STYPE_MAREVENT *
* causes new Event record to be created. *
* idnx unique numeric key of instance of Alternate Name *
* Record tblNX *
* idcr unique numeric key of instance of Child Record tblCR *
* idmr unique numeric key of instance of LegacyMarriage Record *
* idtd unique numeric key of instance of To-Do records *
* tblTD.IDTD *
* *
* givenname optionally explicitly supply given name of individual *
* if DB copy may not be current *
* surname optionally explicitly supply surname of individual *
* if DB copy may not be current *
* date optionally explicitly supply date of event if DB copy *
* may not be current *
* descn optionally explicitly supply description of event if *
* DB copy may not be current *
* location optionally explicitly supply location of event if DB *
* copy may not be current *
* notes optionally explicitly supply notes for event if DB *
* copy may not be current *
* rownum feedback row number for common event *
* *
* History: *
* 2010/08/08 set $ider for newly created Event *
* 2010/08/09 add input field for Order value *
* 2010/08/11 use htmlspecialchars to escape text values *
* 2010/08/16 change to LegacyCitationList interface *
* 2010/08/21 Change to use new page format *
* 2010/08/28 implement delete citation *
* 2010/09/05 Permit explictly supplying name of individual *
* 2010/10/11 Simplify interface for adding citations *
* 2010/10/15 Use cookies to default to last source citation *
* Remove header and trailer sections from dialog. *
* Support all event types, not just Event *
* 2010/10/16 Use Event->getNotes() *
* 2010/10/17 Import citTable.inc and citTable.js to manage *
* citations *
* 2010/10/19 Ensure $notes is not null for NAME event *
* 2010/10/23 move connection establishment to common.inc *
* 2010/10/29 move Notes after Location in dialog *
* 2010/11/04 generate common HTML header tailored to browser *
* 2010/11/14 include prefix and title in fields for Name *
* event *
* 2010/12/04 add link to help page *
* 2010/12/12 replace LegacyDate::dateToString with *
* LegacyDate::toString *
* 2010/12/20 handle exception thrown by new LegacyIndiv *
* handle exception thrown by new LegacyFamily *
* handle exception thrown by new LegacyLocation *
* improved handling of invalid parameters *
* 2011/01/02 add 4 LDS sacraments *
* 2011/01/10 use LegacyRecord::getField method *
* 2011/01/22 clean up code *
* 2011/01/30 identify fact type in title of facts from *
* indiv record *
* 2011/02/24 identify fact type in context specific help *
* for notes *
* 2011/03/03 underline 'U' in "Update Event" button text *
* 2011/06/15 pass idmr to updateEvent.php *
* support events in LegacyFamily record *
* 2011/07/29 handle new parameters date and location to *
* supply explicit values of date and location *
* of event *
* Use LegacyLocation constructor to resolve *
* short names *
* 2011/08/08 trim supplied location name *
* 2011/08/21 do not initially display Temple vs. Live kind *
* row for generic event. *
* 2011/10/01 provide database lookup assist for setting *
* location names *
* document month name abbreviations in context *
* help *
* change name of class LegacyCitationList *
* 2011/11/19 display alternate names in the Name Event and *
* provide a button to selectively delete an *
* alternate name *
* 2011/12/23 always display married surnames *
* display all events in dialog and permit adding, *
* modifying, and deleting events. *
* add help panels for all fields *
* 2012/01/08 reorder to put the event type before the date *
* 2012/01/13 change class names *
* support supplying notes value through parm *
* include <input type=checkbox> in flag events *
* add "No Children" to list of marriage events *
* 2012/01/23 display loading indicator while waiting for *
* response to changed in a location field *
* 2012/02/25 use tinyMCE for stylized editing of text notes *
* 2012/05/06 set explicit class for Order field *
* 2012/07/31 make names of individuals identified in the *
* title of the event hyperlinks to the individual *
* record *
* add names of spouses to all marriage events *
* expand date input field to display 24 characters*
* 2012/08/01 permit invoker to explicitly override *
* description field *
* 2012/08/12 support LDS sealed to parents event *
* validate associated record for all events *
* before using it *
* permit setting temple ready indicator *
* 2012/10/17 do not attempt to create database objects if *
* the numeric key is invalid *
* 2012/10/19 supplied given name and surname was not used *
* by name event *
* 2012/10/30 ensure templeReady field default to unused *
* 2012/11/05 add support for tinyMCE editing of notes *
* 2012/11/22 Event::add removed and replaced by member *
* method addEvent of LegacyIndiv and LegacyFamily *
* 2013/03/03 LegacyIndiv::getNextName now returns all *
* alternate names *
* 2013/04/02 add support for citations for alternate names *
* 2013/04/24 add birth, marriage, and death registrations *
* 2013/05/26 use dialog in place of alert for new location *
* name *
* 2013/07/04 for individual event recorded in instance of *
* Event do not display event types recorded *
* in other records. This permits changing the *
* event type without creating a new record *
* 2013/08/25 add clear button for note textarea *
* 2013/12/07 $msg and $debug initialized by common.inc *
* 2014/02/08 standardize appearance of <select> *
* 2014/02/12 replace tables with CSS for layout *
* 2014/02/17 define local CSS for this form *
* 2014/02/19 add id to <form> *
* 2014/02/24 use dialog to choose from range of locations *
* instead of inserting <select> into the form *
* location support moved to locationCommon.js *
* 2014/03/06 label class name changed to column1 *
* 2014/03/10 ability to edit cause of death added to *
* edit dialogue for normal death event so it *
* can be removed from the edit Individual dialog *
* 2014/03/20 replace deprecated LegacyIndiv::getNumNames *
* replace deprecated LegacyIndiv::getNextName *
* wrap alternate name section of Name event in *
* a fieldset for clarity *
* wrap death cause section of Death event in *
* a fieldset for clarity *
* deprecated class LegacyCitationList replaced by *
* calls to Citation::getCitations *
* 2014/04/08 LegacyAltName renamed to LegacyName *
* management of citations to alternate names *
* moved to EditName.php script *
* 2014/04/13 permit being invoked with just the IDER value *
* 2014/04/15 Display default citation while waiting for *
* database server to respond to request for list *
* of sources *
* enable update of citation page number *
* 2014/04/26 formUtil.inc obsoleted *
* 2014/04/30 refine headings for marriage events *
* 2014/05/30 use explicit style class actleftcit in *
* template for new source citation to limit *
* the width of the selection list to match the *
* width of the display after the citation added *
* 2014/07/06 move textual interpretation of IDET here from *
* Event class to support I18N *
* 2014/07/15 support for popupAlert moved to common code *
* 2014/09/27 RecOwners class renamed to RecOwner *
* use Record method isOwner to check ownership *
* use LegacyTemple::getTemples to get list for *
* <select> *
* 2014/10/01 add delete confirmation dialog *
* 2014/10/03 add support for associating instances of *
* Picture with an event. *
* 2014/10/15 events moved out of tblIR into tblER *
* 2014/11/19 provide alternative occupation input row *
* 2014/11/20 bad generated name for <input name="IDSR..."> *
* 2014/11/27 use Event::getCitations *
* 2014/11/29 do not crash on new location *
* 2014/11/29 print $warn, which may contain debug trace *
* 2014/12/04 global $debug not declared in function *
* getDateAndLocation *
* 2014/12/12 missing parameter to LegacyTemple::getTemples *
* 2014/12/25 redirect debugging output to $warn *
* 2014/12/26 add rownum feedback parameter *
* 2015/03/07 use LegacyFamily::getHusbName and getWifeName *
* instead of deprecated name fields *
* 2015/03/14 include Close button if errors *
* 2015/05/15 do not escape HTML tags in textarea, they are *
* used by rich text editor *
* 2015/06/14 match field sizes in new citation to existing *
* 2015/07/02 access PHP includes using include_path *
* 2016/01/19 add id to debug trace *
* display notes in a larger area *
* 2016/02/05 one trace message was printed instead of saved *
* 2016/02/06 use showTrace *
* 2017/01/03 undefined $checked *
* 2017/01/23 do not use htmlspecchars to build input values *
* 2017/03/19 use preferred parameters for new LegacyIndiv *
* use preferred parameters for new LegacyFamily *
* 2017/07/23 class LegacyPicture renamed to class Picture *
* 2017/07/27 class LegacyCitation renamed to class Citation *
* 2017/08/08 class LegacyChild renamed to class Child *
* 2017/08/15 class LegacyToDo renamed to class ToDo *
* 2017/09/12 use get( and set( *
* 2017/09/23 add a "Choose a Temple" option to temple select *
* 2017/09/28 change class LegacyEvent to class Event *
* 2017/10/13 class LegacyIndiv renamed to class Person *
* 2017/11/18 use RecordSet instead of Temple::getTemples *
* 2017/11/19 use CitationSet in place of getCitations *
* 2018/02/11 add Close button *
* 2018/03/24 add button to control whether textareas are *
* displayed as rich text or raw text *
* 2018/11/19 change Help.html to Helpen.html *
* 2019/08/01 support tinyMCE 5.0.3 *
* 2019/08/06 use editName.php to handle updates of Names *
* 2020/03/13 use FtTemplate::validateLang *
* 2020/12/05 correct XSS vulnerabilities *
* 2022/04/16 use all of FtTemplate *
* 2022/05/16 default IDET to Event::ET_UNDEF *
* *
* Copyright © 2022 James A. Cobban *
************************************************************************/
require_once __NAMESPACE__ . '/Event.inc';
require_once __NAMESPACE__ . '/Person.inc';
require_once __NAMESPACE__ . '/Family.inc';
require_once __NAMESPACE__ . '/Citation.inc';
require_once __NAMESPACE__ . '/CitationSet.inc';
require_once __NAMESPACE__ . '/Name.inc';
require_once __NAMESPACE__ . '/Picture.inc';
require_once __NAMESPACE__ . '/ToDo.inc';
require_once __NAMESPACE__ . '/FtTemplate.inc';
require_once __NAMESPACE__ . '/common.inc';
/************************************************************************
* function getEventType *
* *
* Get the type of the event as descriptive text. *
* *
* Input: *
* $event instance of class Event *
* *
* Returns: *
* String description of event type *
************************************************************************/
function getEventType($event)
{
global $translate;
$idet = $event['idet'];
$result = $translate['eventText'][$idet];
if (is_null($result))
return "IDET=$idet";
else
return $result;
} // getEventType
/************************************************************************
* function getDateAndLocation *
* *
* If the values for date and location have been explicitly *
* provided, use them. Otherwise obtain the values from the *
* associated database record. *
* *
* Parameters: *
* $record data base record as instance of Record *
* $dateFldName field name containing date of event *
* $locFldName field name containing IDLR of location *
* of event *
************************************************************************/
function getDateAndLocation($record,
$dateFldName,
$locFldName)
{
global $debug;
global $warn;
global $date;
global $location; // instance of Location
global $msg;
global $idlr;
if (is_null($date))
{ // date value not explicitly supplied
$date = new LegacyDate($record->get($dateFldName));
$date = $date->toString();
} // date value not explicitly supplied
if (is_null($location))
{ // location value not explicitly supplied
$idlr = $record->get($locFldName);
if ($debug)
$warn .= "<p>\$idlr set to $idlr from field name '$locFldName'</p>\n";
$location = new Location(array('idlr' => $idlr));
} // location value not explicitly supplied
} // function getDateAndLocation
/************************************************************************
* function getDateAndLocationLds *
* *
* If the values for date and location have been explicitly *
* provided, use them. Otherwise obtain the values from the *
* associated database record. *
* *
* Parameters: *
* $record data base record as instance of Record *
* $kind temple indicator *
* $dateFldName field name containing date of event *
* $locFldName field name containing IDLR of location *
* of event *
************************************************************************/
function getDateAndLocationLds($record,
$kind,
$dateFldName,
$locFldName)
{
global $date;
global $location;
global $msg;
global $idtr;
if (is_null($date))
{ // date value not explicitly supplied
$date = new LegacyDate($record->get($dateFldName));
$date = $date->toString();
} // date value not explicitly supplied
$idtr = $record->get($locFldName);
if ($kind == 1)
$location = new Temple(array('idtr' => $idtr));
else
{ // not in temple
if (is_null($location))
{ // do not have explicit location
$location = Location::getLocation($idtr);
} // do not have explicit location
} // not in temple
} // function getDateAndLocationLds
/************************************************************************
* function getEventInfo *
* *
* Get information from an instance of Event *
* *
* Parameters: *
* $event instance of Event *
************************************************************************/
function getEventInfo($event)
{
global $etype;
global $idet;
global $order;
global $notes;
global $descn;
global $kind;
global $templeReady;
global $preferred;
$etype = getEventType($event);
if ($idet <= 1)
$idet = $event['idet']; // numeric key of tblET
$order = $event['order'];
if (is_null($notes))
{
$notes = $event['desc'];
if (is_null($notes))
$notes = '';
}
if (is_null($descn))
$descn = $event['description'];
$templeReady = $event['ldstempleready'];
$preferred = $event['preferred'];
$kind = $event['kind'];
if ($kind == 0)
getDateAndLocation($event,
'eventd',
'idlrevent');
else
getDateAndLocationLds($event,
$kind,
'eventd',
'idlrevent');
} // function getEventInfo
/************************************************************************
* OO PPP EEEE N N CC OO DDD EEEE *
* O O P P E NN N C C O O D D E *
* O O PPP EEE N NN C O O D D EEE *
* O O P E N NN C C O O D D E *
* OO P EEEE N N CC OO DDD EEEE *
************************************************************************/
// default title
$title = 'Edit Event Error';
// safely get parameter values
// defaults
// parameter values from URI
$stype = 0; // see Citation::STYPE_...
$ider = null; // index of Event
$idet = null; // index of EventType
$idir = null; // index of Person
$idnx = null; // index of Name
$idcr = null; // index of Child
$idmr = null; // index of Family
$idtd = null; // index of ToDo
$typetext = null; // error text for event type
$idertext = null; // error text for key of Event
$idettext = null; // error text for key of EventType
$idirtext = null; // error text for key of Person
$idnxtext = null; // error text for key of Name
$idcrtext = null; // error text for key of Child
$idmrtext = null; // error text for key of Family
$idtdtext = null; // error text for key of ToDo
$idtrtext = null; // error text for key of Temple
$date = null;
$descn = null;
$location = null;
$notes = null;
$notmar = null;
$nokids = null;
$cremated = null;
$deathCause = null;
$picIdType = null; // for invoking EditPictures dialog
$given = '';
$surname = '';
$rownum = null;
$lang = 'en';
$etype = null;
$order = null;
$idlr = null;
$idlrtext = null;
$kind = null;
$kindtext = null;
$prefix = null;
$nametitle = null;
$templeReady = null;
$preferred = null;
$typeText = null;
// database records
$event = null; // instance of Event
$person = null; // instance of Person
$family = null; // instance of Family
$child = null; // instance of Child
$altname = null; // instance of Name
$todo = null; // instance of ToDo
// other
$readonly = ''; // attribute value to insert in <input>
$submit = false;
// process input parameters from the search string passed by method=get
if (isset($_GET) && count($_GET) > 0)
{ // invoked by method=get
$parmsText = "<p class='label'>\$_GET</p>\n" .
"<table class='summary'>\n" .
"<tr><th class='colhead'>key</th>\n" .
"<th class='colhead'>value</th></tr>\n";
foreach($_GET as $key => $value)
{
$safevalue = htmlspecialchars($value);
$parmsText .= "<tr>\n<th class='detlabel'>$key</th>" .
"<td class='white left'>\n" .
"$safevalue</td>\n</tr>\n";
$value = trim($value);
switch(strtolower($key))
{
case 'type':
{ // supplied event type
if (ctype_digit($value))
{
$stype = intval($value);
if ($stype == 0)
$readonly = "readonly='readonly'";
// textual description of event type
if (isset($citText[$stype]))
$eventType = $citText[$stype];
else
$eventType = 'Invalid event type ' . $stype;
}
else
$typetext = $safevalue;
break;
} // supplied event type
// get the event record identifier if present
case 'ider':
{
if (ctype_digit($value))
$ider = intval($value);
else
$idertext = $safevalue;
break;
} // ider
// get the event type identifier if present
case 'idet':
{
if (ctype_digit($value))
$idet = intval($value);
else
$idettext = $safevalue;
break;
} // idet
// get the key of instance of Person
case 'idir':
{
if (ctype_digit($value))
$idir = intval($value);
else
$idirtext = $safevalue;
break;
} // idir
case 'idnx':
{ // get the key of instance of Alternate Name Record tblNX
if (ctype_digit($value))
$idnx = intval($value);
else
$idnxtext = $safevalue;
break;
} //idnx
case 'idcr':
{ // key of instance of Child Record tblCR
if (ctype_digit($value))
{
$idcr = intval($value);
$kind = 0;
}
else
$idcrtext = $safevalue;
break;
} //idcr
case 'idmr':
{ // key of instance of Marriage Record
if (ctype_digit($value))
$idmr = intval($value);
else
$idmrtext = $safevalue;
break;
} //idmr
case 'idtd':
{ // key of instance of To-Do records tblTD.IDTD
if (ctype_digit($value))
$idtd = intval($value);
else
$idtdtext = $safevalue;
break;
} // idtd
// individual's name can be explicitly supplied for events
// associated with
// a new individual if that information is not available from the
// database record because it has not been written yet
case 'givenname':
{
$given = $safevalue;
break;
} // given name
case 'surname':
{ // surname
$surname = $safevalue;
break;
} // surname
// the date, location, and notes field values in the DB record may
// not be current as a result of user activity
case 'date':
{ // date of event as an external string
$date = $safevalue;
break;
} // date
case 'descn':
{ // description of the event
$descn = $safevalue;
break;
} // descn
case 'location':
{ // location of the event
$location = $safevalue;
break;
} // location
case 'idtr':
{ // key of temple
if (ctype_digit($value))
$idtr = $value;
else
$idtrtext = $safevalue;
break;
} // key of temple
case 'kind':
{ // key of temple
if (ctype_digit($value) && $value < 2)
$kind = $value;
else
$kindtext = $safevalue;
break;
} // key of temple
case 'rownum':
{ // rownum for feedback about the event
$rownum = $safevalue;
break;
} // rownum for feedback about the event
case 'notes':
{ // notes about the event
$notes = $safevalue;
break;
} // notes about the event
case 'submit':
{ // control whether uses AJAX or submit
if (strtoupper($value) == 'Y')
$submit = true;
break;
} // control whether uses AJAX or submit
case 'debug':
{ // debug handled by common code
break;
} // debug
case 'lang':
{
$lang = FtTemplate::validateLang($value);
break;
}
case 'text':
case 'editnotes':
{
break;
} // used by Javascript
default:
{ // other parameters
$warn .= "<p>Unexpected parameter $key='$safevalue'</p>\n";
break;
} // other parameters
} // switch
} // loop through all parameters
if ($debug)
$warn .= $parmsText . "</table>\n";
} // invoked by method=get
// set default citation type if only IDET and record key specified
if (is_int($idet) && $stype == 0)
{
if (!is_null($idcr))
$stype = Citation::STYPE_CHILDEVENT;
else
if (!is_null($idmr))
$stype = Citation::STYPE_MAREVENT;
else
$stype = Citation::STYPE_EVENT;
}
if (canUser('edit'))
$action = 'Update';
else
$action = 'Display';
// get template
$template = new FtTemplate("editEvent$action$lang.html",
true);
$translate = $template->getTranslate();
$t = $translate['tranTab'];
$citText = $translate['typeText']; // citation text
$template->includeSub('LocationDialogsen.html',
'LOCATIONDIALOGS');
$template->includeSub('TempleDialogsen.html',
'TEMPLEDIALOGS');
// issue parameter syntax error messages
$msgtext = $template['invalidParmValue']->innerHTML;
if (is_string($typetext))
$msg .= str_replace(array('$parm','$value'),
array('Type',$typetext),
$msgtext);
if (is_string($idertext))
$msg .= str_replace(array('$parm','$value'),
array('IDER', $idertext),
$msgtext);
if (is_string($idettext))
$msg .= str_replace(array('$parm','$value'),
array('IDET', $idettext),
$msgtext);
if (is_string($idirtext))
$msg .= str_replace(array('$parm','$value'),
array('IDIR', $idirtext),
$msgtext);
if (is_string($idnxtext))
$msg .= str_replace(array('$parm','$value'),
array('IDNX', $idnxtext),
$msgtext);
if (is_string($idcrtext))
$msg .= str_replace(array('$parm','$value'),
array('IDCR', $idcrtext),
$msgtext);
if (is_string($idmrtext))
$msg .= str_replace(array('$parm','$value'),
array('IDMR', $idmrtext),
$msgtext);
if (is_string($idtrtext))
$msg .= str_replace(array('$parm','$value'),
array('IDTR', $idtrtext),
$msgtext);
if (is_string($idtdtext))
$msg .= str_replace(array('$parm','$value'),
array('IDTD', $idtdtext),
$msgtext);
if (is_string($kindtext))
$msg .= str_replace(array('$parm','$value'),
array('kind', $kindtext),
$msgtext);
// create Event based upon IDER parameter
if (!is_null($ider) && $ider > 0)
{ // existing event
$event = new Event(array('ider' => $ider));
if ($event->isExisting())
{
$idet = $event['idet'];
$idtype = $event['idtype'];
switch($idtype)
{ // get associated record
case Event::IDTYPE_INDIV: // Person
$idir = $event['idir'];
$stype = Citation::STYPE_EVENT;
break;
case Event::IDTYPE_MAR: // Family
$idmr = $event['idir'];
$stype = Citation::STYPE_MAREVENT;
break;
case Event::IDTYPE_CHILD: // Child
$idcr = $event['idir'];
$stype = 32;
break;
} // get associated record
}
else
{ // new Event failed
$event = null;
$msg .= "No existing event has IDER=$ider. ";
} // new Event failed
} // existing event
else
{ // request to create new event
$event = null; // is done later
if ($stype == 0)
{
if (!is_null($idir))
{ // individual event
$stype = Citation::STYPE_EVENT;
} // individual event
else
if (!is_null($idmr))
{ // marriage event
$stype = Citation::STYPE_MAREVENT;
$idet = Event::ET_MARRIAGE;
} // married event
else
if (!is_null($idtd))
{ // to do event
$stype = Citation::STYPE_TODO;
} // to do event
else
if (!is_null($idnx))
{ // name event
$stype = Citation::STYPE_ALTNAME;
} // name event
}
} // request to create new event
// create Name record based upon IDNX keyword
if ($idnx > 0)
{ // IDNX was specified in parameters
$altname = new Name(array('idnx' => $idnx));
if ($altname->isExisting())
header("Location: /FamilyTree/editName.php?idnx=$idnx");
else
{ // no matching Name
$altname = null;
$msg .= "Invalid name identification IDNX=$idnx. ";
$typeText = $t['Name'];
if ($typeText == null)
$typeText = 'Name';
} // no matching Name
} // IDNX was specified in parameters
// create Child record based upon IDCR keyword
if ($idcr > 0)
{ // IDCR was specified in parameters
$child = new Child(array('idcr' => $idcr));
if ($child->isExisting())
{ // have matching Child
$idir = $child['idir'];
$person = new Person(array('idir' => $idir));
$isOwner = canUser('edit') && $person->isOwner();
if (!$isOwner)
$msg .=
'You are not authorized to edit the events of this child. ';
$idmr = $child['idmr'];
$family = new Family(array('idmr' => $idmr));
} // have matching Child
else
{ // no matching Child
$child = null;
$msg .= "Invalid child identification IDCR=$idcr. ";
$idcr = null;
} // no matching Child
} // IDCR was specified in parameters
// get the associated individual record
if ($idir > 0)
{ // IDIR was specified in parameters
$person = new Person(array('idir' => $idir));
if ($person->isExisting())
{
$isOwner = canUser('edit') && $person->isOwner();
if (!$isOwner)
$msg .= 'You are not authorized to edit the events of this individual. ';
// if name of individual not supplied,
// get it from Person record
if (strlen($given) == 0)
$given = $person->getGivenname();
if (strlen($surname) == 0)
$surname = $person->getSurname();
$title = "Edit Event for $given $surname";
} // try creating instance of Person
else
{ // error creating individual
$person = null;
$idime = -1;
$given = '';
$surname = $t['Unknown'];
$msg .= "Invalid Value of IDIR=$idir. ";
$idir = null;
} // error creating individual
} // IDIR was specified in parameters
// get the To-Do record, under construction
if ($idtd > 0)
{ // IDTD was specified in parameters
$todo = new ToDo(array('idtd' => $idtd));
if ($todo->isExisting())
{
}
else
{ // no match
$todo = null;
$msg .= "Invalid To Do identification idtd=$idtd. ";
} // no match
} // IDTD was specified in parameters
// create Family record based upon IDMR keyword
if ($idmr > 0)
{ // IDMR was specified in parameters
$family = new Family(array('idmr' => $idmr));
if ($family->isExisting())
{
$husbname = $family->getHusbName();
$idirhusb = $family['idirhusb'];
$wifename = $family->getWifeName();
$idirwife = $family['idirwife'];
} // existing Family record
else
{ // invalid IDMR value
$husbname = $t['Unknown'];
$idirhusb = 0;
$wifename = $t['Unknown'];
$idirwife = 0;
$msg .= "Invalid family identification idmr=$idmr. ";
} // invalid IDMR value
} // IDMR was specified in parameters
$forText = '';
if (strlen($msg) == 0)
{
// validate the presence of parameters depending upon
// the value of the type parameter
// identify the fields in the associated record that are
// updated for each type of event
// default that all fields are unsupported
if ($ider === 0)
{ // create new Event
if (is_null($idet))
$idet = Event::ET_UNDEF;
$event = new Event(array('ider' => 0,
'idet' => $idet,
'idir' => $idir));
} // create new Event
// determine portion of page heading that describes the record
// referenced by the event
if ((ctype_digit($idir) || is_int($idir)) && $idir > 0)
{ // IDIR based event
$forText =
"<a href=\"Person.php?idir=$idir\">$given $surname</a>";
} // IDIR based event
else
if ((ctype_digit($idmr) || is_int($idmr)) && $idmr > 0)
{ // IDMR based event
if ($idirhusb)
{
$forText =
"<a href=\"Person.php?idir=$idirhusb&lang=$lang\" class=\"male\">\n" .
" $husbname</a> ";
if ($idirwife)
$forText .= $t['and'];
}
if ($idirwife)
$forText .=
"<a href=\"Person.php?idir=$idirwife&lang=$lang\" class=\"female\">\n" .
" $wifename</a>";
}
else
if (ctype_digit($idtd) || is_int($idtd))
$forText = "<a href=\"ToDo.php?idtd=$idtd&lang=$lang\">IDTD=$idtd</a>";
else
$forText = '';
// take action which depends upon the Citation type
switch($stype)