@@ -68,7 +68,7 @@ |
||
68 | 68 | */ |
69 | 69 | public function updateRecord(GedcomRecord $record): string { |
70 | 70 | $old_gedcom = $record->getGedcom(); |
71 | - $tree = $record->getTree(); |
|
71 | + $tree = $record->getTree(); |
|
72 | 72 | |
73 | 73 | $SURNAME_TRADITION = $tree->getPreference('SURNAME_TRADITION'); |
74 | 74 |
@@ -173,7 +173,7 @@ |
||
173 | 173 | /** @var Tree $tree */ |
174 | 174 | $tree = $request->attributes->get('tree'); |
175 | 175 | |
176 | - $q = $request->get('q'); |
|
176 | + $q = $request->get('q'); |
|
177 | 177 | $instance = $request->get('instance'); |
178 | 178 | $treeview = new TreeView($instance); |
179 | 179 |
@@ -158,7 +158,7 @@ |
||
158 | 158 | DebugBar::addThrowable($ex); |
159 | 159 | |
160 | 160 | // The module has been deleted or is broken? Disable it. |
161 | - Log::addConfigurationLog("Module {$module_name} is missing or broken - disabling it. " . $ex->getMessage(), null); |
|
161 | + Log::addConfigurationLog("module {$module_name} is missing or broken - disabling it. " . $ex->getMessage(), null); |
|
162 | 162 | Database::prepare( |
163 | 163 | "UPDATE `##module` SET status = 'disabled' WHERE module_name = :module_name" |
164 | 164 | )->execute([ |
@@ -30,48 +30,48 @@ discard block |
||
30 | 30 | $controller = new PageController; |
31 | 31 | |
32 | 32 | switch ($action) { |
33 | -case 'edit': |
|
34 | - ////////////////////////////////////////////////////////////////////////////// |
|
35 | - // Edit a fact |
|
36 | - ////////////////////////////////////////////////////////////////////////////// |
|
37 | - $tree = $controller->tree(); |
|
38 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
39 | - $fact_id = Filter::get('fact_id'); |
|
40 | - |
|
41 | - $record = GedcomRecord::getInstance($xref, $tree); |
|
42 | - check_record_access($record); |
|
43 | - |
|
44 | - // Find the fact to edit |
|
45 | - $edit_fact = null; |
|
46 | - foreach ($record->getFacts() as $fact) { |
|
47 | - if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
48 | - $edit_fact = $fact; |
|
33 | + case 'edit': |
|
34 | + ////////////////////////////////////////////////////////////////////////////// |
|
35 | + // Edit a fact |
|
36 | + ////////////////////////////////////////////////////////////////////////////// |
|
37 | + $tree = $controller->tree(); |
|
38 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
39 | + $fact_id = Filter::get('fact_id'); |
|
40 | + |
|
41 | + $record = GedcomRecord::getInstance($xref, $tree); |
|
42 | + check_record_access($record); |
|
43 | + |
|
44 | + // Find the fact to edit |
|
45 | + $edit_fact = null; |
|
46 | + foreach ($record->getFacts() as $fact) { |
|
47 | + if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
48 | + $edit_fact = $fact; |
|
49 | + break; |
|
50 | + } |
|
51 | + } |
|
52 | + if (!$edit_fact) { |
|
53 | + header('Location: ' . $record->url()); |
|
49 | 54 | break; |
50 | 55 | } |
51 | - } |
|
52 | - if (!$edit_fact) { |
|
53 | - header('Location: ' . $record->url()); |
|
54 | - break; |
|
55 | - } |
|
56 | 56 | |
57 | - $controller |
|
58 | - ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($edit_fact->getTag())) |
|
59 | - ->pageHeader(); |
|
60 | - |
|
61 | - echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
62 | - FunctionsPrint::initializeCalendarPopup(); |
|
63 | - echo '<form name="editform" method="post" enctype="multipart/form-data">'; |
|
64 | - echo '<input type="hidden" name="ged" value="', e($tree->getName()), '">'; |
|
65 | - echo '<input type="hidden" name="action" value="update">'; |
|
66 | - echo '<input type="hidden" name="fact_id" value="', $fact_id, '">'; |
|
67 | - echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
68 | - echo '<input type="hidden" name="prev_action" value="edit">'; |
|
69 | - echo Filter::getCsrf(); |
|
70 | - FunctionsEdit::createEditForm($edit_fact); |
|
71 | - echo keep_chan($record); |
|
72 | - |
|
73 | - $level1type = $edit_fact->getTag(); |
|
74 | - switch ($record::RECORD_TYPE) { |
|
57 | + $controller |
|
58 | + ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($edit_fact->getTag())) |
|
59 | + ->pageHeader(); |
|
60 | + |
|
61 | + echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
62 | + FunctionsPrint::initializeCalendarPopup(); |
|
63 | + echo '<form name="editform" method="post" enctype="multipart/form-data">'; |
|
64 | + echo '<input type="hidden" name="ged" value="', e($tree->getName()), '">'; |
|
65 | + echo '<input type="hidden" name="action" value="update">'; |
|
66 | + echo '<input type="hidden" name="fact_id" value="', $fact_id, '">'; |
|
67 | + echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
68 | + echo '<input type="hidden" name="prev_action" value="edit">'; |
|
69 | + echo Filter::getCsrf(); |
|
70 | + FunctionsEdit::createEditForm($edit_fact); |
|
71 | + echo keep_chan($record); |
|
72 | + |
|
73 | + $level1type = $edit_fact->getTag(); |
|
74 | + switch ($record::RECORD_TYPE) { |
|
75 | 75 | case 'REPO': |
76 | 76 | // REPO:NAME facts may take a NOTE (but the REPO record may not). |
77 | 77 | if ($level1type === 'NAME') { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | default: |
129 | 129 | // Other types of record do not have these lower-level records |
130 | 130 | break; |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | 133 | ?> |
134 | 134 | <div class="row form-group"> |
@@ -157,527 +157,527 @@ discard block |
||
157 | 157 | echo view('modals/ajax'); |
158 | 158 | break; |
159 | 159 | |
160 | -case 'add': |
|
161 | - ////////////////////////////////////////////////////////////////////////////// |
|
162 | - // Add a new fact |
|
163 | - ////////////////////////////////////////////////////////////////////////////// |
|
164 | - $tree = $controller->tree(); |
|
165 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
166 | - $fact = Filter::get('fact', WT_REGEX_TAG); |
|
167 | - |
|
168 | - $record = GedcomRecord::getInstance($xref, $tree); |
|
169 | - check_record_access($record); |
|
170 | - |
|
171 | - $controller |
|
172 | - ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($fact, $record)) |
|
173 | - ->pageHeader(); |
|
174 | - |
|
175 | - $level0type = $record::RECORD_TYPE; |
|
176 | - |
|
177 | - echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
178 | - |
|
179 | - FunctionsPrint::initializeCalendarPopup(); |
|
180 | - echo '<form name="addform" method="post" enctype="multipart/form-data">'; |
|
181 | - echo '<input type="hidden" name="ged" value="', e($tree->getName()), '">'; |
|
182 | - echo '<input type="hidden" name="action" value="update">'; |
|
183 | - echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
184 | - echo '<input type="hidden" name="prev_action" value="add">'; |
|
185 | - echo '<input type="hidden" name="fact_type" value="' . $fact . '">'; |
|
186 | - echo Filter::getCsrf(); |
|
187 | - FunctionsEdit::createAddForm($tree, $fact); |
|
188 | - echo keep_chan($record); |
|
189 | - |
|
190 | - // Genealogical facts (e.g. for INDI and FAM records) can have 2 SOUR/NOTE/OBJE/ASSO/RESN ... |
|
191 | - if ($level0type === 'INDI' || $level0type === 'FAM') { |
|
192 | - // ... but not facts which are simply links to other records |
|
193 | - if ($fact !== 'OBJE' && $fact !== 'NOTE' && $fact !== 'SHARED_NOTE' && $fact !== 'REPO' && $fact !== 'SOUR' && $fact !== 'SUBM' && $fact !== 'ASSO' && $fact !== 'ALIA' && $fact !== 'SEX') { |
|
194 | - echo view('cards/add-source-citation', [ |
|
195 | - 'level' => 2, |
|
196 | - 'full_citations' => $tree->getPreference('FULL_SOURCES'), |
|
197 | - ]); |
|
198 | - if ($tree->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($tree)) { |
|
199 | - echo view('cards/add-media-object', [ |
|
200 | - 'level' => 2, |
|
201 | - ]); |
|
202 | - } |
|
203 | - // Don’t add notes to notes! |
|
204 | - if ($fact !== 'NOTE') { |
|
205 | - echo view('cards/add-note', [ |
|
206 | - 'level' => 2, |
|
160 | + case 'add': |
|
161 | + ////////////////////////////////////////////////////////////////////////////// |
|
162 | + // Add a new fact |
|
163 | + ////////////////////////////////////////////////////////////////////////////// |
|
164 | + $tree = $controller->tree(); |
|
165 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
166 | + $fact = Filter::get('fact', WT_REGEX_TAG); |
|
167 | + |
|
168 | + $record = GedcomRecord::getInstance($xref, $tree); |
|
169 | + check_record_access($record); |
|
170 | + |
|
171 | + $controller |
|
172 | + ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($fact, $record)) |
|
173 | + ->pageHeader(); |
|
174 | + |
|
175 | + $level0type = $record::RECORD_TYPE; |
|
176 | + |
|
177 | + echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
178 | + |
|
179 | + FunctionsPrint::initializeCalendarPopup(); |
|
180 | + echo '<form name="addform" method="post" enctype="multipart/form-data">'; |
|
181 | + echo '<input type="hidden" name="ged" value="', e($tree->getName()), '">'; |
|
182 | + echo '<input type="hidden" name="action" value="update">'; |
|
183 | + echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
184 | + echo '<input type="hidden" name="prev_action" value="add">'; |
|
185 | + echo '<input type="hidden" name="fact_type" value="' . $fact . '">'; |
|
186 | + echo Filter::getCsrf(); |
|
187 | + FunctionsEdit::createAddForm($tree, $fact); |
|
188 | + echo keep_chan($record); |
|
189 | + |
|
190 | + // Genealogical facts (e.g. for INDI and FAM records) can have 2 SOUR/NOTE/OBJE/ASSO/RESN ... |
|
191 | + if ($level0type === 'INDI' || $level0type === 'FAM') { |
|
192 | + // ... but not facts which are simply links to other records |
|
193 | + if ($fact !== 'OBJE' && $fact !== 'NOTE' && $fact !== 'SHARED_NOTE' && $fact !== 'REPO' && $fact !== 'SOUR' && $fact !== 'SUBM' && $fact !== 'ASSO' && $fact !== 'ALIA' && $fact !== 'SEX') { |
|
194 | + echo view('cards/add-source-citation', [ |
|
195 | + 'level' => 2, |
|
196 | + 'full_citations' => $tree->getPreference('FULL_SOURCES'), |
|
207 | 197 | ]); |
208 | - echo view('cards/add-shared-note', [ |
|
209 | - 'level' => 2, |
|
210 | - ]); |
|
211 | - } |
|
212 | - echo view('cards/add-associate', [ |
|
213 | - 'id' => Uuid::uuid4()->toString(), |
|
214 | - 'level' => 2, |
|
215 | - ]); |
|
216 | - // allow to add godfather and godmother for CHR fact or best man and bridesmaid for MARR fact in one window |
|
217 | - if (in_array($fact, Config::twoAssociates())) { |
|
198 | + if ($tree->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($tree)) { |
|
199 | + echo view('cards/add-media-object', [ |
|
200 | + 'level' => 2, |
|
201 | + ]); |
|
202 | + } |
|
203 | + // Don’t add notes to notes! |
|
204 | + if ($fact !== 'NOTE') { |
|
205 | + echo view('cards/add-note', [ |
|
206 | + 'level' => 2, |
|
207 | + ]); |
|
208 | + echo view('cards/add-shared-note', [ |
|
209 | + 'level' => 2, |
|
210 | + ]); |
|
211 | + } |
|
218 | 212 | echo view('cards/add-associate', [ |
219 | 213 | 'id' => Uuid::uuid4()->toString(), |
220 | 214 | 'level' => 2, |
221 | 215 | ]); |
216 | + // allow to add godfather and godmother for CHR fact or best man and bridesmaid for MARR fact in one window |
|
217 | + if (in_array($fact, Config::twoAssociates())) { |
|
218 | + echo view('cards/add-associate', [ |
|
219 | + 'id' => Uuid::uuid4()->toString(), |
|
220 | + 'level' => 2, |
|
221 | + ]); |
|
222 | + } |
|
223 | + echo view('cards/add-restriction', [ |
|
224 | + 'level' => 2, |
|
225 | + ]); |
|
222 | 226 | } |
223 | - echo view('cards/add-restriction', [ |
|
224 | - 'level' => 2, |
|
225 | - ]); |
|
226 | 227 | } |
227 | - } |
|
228 | - ?> |
|
228 | + ?> |
|
229 | 229 | <div class="row form-group"> |
230 | 230 | <div class="col-sm-9 offset-sm-3"> |
231 | 231 | <button class="btn btn-primary" type="submit"> |
232 | 232 | <?= FontAwesome::decorativeIcon('save') ?> |
233 | - <?= /* I18N: A button label. */ |
|
234 | - I18N::translate('save') ?> |
|
233 | + <?= /* I18N: A button label. */ |
|
234 | + I18N::translate('save') ?> |
|
235 | 235 | </button> |
236 | 236 | <a class="btn btn-secondary" href="<?= e($record->url()) ?>"> |
237 | 237 | <?= FontAwesome::decorativeIcon('cancel') ?> |
238 | - <?= /* I18N: A button label. */ |
|
239 | - I18N::translate('cancel') ?> |
|
238 | + <?= /* I18N: A button label. */ |
|
239 | + I18N::translate('cancel') ?> |
|
240 | 240 | </a> |
241 | 241 | </div> |
242 | 242 | </div> |
243 | 243 | </form> |
244 | 244 | <?php |
245 | - echo view('modals/on-screen-keyboard'); |
|
246 | - echo view('modals/ajax'); |
|
245 | + echo view('modals/on-screen-keyboard'); |
|
246 | + echo view('modals/ajax'); |
|
247 | 247 | |
248 | - break; |
|
248 | + break; |
|
249 | 249 | |
250 | -case 'update': |
|
251 | - ////////////////////////////////////////////////////////////////////////////// |
|
252 | - // Save a new/updated fact |
|
253 | - ////////////////////////////////////////////////////////////////////////////// |
|
254 | - $tree = $controller->tree(); |
|
255 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
256 | - $fact_id = Filter::post('fact_id'); |
|
257 | - $keep_chan = Filter::postBool('keep_chan'); |
|
258 | - |
|
259 | - $record = GedcomRecord::getInstance($xref, $tree); |
|
260 | - check_record_access($record); |
|
261 | - |
|
262 | - // Arrays for each GEDCOM line |
|
263 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
264 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
265 | - $text = Filter::postArray('text'); |
|
266 | - $islink = Filter::postArray('islink', '[01]'); |
|
267 | - |
|
268 | - // If the fact has a DATE or PLAC, then delete any value of Y |
|
269 | - if ($text[0] === 'Y') { |
|
270 | - foreach ($tag as $n => $value) { |
|
271 | - if ($glevels[$n] == 2 && ($value === 'DATE' || $value === 'PLAC') && $text[$n] !== '') { |
|
272 | - $text[0] = ''; |
|
273 | - break; |
|
250 | + case 'update': |
|
251 | + ////////////////////////////////////////////////////////////////////////////// |
|
252 | + // Save a new/updated fact |
|
253 | + ////////////////////////////////////////////////////////////////////////////// |
|
254 | + $tree = $controller->tree(); |
|
255 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
256 | + $fact_id = Filter::post('fact_id'); |
|
257 | + $keep_chan = Filter::postBool('keep_chan'); |
|
258 | + |
|
259 | + $record = GedcomRecord::getInstance($xref, $tree); |
|
260 | + check_record_access($record); |
|
261 | + |
|
262 | + // Arrays for each GEDCOM line |
|
263 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
264 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
265 | + $text = Filter::postArray('text'); |
|
266 | + $islink = Filter::postArray('islink', '[01]'); |
|
267 | + |
|
268 | + // If the fact has a DATE or PLAC, then delete any value of Y |
|
269 | + if ($text[0] === 'Y') { |
|
270 | + foreach ($tag as $n => $value) { |
|
271 | + if ($glevels[$n] == 2 && ($value === 'DATE' || $value === 'PLAC') && $text[$n] !== '') { |
|
272 | + $text[0] = ''; |
|
273 | + break; |
|
274 | + } |
|
274 | 275 | } |
275 | 276 | } |
276 | - } |
|
277 | 277 | |
278 | - $newged = ''; |
|
279 | - if (!empty($_POST['NAME'])) { |
|
280 | - $newged .= "\n1 NAME " . $_POST['NAME']; |
|
281 | - $name_facts = ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX']; |
|
282 | - foreach ($name_facts as $name_fact) { |
|
283 | - if (!empty($_POST[$name_fact])) { |
|
284 | - $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
278 | + $newged = ''; |
|
279 | + if (!empty($_POST['NAME'])) { |
|
280 | + $newged .= "\n1 NAME " . $_POST['NAME']; |
|
281 | + $name_facts = ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX']; |
|
282 | + foreach ($name_facts as $name_fact) { |
|
283 | + if (!empty($_POST[$name_fact])) { |
|
284 | + $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
285 | + } |
|
285 | 286 | } |
286 | 287 | } |
287 | - } |
|
288 | 288 | |
289 | - if (isset($_POST['NOTE'])) { |
|
290 | - $NOTE = $_POST['NOTE']; |
|
291 | - } |
|
292 | - if (!empty($NOTE)) { |
|
293 | - $tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end |
|
294 | - $title[] = '0 @' . $xref . '@ NOTE ' . array_shift($tempnote); |
|
295 | - foreach ($tempnote as &$line) { |
|
296 | - $line = trim('1 CONT ' . $line, ' '); |
|
289 | + if (isset($_POST['NOTE'])) { |
|
290 | + $NOTE = $_POST['NOTE']; |
|
291 | + } |
|
292 | + if (!empty($NOTE)) { |
|
293 | + $tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end |
|
294 | + $title[] = '0 @' . $xref . '@ NOTE ' . array_shift($tempnote); |
|
295 | + foreach ($tempnote as &$line) { |
|
296 | + $line = trim('1 CONT ' . $line, ' '); |
|
297 | + } |
|
297 | 298 | } |
298 | - } |
|
299 | 299 | |
300 | - $newged = FunctionsEdit::handleUpdates($newged); |
|
300 | + $newged = FunctionsEdit::handleUpdates($newged); |
|
301 | 301 | |
302 | - // Add new names after existing names |
|
303 | - if (!empty($_POST['NAME'])) { |
|
304 | - preg_match_all('/[_0-9A-Z]+/', $tree->getPreference('ADVANCED_NAME_FACTS'), $match); |
|
305 | - $name_facts = array_unique(array_merge(['_MARNM'], $match[0])); |
|
306 | - foreach ($name_facts as $name_fact) { |
|
307 | - // Ignore advanced facts that duplicate standard facts. |
|
308 | - if (!in_array($name_fact, ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX']) && !empty($_POST[$name_fact])) { |
|
309 | - $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
302 | + // Add new names after existing names |
|
303 | + if (!empty($_POST['NAME'])) { |
|
304 | + preg_match_all('/[_0-9A-Z]+/', $tree->getPreference('ADVANCED_NAME_FACTS'), $match); |
|
305 | + $name_facts = array_unique(array_merge(['_MARNM'], $match[0])); |
|
306 | + foreach ($name_facts as $name_fact) { |
|
307 | + // Ignore advanced facts that duplicate standard facts. |
|
308 | + if (!in_array($name_fact, ['TYPE', 'NPFX', 'GIVN', 'NICK', 'SPFX', 'SURN', 'NSFX']) && !empty($_POST[$name_fact])) { |
|
309 | + $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
310 | + } |
|
310 | 311 | } |
311 | 312 | } |
312 | - } |
|
313 | 313 | |
314 | - $newged = substr($newged, 1); // Remove leading newline |
|
314 | + $newged = substr($newged, 1); // Remove leading newline |
|
315 | 315 | |
316 | - /** @var CensusAssistantModule $census_assistant */ |
|
317 | - $census_assistant = Module::getModuleByName('GEDFact_assistant'); |
|
318 | - if ($census_assistant !== null && $record instanceof Individual) { |
|
319 | - $newged = $census_assistant->updateCensusAssistant($record, $fact_id, $newged, $keep_chan); |
|
320 | - } |
|
316 | + /** @var CensusAssistantModule $census_assistant */ |
|
317 | + $census_assistant = Module::getModuleByName('GEDFact_assistant'); |
|
318 | + if ($census_assistant !== null && $record instanceof Individual) { |
|
319 | + $newged = $census_assistant->updateCensusAssistant($record, $fact_id, $newged, $keep_chan); |
|
320 | + } |
|
321 | 321 | |
322 | - $record->updateFact($fact_id, $newged, !$keep_chan); |
|
322 | + $record->updateFact($fact_id, $newged, !$keep_chan); |
|
323 | 323 | |
324 | - // For the GEDFact_assistant module |
|
325 | - $pid_array = Filter::post('pid_array'); |
|
326 | - if ($pid_array) { |
|
327 | - foreach (explode(',', $pid_array) as $pid) { |
|
328 | - if ($pid !== $xref) { |
|
329 | - $indi = Individual::getInstance($pid, $tree); |
|
330 | - if ($indi && $indi->canEdit()) { |
|
331 | - $indi->updateFact($fact_id, $newged, !$keep_chan); |
|
324 | + // For the GEDFact_assistant module |
|
325 | + $pid_array = Filter::post('pid_array'); |
|
326 | + if ($pid_array) { |
|
327 | + foreach (explode(',', $pid_array) as $pid) { |
|
328 | + if ($pid !== $xref) { |
|
329 | + $indi = Individual::getInstance($pid, $tree); |
|
330 | + if ($indi && $indi->canEdit()) { |
|
331 | + $indi->updateFact($fact_id, $newged, !$keep_chan); |
|
332 | + } |
|
332 | 333 | } |
333 | 334 | } |
334 | 335 | } |
335 | - } |
|
336 | 336 | |
337 | - header('Location: ' . $record->url()); |
|
338 | - break; |
|
337 | + header('Location: ' . $record->url()); |
|
338 | + break; |
|
339 | 339 | |
340 | -case 'add_child_to_family_action': |
|
341 | - ////////////////////////////////////////////////////////////////////////////// |
|
342 | - // Add a child to an existing family |
|
343 | - ////////////////////////////////////////////////////////////////////////////// |
|
344 | - $tree = $controller->tree(); |
|
345 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
346 | - $PEDI = Filter::post('PEDI'); |
|
347 | - $keep_chan = Filter::postBool('keep_chan'); |
|
348 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
349 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
350 | - $text = Filter::postArray('text'); |
|
351 | - $islink = Filter::postArray('islink', '[01]'); |
|
352 | - |
|
353 | - $family = Family::getInstance($xref, $tree); |
|
354 | - check_record_access($family); |
|
355 | - |
|
356 | - FunctionsEdit::splitSource(); |
|
357 | - $gedrec = '0 @REF@ INDI'; |
|
358 | - $gedrec .= FunctionsEdit::addNewName($tree); |
|
359 | - $gedrec .= FunctionsEdit::addNewSex(); |
|
360 | - if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
361 | - foreach ($matches[1] as $match) { |
|
362 | - $gedrec .= FunctionsEdit::addNewFact($tree, $match); |
|
340 | + case 'add_child_to_family_action': |
|
341 | + ////////////////////////////////////////////////////////////////////////////// |
|
342 | + // Add a child to an existing family |
|
343 | + ////////////////////////////////////////////////////////////////////////////// |
|
344 | + $tree = $controller->tree(); |
|
345 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
346 | + $PEDI = Filter::post('PEDI'); |
|
347 | + $keep_chan = Filter::postBool('keep_chan'); |
|
348 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
349 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
350 | + $text = Filter::postArray('text'); |
|
351 | + $islink = Filter::postArray('islink', '[01]'); |
|
352 | + |
|
353 | + $family = Family::getInstance($xref, $tree); |
|
354 | + check_record_access($family); |
|
355 | + |
|
356 | + FunctionsEdit::splitSource(); |
|
357 | + $gedrec = '0 @REF@ INDI'; |
|
358 | + $gedrec .= FunctionsEdit::addNewName($tree); |
|
359 | + $gedrec .= FunctionsEdit::addNewSex(); |
|
360 | + if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
361 | + foreach ($matches[1] as $match) { |
|
362 | + $gedrec .= FunctionsEdit::addNewFact($tree, $match); |
|
363 | + } |
|
364 | + } |
|
365 | + $gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref); |
|
366 | + if (Filter::postBool('SOUR_INDI')) { |
|
367 | + $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
368 | + } else { |
|
369 | + $gedrec = FunctionsEdit::updateRest($gedrec); |
|
363 | 370 | } |
364 | - } |
|
365 | - $gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref); |
|
366 | - if (Filter::postBool('SOUR_INDI')) { |
|
367 | - $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
368 | - } else { |
|
369 | - $gedrec = FunctionsEdit::updateRest($gedrec); |
|
370 | - } |
|
371 | 371 | |
372 | - // Create the new child |
|
373 | - $new_child = $family->getTree()->createRecord($gedrec); |
|
374 | - |
|
375 | - // Insert new child at the right place |
|
376 | - $done = false; |
|
377 | - foreach ($family->getFacts('CHIL') as $fact) { |
|
378 | - $old_child = $fact->getTarget(); |
|
379 | - if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) { |
|
380 | - // Insert before this child |
|
381 | - $family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan); |
|
382 | - $done = true; |
|
383 | - break; |
|
372 | + // Create the new child |
|
373 | + $new_child = $family->getTree()->createRecord($gedrec); |
|
374 | + |
|
375 | + // Insert new child at the right place |
|
376 | + $done = false; |
|
377 | + foreach ($family->getFacts('CHIL') as $fact) { |
|
378 | + $old_child = $fact->getTarget(); |
|
379 | + if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) { |
|
380 | + // Insert before this child |
|
381 | + $family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan); |
|
382 | + $done = true; |
|
383 | + break; |
|
384 | + } |
|
385 | + } |
|
386 | + if (!$done) { |
|
387 | + // Append child at end |
|
388 | + $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
384 | 389 | } |
385 | - } |
|
386 | - if (!$done) { |
|
387 | - // Append child at end |
|
388 | - $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
389 | - } |
|
390 | 390 | |
391 | - if (Filter::post('goto') === 'new') { |
|
392 | - header('Location: ' . $new_child->url()); |
|
393 | - } else { |
|
394 | - header('Location: ' . $family->url()); |
|
395 | - } |
|
396 | - break; |
|
391 | + if (Filter::post('goto') === 'new') { |
|
392 | + header('Location: ' . $new_child->url()); |
|
393 | + } else { |
|
394 | + header('Location: ' . $family->url()); |
|
395 | + } |
|
396 | + break; |
|
397 | 397 | |
398 | -case 'add_child_to_individual_action': |
|
399 | - ////////////////////////////////////////////////////////////////////////////// |
|
400 | - // Add a child to an existing individual (creating a one-parent family) |
|
401 | - ////////////////////////////////////////////////////////////////////////////// |
|
402 | - $tree = $controller->tree(); |
|
403 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
404 | - $PEDI = Filter::post('PEDI'); |
|
405 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
406 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
407 | - $text = Filter::postArray('text'); |
|
408 | - $islink = Filter::postArray('islink', '[01]'); |
|
409 | - |
|
410 | - $person = Individual::getInstance($xref, $tree); |
|
411 | - check_record_access($person); |
|
412 | - |
|
413 | - // Create a family |
|
414 | - if ($person->getSex() === 'F') { |
|
415 | - $gedcom = "0 @NEW@ FAM\n1 WIFE @" . $person->getXref() . '@'; |
|
416 | - } else { |
|
417 | - $gedcom = "0 @NEW@ FAM\n1 HUSB @" . $person->getXref() . '@'; |
|
418 | - } |
|
419 | - $family = $tree->createRecord($gedcom); |
|
398 | + case 'add_child_to_individual_action': |
|
399 | + ////////////////////////////////////////////////////////////////////////////// |
|
400 | + // Add a child to an existing individual (creating a one-parent family) |
|
401 | + ////////////////////////////////////////////////////////////////////////////// |
|
402 | + $tree = $controller->tree(); |
|
403 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
404 | + $PEDI = Filter::post('PEDI'); |
|
405 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
406 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
407 | + $text = Filter::postArray('text'); |
|
408 | + $islink = Filter::postArray('islink', '[01]'); |
|
409 | + |
|
410 | + $person = Individual::getInstance($xref, $tree); |
|
411 | + check_record_access($person); |
|
412 | + |
|
413 | + // Create a family |
|
414 | + if ($person->getSex() === 'F') { |
|
415 | + $gedcom = "0 @NEW@ FAM\n1 WIFE @" . $person->getXref() . '@'; |
|
416 | + } else { |
|
417 | + $gedcom = "0 @NEW@ FAM\n1 HUSB @" . $person->getXref() . '@'; |
|
418 | + } |
|
419 | + $family = $tree->createRecord($gedcom); |
|
420 | 420 | |
421 | - // Link the parent to the family |
|
422 | - $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
421 | + // Link the parent to the family |
|
422 | + $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
423 | 423 | |
424 | - // Create a child |
|
425 | - FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
424 | + // Create a child |
|
425 | + FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
426 | 426 | |
427 | - $gedcom = '0 @NEW@ INDI'; |
|
428 | - $gedcom .= FunctionsEdit::addNewName($tree); |
|
429 | - $gedcom .= FunctionsEdit::addNewSex(); |
|
430 | - $gedcom .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $family->getXref()); |
|
431 | - if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
432 | - foreach ($matches[1] as $match) { |
|
433 | - $gedcom .= FunctionsEdit::addNewFact($tree, $match); |
|
427 | + $gedcom = '0 @NEW@ INDI'; |
|
428 | + $gedcom .= FunctionsEdit::addNewName($tree); |
|
429 | + $gedcom .= FunctionsEdit::addNewSex(); |
|
430 | + $gedcom .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $family->getXref()); |
|
431 | + if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
432 | + foreach ($matches[1] as $match) { |
|
433 | + $gedcom .= FunctionsEdit::addNewFact($tree, $match); |
|
434 | + } |
|
435 | + } |
|
436 | + if (Filter::postBool('SOUR_INDI')) { |
|
437 | + $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
438 | + } else { |
|
439 | + $gedcom = FunctionsEdit::updateRest($gedcom); |
|
434 | 440 | } |
435 | - } |
|
436 | - if (Filter::postBool('SOUR_INDI')) { |
|
437 | - $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
438 | - } else { |
|
439 | - $gedcom = FunctionsEdit::updateRest($gedcom); |
|
440 | - } |
|
441 | 441 | |
442 | - $child = $tree->createRecord($gedcom); |
|
442 | + $child = $tree->createRecord($gedcom); |
|
443 | 443 | |
444 | - // Link the family to the child |
|
445 | - $family->createFact('1 CHIL @' . $child->getXref() . '@', true); |
|
444 | + // Link the family to the child |
|
445 | + $family->createFact('1 CHIL @' . $child->getXref() . '@', true); |
|
446 | 446 | |
447 | - if (Filter::post('goto') === 'new') { |
|
448 | - header('Location: ' . $child->url()); |
|
449 | - } else { |
|
450 | - header('Location: ' . $person->url()); |
|
451 | - } |
|
452 | - break; |
|
447 | + if (Filter::post('goto') === 'new') { |
|
448 | + header('Location: ' . $child->url()); |
|
449 | + } else { |
|
450 | + header('Location: ' . $person->url()); |
|
451 | + } |
|
452 | + break; |
|
453 | 453 | |
454 | -case 'add_parent_to_individual_action': |
|
455 | - ////////////////////////////////////////////////////////////////////////////// |
|
456 | - // Add a new parent to an existing individual (creating a one-parent family) |
|
457 | - ////////////////////////////////////////////////////////////////////////////// |
|
458 | - $tree = $controller->tree(); |
|
459 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
460 | - $PEDI = Filter::post('PEDI'); |
|
461 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
462 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
463 | - $text = Filter::postArray('text'); |
|
464 | - $islink = Filter::postArray('islink', '[01]'); |
|
465 | - |
|
466 | - $person = Individual::getInstance($xref, $tree); |
|
467 | - check_record_access($person); |
|
468 | - |
|
469 | - // Create a new family |
|
470 | - $gedcom = "0 @NEW@ FAM\n1 CHIL @" . $person->getXref() . '@'; |
|
471 | - $family = $tree->createRecord($gedcom); |
|
472 | - |
|
473 | - // Link the child to the family |
|
474 | - $person->createFact('1 FAMC @' . $family->getXref() . '@', true); |
|
475 | - |
|
476 | - // Create a child |
|
477 | - FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
478 | - |
|
479 | - $gedcom = '0 @NEW@ INDI'; |
|
480 | - $gedcom .= FunctionsEdit::addNewName($tree); |
|
481 | - $gedcom .= FunctionsEdit::addNewSex(); |
|
482 | - if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
483 | - foreach ($matches[1] as $match) { |
|
484 | - $gedcom .= FunctionsEdit::addNewFact($tree, $match); |
|
454 | + case 'add_parent_to_individual_action': |
|
455 | + ////////////////////////////////////////////////////////////////////////////// |
|
456 | + // Add a new parent to an existing individual (creating a one-parent family) |
|
457 | + ////////////////////////////////////////////////////////////////////////////// |
|
458 | + $tree = $controller->tree(); |
|
459 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
460 | + $PEDI = Filter::post('PEDI'); |
|
461 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
462 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
463 | + $text = Filter::postArray('text'); |
|
464 | + $islink = Filter::postArray('islink', '[01]'); |
|
465 | + |
|
466 | + $person = Individual::getInstance($xref, $tree); |
|
467 | + check_record_access($person); |
|
468 | + |
|
469 | + // Create a new family |
|
470 | + $gedcom = "0 @NEW@ FAM\n1 CHIL @" . $person->getXref() . '@'; |
|
471 | + $family = $tree->createRecord($gedcom); |
|
472 | + |
|
473 | + // Link the child to the family |
|
474 | + $person->createFact('1 FAMC @' . $family->getXref() . '@', true); |
|
475 | + |
|
476 | + // Create a child |
|
477 | + FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
478 | + |
|
479 | + $gedcom = '0 @NEW@ INDI'; |
|
480 | + $gedcom .= FunctionsEdit::addNewName($tree); |
|
481 | + $gedcom .= FunctionsEdit::addNewSex(); |
|
482 | + if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
483 | + foreach ($matches[1] as $match) { |
|
484 | + $gedcom .= FunctionsEdit::addNewFact($tree, $match); |
|
485 | + } |
|
485 | 486 | } |
486 | - } |
|
487 | - if (Filter::postBool('SOUR_INDI')) { |
|
488 | - $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
489 | - } else { |
|
490 | - $gedcom = FunctionsEdit::updateRest($gedcom); |
|
491 | - } |
|
492 | - $gedcom .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
487 | + if (Filter::postBool('SOUR_INDI')) { |
|
488 | + $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
489 | + } else { |
|
490 | + $gedcom = FunctionsEdit::updateRest($gedcom); |
|
491 | + } |
|
492 | + $gedcom .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
493 | 493 | |
494 | - $parent = $tree->createRecord($gedcom); |
|
494 | + $parent = $tree->createRecord($gedcom); |
|
495 | 495 | |
496 | - // Link the family to the child |
|
497 | - if ($parent->getSex() === 'F') { |
|
498 | - $family->createFact('1 WIFE @' . $parent->getXref() . '@', true); |
|
499 | - } else { |
|
500 | - $family->createFact('1 HUSB @' . $parent->getXref() . '@', true); |
|
501 | - } |
|
496 | + // Link the family to the child |
|
497 | + if ($parent->getSex() === 'F') { |
|
498 | + $family->createFact('1 WIFE @' . $parent->getXref() . '@', true); |
|
499 | + } else { |
|
500 | + $family->createFact('1 HUSB @' . $parent->getXref() . '@', true); |
|
501 | + } |
|
502 | 502 | |
503 | - if (Filter::post('goto') === 'new') { |
|
504 | - header('Location: ' . $parent->url()); |
|
505 | - } else { |
|
506 | - header('Location: ' . $person->url()); |
|
507 | - } |
|
508 | - break; |
|
503 | + if (Filter::post('goto') === 'new') { |
|
504 | + header('Location: ' . $parent->url()); |
|
505 | + } else { |
|
506 | + header('Location: ' . $person->url()); |
|
507 | + } |
|
508 | + break; |
|
509 | 509 | |
510 | -case 'add_unlinked_indi_action': |
|
511 | - ////////////////////////////////////////////////////////////////////////////// |
|
512 | - // Add a new, unlinked individual |
|
513 | - ////////////////////////////////////////////////////////////////////////////// |
|
514 | - $tree = $controller->tree(); |
|
515 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
516 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
517 | - $text = Filter::postArray('text'); |
|
518 | - $islink = Filter::postArray('islink', '[01]'); |
|
519 | - |
|
520 | - FunctionsEdit::splitSource(); |
|
521 | - $gedrec = '0 @REF@ INDI'; |
|
522 | - $gedrec .= FunctionsEdit::addNewName($tree); |
|
523 | - $gedrec .= FunctionsEdit::addNewSex(); |
|
524 | - if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
525 | - foreach ($matches[1] as $match) { |
|
526 | - $gedrec .= FunctionsEdit::addNewFact($tree, $match); |
|
510 | + case 'add_unlinked_indi_action': |
|
511 | + ////////////////////////////////////////////////////////////////////////////// |
|
512 | + // Add a new, unlinked individual |
|
513 | + ////////////////////////////////////////////////////////////////////////////// |
|
514 | + $tree = $controller->tree(); |
|
515 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
516 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
517 | + $text = Filter::postArray('text'); |
|
518 | + $islink = Filter::postArray('islink', '[01]'); |
|
519 | + |
|
520 | + FunctionsEdit::splitSource(); |
|
521 | + $gedrec = '0 @REF@ INDI'; |
|
522 | + $gedrec .= FunctionsEdit::addNewName($tree); |
|
523 | + $gedrec .= FunctionsEdit::addNewSex(); |
|
524 | + if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
525 | + foreach ($matches[1] as $match) { |
|
526 | + $gedrec .= FunctionsEdit::addNewFact($tree, $match); |
|
527 | + } |
|
528 | + } |
|
529 | + if (Filter::postBool('SOUR_INDI')) { |
|
530 | + $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
531 | + } else { |
|
532 | + $gedrec = FunctionsEdit::updateRest($gedrec); |
|
527 | 533 | } |
528 | - } |
|
529 | - if (Filter::postBool('SOUR_INDI')) { |
|
530 | - $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
531 | - } else { |
|
532 | - $gedrec = FunctionsEdit::updateRest($gedrec); |
|
533 | - } |
|
534 | 534 | |
535 | - $new_indi = $tree->createRecord($gedrec); |
|
535 | + $new_indi = $tree->createRecord($gedrec); |
|
536 | 536 | |
537 | - if (Filter::post('goto') === 'new') { |
|
538 | - header('Location: ' . $new_indi->url()); |
|
539 | - } else { |
|
540 | - header('Location: ' . route('admin-trees')); |
|
541 | - } |
|
542 | - break; |
|
537 | + if (Filter::post('goto') === 'new') { |
|
538 | + header('Location: ' . $new_indi->url()); |
|
539 | + } else { |
|
540 | + header('Location: ' . route('admin-trees')); |
|
541 | + } |
|
542 | + break; |
|
543 | 543 | |
544 | -case 'add_spouse_to_individual_action': |
|
545 | - ////////////////////////////////////////////////////////////////////////////// |
|
546 | - // Add a spouse to an existing individual (creating a new family) |
|
547 | - ////////////////////////////////////////////////////////////////////////////// |
|
548 | - $tree = $controller->tree(); |
|
549 | - $xref = Filter::post('xref'); // Add a spouse to this individual |
|
550 | - $sex = Filter::post('SEX', '[MFU]', 'U'); |
|
551 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
552 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
553 | - $text = Filter::postArray('text'); |
|
554 | - $islink = Filter::postArray('islink', '[01]'); |
|
555 | - |
|
556 | - $person = Individual::getInstance($xref, $tree); |
|
557 | - check_record_access($person); |
|
558 | - |
|
559 | - FunctionsEdit::splitSource(); |
|
560 | - $indi_gedcom = '0 @REF@ INDI'; |
|
561 | - $indi_gedcom .= FunctionsEdit::addNewName($tree); |
|
562 | - $indi_gedcom .= FunctionsEdit::addNewSex(); |
|
563 | - if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
564 | - foreach ($matches[1] as $match) { |
|
565 | - $indi_gedcom .= FunctionsEdit::addNewFact($tree, $match); |
|
544 | + case 'add_spouse_to_individual_action': |
|
545 | + ////////////////////////////////////////////////////////////////////////////// |
|
546 | + // Add a spouse to an existing individual (creating a new family) |
|
547 | + ////////////////////////////////////////////////////////////////////////////// |
|
548 | + $tree = $controller->tree(); |
|
549 | + $xref = Filter::post('xref'); // Add a spouse to this individual |
|
550 | + $sex = Filter::post('SEX', '[MFU]', 'U'); |
|
551 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
552 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
553 | + $text = Filter::postArray('text'); |
|
554 | + $islink = Filter::postArray('islink', '[01]'); |
|
555 | + |
|
556 | + $person = Individual::getInstance($xref, $tree); |
|
557 | + check_record_access($person); |
|
558 | + |
|
559 | + FunctionsEdit::splitSource(); |
|
560 | + $indi_gedcom = '0 @REF@ INDI'; |
|
561 | + $indi_gedcom .= FunctionsEdit::addNewName($tree); |
|
562 | + $indi_gedcom .= FunctionsEdit::addNewSex(); |
|
563 | + if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
564 | + foreach ($matches[1] as $match) { |
|
565 | + $indi_gedcom .= FunctionsEdit::addNewFact($tree, $match); |
|
566 | + } |
|
567 | + } |
|
568 | + if (Filter::postBool('SOUR_INDI')) { |
|
569 | + $indi_gedcom = FunctionsEdit::handleUpdates($indi_gedcom); |
|
570 | + } else { |
|
571 | + $indi_gedcom = FunctionsEdit::updateRest($indi_gedcom); |
|
566 | 572 | } |
567 | - } |
|
568 | - if (Filter::postBool('SOUR_INDI')) { |
|
569 | - $indi_gedcom = FunctionsEdit::handleUpdates($indi_gedcom); |
|
570 | - } else { |
|
571 | - $indi_gedcom = FunctionsEdit::updateRest($indi_gedcom); |
|
572 | - } |
|
573 | 573 | |
574 | - $fam_gedcom = ''; |
|
575 | - if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
576 | - foreach ($matches[1] as $match) { |
|
577 | - $fam_gedcom .= FunctionsEdit::addNewFact($tree, $match); |
|
574 | + $fam_gedcom = ''; |
|
575 | + if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
576 | + foreach ($matches[1] as $match) { |
|
577 | + $fam_gedcom .= FunctionsEdit::addNewFact($tree, $match); |
|
578 | + } |
|
579 | + } |
|
580 | + if (Filter::postBool('SOUR_FAM')) { |
|
581 | + $fam_gedcom = FunctionsEdit::handleUpdates($fam_gedcom); |
|
582 | + } else { |
|
583 | + $fam_gedcom = FunctionsEdit::updateRest($fam_gedcom); |
|
578 | 584 | } |
579 | - } |
|
580 | - if (Filter::postBool('SOUR_FAM')) { |
|
581 | - $fam_gedcom = FunctionsEdit::handleUpdates($fam_gedcom); |
|
582 | - } else { |
|
583 | - $fam_gedcom = FunctionsEdit::updateRest($fam_gedcom); |
|
584 | - } |
|
585 | 585 | |
586 | - // Create the new spouse |
|
587 | - $spouse = $tree->createRecord($indi_gedcom); |
|
588 | - // Create a new family |
|
589 | - if ($sex === 'F') { |
|
590 | - $family = $tree->createRecord("0 @NEW@ FAM\n1 WIFE @" . $spouse->getXref() . "@\n1 HUSB @" . $person->getXref() . '@' . $fam_gedcom); |
|
591 | - } else { |
|
592 | - $family = $tree->createRecord("0 @NEW@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@' . $fam_gedcom); |
|
593 | - } |
|
594 | - // Link the spouses to the family |
|
595 | - $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
596 | - $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
586 | + // Create the new spouse |
|
587 | + $spouse = $tree->createRecord($indi_gedcom); |
|
588 | + // Create a new family |
|
589 | + if ($sex === 'F') { |
|
590 | + $family = $tree->createRecord("0 @NEW@ FAM\n1 WIFE @" . $spouse->getXref() . "@\n1 HUSB @" . $person->getXref() . '@' . $fam_gedcom); |
|
591 | + } else { |
|
592 | + $family = $tree->createRecord("0 @NEW@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@' . $fam_gedcom); |
|
593 | + } |
|
594 | + // Link the spouses to the family |
|
595 | + $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
596 | + $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
597 | 597 | |
598 | - if (Filter::post('goto') === 'new') { |
|
599 | - header('Location: ' . $spouse->url()); |
|
600 | - } else { |
|
601 | - header('Location: ' . $person->url()); |
|
602 | - } |
|
603 | - break; |
|
598 | + if (Filter::post('goto') === 'new') { |
|
599 | + header('Location: ' . $spouse->url()); |
|
600 | + } else { |
|
601 | + header('Location: ' . $person->url()); |
|
602 | + } |
|
603 | + break; |
|
604 | 604 | |
605 | -case 'add_spouse_to_family_action': |
|
606 | - ////////////////////////////////////////////////////////////////////////////// |
|
607 | - // Add a spouse to an existing family |
|
608 | - ////////////////////////////////////////////////////////////////////////////// |
|
609 | - $tree = $controller->tree(); |
|
610 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
611 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
612 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
613 | - $text = Filter::postArray('text'); |
|
614 | - $islink = Filter::postArray('islink', '[01]'); |
|
615 | - |
|
616 | - $family = Family::getInstance($xref, $tree); |
|
617 | - check_record_access($family); |
|
618 | - |
|
619 | - // Create the new spouse |
|
620 | - FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
621 | - |
|
622 | - $gedrec = '0 @REF@ INDI'; |
|
623 | - $gedrec .= FunctionsEdit::addNewName($tree); |
|
624 | - $gedrec .= FunctionsEdit::addNewSex(); |
|
625 | - if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
626 | - foreach ($matches[1] as $match) { |
|
627 | - $gedrec .= FunctionsEdit::addNewFact($tree, $match); |
|
605 | + case 'add_spouse_to_family_action': |
|
606 | + ////////////////////////////////////////////////////////////////////////////// |
|
607 | + // Add a spouse to an existing family |
|
608 | + ////////////////////////////////////////////////////////////////////////////// |
|
609 | + $tree = $controller->tree(); |
|
610 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
611 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
612 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
613 | + $text = Filter::postArray('text'); |
|
614 | + $islink = Filter::postArray('islink', '[01]'); |
|
615 | + |
|
616 | + $family = Family::getInstance($xref, $tree); |
|
617 | + check_record_access($family); |
|
618 | + |
|
619 | + // Create the new spouse |
|
620 | + FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
621 | + |
|
622 | + $gedrec = '0 @REF@ INDI'; |
|
623 | + $gedrec .= FunctionsEdit::addNewName($tree); |
|
624 | + $gedrec .= FunctionsEdit::addNewSex(); |
|
625 | + if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
626 | + foreach ($matches[1] as $match) { |
|
627 | + $gedrec .= FunctionsEdit::addNewFact($tree, $match); |
|
628 | + } |
|
628 | 629 | } |
629 | - } |
|
630 | 630 | |
631 | - if (Filter::postBool('SOUR_INDI')) { |
|
632 | - $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
633 | - } else { |
|
634 | - $gedrec = FunctionsEdit::updateRest($gedrec); |
|
635 | - } |
|
636 | - $gedrec .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
637 | - $spouse = $tree->createRecord($gedrec); |
|
631 | + if (Filter::postBool('SOUR_INDI')) { |
|
632 | + $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
633 | + } else { |
|
634 | + $gedrec = FunctionsEdit::updateRest($gedrec); |
|
635 | + } |
|
636 | + $gedrec .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
637 | + $spouse = $tree->createRecord($gedrec); |
|
638 | 638 | |
639 | - // Update the existing family - add marriage, etc |
|
640 | - if ($family->getFirstFact('HUSB')) { |
|
641 | - $family->createFact('1 WIFE @' . $spouse->getXref() . '@', true); |
|
642 | - } else { |
|
643 | - $family->createFact('1 HUSB @' . $spouse->getXref() . '@', true); |
|
644 | - } |
|
645 | - $famrec = ''; |
|
646 | - if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
647 | - foreach ($matches[1] as $match) { |
|
648 | - $famrec .= FunctionsEdit::addNewFact($tree, $match); |
|
639 | + // Update the existing family - add marriage, etc |
|
640 | + if ($family->getFirstFact('HUSB')) { |
|
641 | + $family->createFact('1 WIFE @' . $spouse->getXref() . '@', true); |
|
642 | + } else { |
|
643 | + $family->createFact('1 HUSB @' . $spouse->getXref() . '@', true); |
|
649 | 644 | } |
650 | - } |
|
651 | - if (Filter::postBool('SOUR_FAM')) { |
|
652 | - $famrec = FunctionsEdit::handleUpdates($famrec); |
|
653 | - } else { |
|
654 | - $famrec = FunctionsEdit::updateRest($famrec); |
|
655 | - } |
|
656 | - $family->createFact(trim($famrec), true); // trim leading \n |
|
645 | + $famrec = ''; |
|
646 | + if (preg_match_all('/([A-Z0-9_]+)/', $tree->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
647 | + foreach ($matches[1] as $match) { |
|
648 | + $famrec .= FunctionsEdit::addNewFact($tree, $match); |
|
649 | + } |
|
650 | + } |
|
651 | + if (Filter::postBool('SOUR_FAM')) { |
|
652 | + $famrec = FunctionsEdit::handleUpdates($famrec); |
|
653 | + } else { |
|
654 | + $famrec = FunctionsEdit::updateRest($famrec); |
|
655 | + } |
|
656 | + $family->createFact(trim($famrec), true); // trim leading \n |
|
657 | 657 | |
658 | - if (Filter::post('goto') === 'new') { |
|
659 | - header('Location: ' . $spouse->url()); |
|
660 | - } else { |
|
661 | - header('Location: ' . $family->url()); |
|
662 | - } |
|
663 | - break; |
|
658 | + if (Filter::post('goto') === 'new') { |
|
659 | + header('Location: ' . $spouse->url()); |
|
660 | + } else { |
|
661 | + header('Location: ' . $family->url()); |
|
662 | + } |
|
663 | + break; |
|
664 | 664 | |
665 | -case 'addfamlink': |
|
666 | - ////////////////////////////////////////////////////////////////////////////// |
|
667 | - // Link an individual to an existing family, as a child |
|
668 | - ////////////////////////////////////////////////////////////////////////////// |
|
669 | - $tree = $controller->tree(); |
|
670 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
665 | + case 'addfamlink': |
|
666 | + ////////////////////////////////////////////////////////////////////////////// |
|
667 | + // Link an individual to an existing family, as a child |
|
668 | + ////////////////////////////////////////////////////////////////////////////// |
|
669 | + $tree = $controller->tree(); |
|
670 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
671 | 671 | |
672 | - $person = Individual::getInstance($xref, $tree); |
|
673 | - check_record_access($person); |
|
672 | + $person = Individual::getInstance($xref, $tree); |
|
673 | + check_record_access($person); |
|
674 | 674 | |
675 | - $controller |
|
676 | - ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child')) |
|
677 | - ->pageHeader(); |
|
675 | + $controller |
|
676 | + ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child')) |
|
677 | + ->pageHeader(); |
|
678 | 678 | |
679 | - ?> |
|
680 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
679 | + ?> |
|
680 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
681 | 681 | <form method="post"> |
682 | 682 | <input type="hidden" name="ged" value="<?= e($tree->getName()) ?>"> |
683 | 683 | <input type="hidden" name="action" value="linkfamaction"> |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | </label> |
700 | 700 | <div class="col-sm-9"> |
701 | 701 | <?= Bootstrap4::select(GedcomCodePedi::getValues($person), '', ['id' => 'PEDI', 'name' => 'PEDI']) ?> |
702 | - <p class="small text-muted"> |
|
702 | + <p class="small text-muted"> |
|
703 | 703 | <?= I18N::translate('A child may have more than one set of parents. The relationship between the child and the parents can be biological, legal, or based on local culture and tradition. If no pedigree is specified, then a biological relationship will be assumed.') ?> |
704 | 704 | </p> |
705 | 705 | </div> |
@@ -711,85 +711,85 @@ discard block |
||
711 | 711 | <div class="col-sm-9 offset-sm-3"> |
712 | 712 | <button class="btn btn-primary" type="submit"> |
713 | 713 | <?= FontAwesome::decorativeIcon('save') ?> |
714 | - <?= /* I18N: A button label. */ |
|
715 | - I18N::translate('save') ?> |
|
714 | + <?= /* I18N: A button label. */ |
|
715 | + I18N::translate('save') ?> |
|
716 | 716 | </button> |
717 | 717 | <a class="btn btn-secondary" href="<?= e($person->url()) ?>"> |
718 | 718 | <?= FontAwesome::decorativeIcon('cancel') ?> |
719 | - <?= /* I18N: A button label. */ |
|
720 | - I18N::translate('cancel') ?> |
|
719 | + <?= /* I18N: A button label. */ |
|
720 | + I18N::translate('cancel') ?> |
|
721 | 721 | </a> |
722 | 722 | </div> |
723 | 723 | </div> |
724 | 724 | </form> |
725 | 725 | <?php |
726 | - break; |
|
726 | + break; |
|
727 | 727 | |
728 | -case 'linkfamaction': |
|
729 | - ////////////////////////////////////////////////////////////////////////////// |
|
730 | - // Link an individual to an existing family, as a child |
|
731 | - ////////////////////////////////////////////////////////////////////////////// |
|
732 | - $tree = $controller->tree(); |
|
733 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
734 | - $famid = Filter::post('famid', WT_REGEX_XREF); |
|
735 | - $PEDI = Filter::post('PEDI'); |
|
736 | - |
|
737 | - $person = Individual::getInstance($xref, $tree); |
|
738 | - $family = Family::getInstance($famid, $tree); |
|
739 | - check_record_access($person); |
|
740 | - check_record_access($family); |
|
741 | - |
|
742 | - // Replace any existing child->family link (we may be changing the PEDI); |
|
743 | - $fact_id = null; |
|
744 | - foreach ($person->getFacts('FAMC') as $fact) { |
|
745 | - if ($family === $fact->getTarget()) { |
|
746 | - $fact_id = $fact->getFactId(); |
|
747 | - break; |
|
728 | + case 'linkfamaction': |
|
729 | + ////////////////////////////////////////////////////////////////////////////// |
|
730 | + // Link an individual to an existing family, as a child |
|
731 | + ////////////////////////////////////////////////////////////////////////////// |
|
732 | + $tree = $controller->tree(); |
|
733 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
734 | + $famid = Filter::post('famid', WT_REGEX_XREF); |
|
735 | + $PEDI = Filter::post('PEDI'); |
|
736 | + |
|
737 | + $person = Individual::getInstance($xref, $tree); |
|
738 | + $family = Family::getInstance($famid, $tree); |
|
739 | + check_record_access($person); |
|
740 | + check_record_access($family); |
|
741 | + |
|
742 | + // Replace any existing child->family link (we may be changing the PEDI); |
|
743 | + $fact_id = null; |
|
744 | + foreach ($person->getFacts('FAMC') as $fact) { |
|
745 | + if ($family === $fact->getTarget()) { |
|
746 | + $fact_id = $fact->getFactId(); |
|
747 | + break; |
|
748 | + } |
|
748 | 749 | } |
749 | - } |
|
750 | 750 | |
751 | - $gedcom = GedcomCodePedi::createNewFamcPedi($PEDI, $famid); |
|
752 | - $person->updateFact($fact_id, $gedcom, true); |
|
751 | + $gedcom = GedcomCodePedi::createNewFamcPedi($PEDI, $famid); |
|
752 | + $person->updateFact($fact_id, $gedcom, true); |
|
753 | 753 | |
754 | - // Only set the family->child link if it does not already exist |
|
755 | - $edit_fact = null; |
|
756 | - foreach ($family->getFacts('CHIL') as $fact) { |
|
757 | - if ($person === $fact->getTarget()) { |
|
758 | - $edit_fact = $fact; |
|
759 | - break; |
|
754 | + // Only set the family->child link if it does not already exist |
|
755 | + $edit_fact = null; |
|
756 | + foreach ($family->getFacts('CHIL') as $fact) { |
|
757 | + if ($person === $fact->getTarget()) { |
|
758 | + $edit_fact = $fact; |
|
759 | + break; |
|
760 | + } |
|
761 | + } |
|
762 | + if (!$edit_fact) { |
|
763 | + $family->createFact('1 CHIL @' . $person->getXref() . '@', true); |
|
760 | 764 | } |
761 | - } |
|
762 | - if (!$edit_fact) { |
|
763 | - $family->createFact('1 CHIL @' . $person->getXref() . '@', true); |
|
764 | - } |
|
765 | 765 | |
766 | - header('Location: ' . $person->url()); |
|
767 | - break; |
|
766 | + header('Location: ' . $person->url()); |
|
767 | + break; |
|
768 | 768 | |
769 | -case 'linkspouse': |
|
770 | - ////////////////////////////////////////////////////////////////////////////// |
|
771 | - // Link and individual to an existing individual as a spouse |
|
772 | - ////////////////////////////////////////////////////////////////////////////// |
|
773 | - $tree = $controller->tree(); |
|
774 | - $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
775 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
769 | + case 'linkspouse': |
|
770 | + ////////////////////////////////////////////////////////////////////////////// |
|
771 | + // Link and individual to an existing individual as a spouse |
|
772 | + ////////////////////////////////////////////////////////////////////////////// |
|
773 | + $tree = $controller->tree(); |
|
774 | + $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
775 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
776 | 776 | |
777 | - $person = Individual::getInstance($xref, $tree); |
|
778 | - check_record_access($person); |
|
777 | + $person = Individual::getInstance($xref, $tree); |
|
778 | + check_record_access($person); |
|
779 | 779 | |
780 | - if ($person->getSex() === 'F') { |
|
781 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
782 | - $label = I18N::translate('Husband'); |
|
783 | - } else { |
|
784 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
785 | - $label = I18N::translate('Wife'); |
|
786 | - } |
|
780 | + if ($person->getSex() === 'F') { |
|
781 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
782 | + $label = I18N::translate('Husband'); |
|
783 | + } else { |
|
784 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
785 | + $label = I18N::translate('Wife'); |
|
786 | + } |
|
787 | 787 | |
788 | - $controller->pageHeader(); |
|
789 | - FunctionsPrint::initializeCalendarPopup(); |
|
788 | + $controller->pageHeader(); |
|
789 | + FunctionsPrint::initializeCalendarPopup(); |
|
790 | 790 | |
791 | - ?> |
|
792 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
791 | + ?> |
|
792 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
793 | 793 | |
794 | 794 | <form method="post"> |
795 | 795 | <input type="hidden" name="ged" value="<?= e($tree->getName()) ?>"> |
@@ -807,120 +807,120 @@ discard block |
||
807 | 807 | </div> |
808 | 808 | |
809 | 809 | <?= FunctionsEdit::addSimpleTag($tree, '0 MARR Y') ?> |
810 | - <?= FunctionsEdit::addSimpleTag($tree, '0 DATE', 'MARR') ?> |
|
811 | - <?= FunctionsEdit::addSimpleTag($tree, '0 PLAC', 'MARR') ?> |
|
810 | + <?= FunctionsEdit::addSimpleTag($tree, '0 DATE', 'MARR') ?> |
|
811 | + <?= FunctionsEdit::addSimpleTag($tree, '0 PLAC', 'MARR') ?> |
|
812 | 812 | |
813 | 813 | <div class="row form-group"> |
814 | 814 | <div class="col-sm-9 offset-sm-3"> |
815 | 815 | <button class="btn btn-primary" type="submit"> |
816 | 816 | <?= FontAwesome::decorativeIcon('save') ?> |
817 | - <?= /* I18N: A button label. */ I18N::translate('save') ?> |
|
817 | + <?= /* I18N: A button label. */ I18N::translate('save') ?> |
|
818 | 818 | </button> |
819 | 819 | <a class="btn btn-secondary" href="<?= e($person->url()) ?>"> |
820 | 820 | <?= FontAwesome::decorativeIcon('cancel') ?> |
821 | - <?= /* I18N: A button label. */ I18N::translate('cancel') ?> |
|
821 | + <?= /* I18N: A button label. */ I18N::translate('cancel') ?> |
|
822 | 822 | </a> |
823 | 823 | </div> |
824 | 824 | </div> |
825 | 825 | </form> |
826 | 826 | <?php |
827 | - break; |
|
828 | - |
|
829 | -case 'linkspouseaction': |
|
830 | - ////////////////////////////////////////////////////////////////////////////// |
|
831 | - // Link and individual to an existing individual as a spouse |
|
832 | - ////////////////////////////////////////////////////////////////////////////// |
|
833 | - $tree = $controller->tree(); |
|
834 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
835 | - $spid = Filter::post('spid', WT_REGEX_XREF); |
|
836 | - $famtag = Filter::post('famtag', 'HUSB|WIFE'); |
|
837 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
838 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
839 | - $text = Filter::postArray('text'); |
|
840 | - $islink = Filter::postArray('islink', '[01]'); |
|
841 | - |
|
842 | - $person = Individual::getInstance($xref, $tree); |
|
843 | - $spouse = Individual::getInstance($spid, $tree); |
|
844 | - check_record_access($person); |
|
845 | - check_record_access($spouse); |
|
846 | - |
|
847 | - if ($person->getSex() === 'F') { |
|
848 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
849 | - } else { |
|
850 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
851 | - } |
|
827 | + break; |
|
852 | 828 | |
853 | - if ($person->getSex() === 'M') { |
|
854 | - $gedcom = "0 @new@ FAM\n1 HUSB @" . $person->getXref() . "@\n1 WIFE @" . $spouse->getXref() . '@'; |
|
855 | - } else { |
|
856 | - $gedcom = "0 @new@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@'; |
|
857 | - } |
|
858 | - FunctionsEdit::splitSource(); |
|
859 | - $gedcom .= FunctionsEdit::addNewFact($tree, 'MARR'); |
|
829 | + case 'linkspouseaction': |
|
830 | + ////////////////////////////////////////////////////////////////////////////// |
|
831 | + // Link and individual to an existing individual as a spouse |
|
832 | + ////////////////////////////////////////////////////////////////////////////// |
|
833 | + $tree = $controller->tree(); |
|
834 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
835 | + $spid = Filter::post('spid', WT_REGEX_XREF); |
|
836 | + $famtag = Filter::post('famtag', 'HUSB|WIFE'); |
|
837 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
838 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
839 | + $text = Filter::postArray('text'); |
|
840 | + $islink = Filter::postArray('islink', '[01]'); |
|
841 | + |
|
842 | + $person = Individual::getInstance($xref, $tree); |
|
843 | + $spouse = Individual::getInstance($spid, $tree); |
|
844 | + check_record_access($person); |
|
845 | + check_record_access($spouse); |
|
846 | + |
|
847 | + if ($person->getSex() === 'F') { |
|
848 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
849 | + } else { |
|
850 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
851 | + } |
|
860 | 852 | |
861 | - if (Filter::postBool('SOUR_FAM') || count($tagSOUR) > 0) { |
|
862 | - // before adding 2 SOUR it needs to add 1 MARR Y first |
|
863 | - if (FunctionsEdit::addNewFact($tree, 'MARR') === '') { |
|
864 | - $gedcom .= "\n1 MARR Y"; |
|
853 | + if ($person->getSex() === 'M') { |
|
854 | + $gedcom = "0 @new@ FAM\n1 HUSB @" . $person->getXref() . "@\n1 WIFE @" . $spouse->getXref() . '@'; |
|
855 | + } else { |
|
856 | + $gedcom = "0 @new@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@'; |
|
865 | 857 | } |
866 | - $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
867 | - } else { |
|
868 | - // before adding level 2 facts it needs to add 1 MARR Y first |
|
869 | - if (FunctionsEdit::addNewFact($tree, 'MARR') === '') { |
|
870 | - $gedcom .= "\n1 MARR Y"; |
|
858 | + FunctionsEdit::splitSource(); |
|
859 | + $gedcom .= FunctionsEdit::addNewFact($tree, 'MARR'); |
|
860 | + |
|
861 | + if (Filter::postBool('SOUR_FAM') || count($tagSOUR) > 0) { |
|
862 | + // before adding 2 SOUR it needs to add 1 MARR Y first |
|
863 | + if (FunctionsEdit::addNewFact($tree, 'MARR') === '') { |
|
864 | + $gedcom .= "\n1 MARR Y"; |
|
865 | + } |
|
866 | + $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
867 | + } else { |
|
868 | + // before adding level 2 facts it needs to add 1 MARR Y first |
|
869 | + if (FunctionsEdit::addNewFact($tree, 'MARR') === '') { |
|
870 | + $gedcom .= "\n1 MARR Y"; |
|
871 | + } |
|
872 | + $gedcom = FunctionsEdit::updateRest($gedcom); |
|
871 | 873 | } |
872 | - $gedcom = FunctionsEdit::updateRest($gedcom); |
|
873 | - } |
|
874 | 874 | |
875 | - $family = $tree->createRecord($gedcom); |
|
876 | - $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
877 | - $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
875 | + $family = $tree->createRecord($gedcom); |
|
876 | + $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
877 | + $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
878 | 878 | |
879 | - header('Location: ' . $person->url()); |
|
880 | - break; |
|
879 | + header('Location: ' . $person->url()); |
|
880 | + break; |
|
881 | 881 | |
882 | -case 'addmedia_links': |
|
883 | - ////////////////////////////////////////////////////////////////////////////// |
|
884 | - // |
|
885 | - ////////////////////////////////////////////////////////////////////////////// |
|
886 | - $tree = $controller->tree(); |
|
887 | - $pid = Filter::get('pid', WT_REGEX_XREF); |
|
882 | + case 'addmedia_links': |
|
883 | + ////////////////////////////////////////////////////////////////////////////// |
|
884 | + // |
|
885 | + ////////////////////////////////////////////////////////////////////////////// |
|
886 | + $tree = $controller->tree(); |
|
887 | + $pid = Filter::get('pid', WT_REGEX_XREF); |
|
888 | 888 | |
889 | - $person = Individual::getInstance($pid, $tree); |
|
890 | - check_record_access($person); |
|
889 | + $person = Individual::getInstance($pid, $tree); |
|
890 | + check_record_access($person); |
|
891 | 891 | |
892 | - $controller |
|
893 | - ->setPageTitle(I18N::translate('Family navigator') . ' — ' . $person->getFullName()) |
|
894 | - ->pageHeader(); |
|
892 | + $controller |
|
893 | + ->setPageTitle(I18N::translate('Family navigator') . ' — ' . $person->getFullName()) |
|
894 | + ->pageHeader(); |
|
895 | 895 | |
896 | - ?> |
|
897 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
896 | + ?> |
|
897 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
898 | 898 | |
899 | 899 | <form method="post" action="edit_interface.php?xref=<?= $person->getXref() ?>" onsubmit="findindi()"> |
900 | 900 | <input type="hidden" name="ged" value="<?= e($tree->getName()) ?>"> |
901 | 901 | <input type="hidden" name="action" value="addmedia_links"> |
902 | 902 | <input type="hidden" name="noteid" value="newnote"> |
903 | 903 | <?= Filter::getCsrf() ?> |
904 | - <?php require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/MEDIA_ctrl.php' ?> |
|
905 | - </form> |
|
904 | + <?php require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/MEDIA_ctrl.php' ?> |
|
905 | + </form> |
|
906 | 906 | <?php |
907 | - break; |
|
907 | + break; |
|
908 | 908 | |
909 | -case 'add-media-link': |
|
910 | - ////////////////////////////////////////////////////////////////////////////// |
|
911 | - // Link a media object to a record. |
|
912 | - ////////////////////////////////////////////////////////////////////////////// |
|
913 | - $tree = $controller->tree(); |
|
914 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
915 | - $record = GedcomRecord::getInstance($xref, $tree); |
|
916 | - check_record_access($record); |
|
909 | + case 'add-media-link': |
|
910 | + ////////////////////////////////////////////////////////////////////////////// |
|
911 | + // Link a media object to a record. |
|
912 | + ////////////////////////////////////////////////////////////////////////////// |
|
913 | + $tree = $controller->tree(); |
|
914 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
915 | + $record = GedcomRecord::getInstance($xref, $tree); |
|
916 | + check_record_access($record); |
|
917 | 917 | |
918 | - $controller |
|
919 | - ->setPageTitle($record->getFullName() . ' — ' . I18N::translate('Add a media object')) |
|
920 | - ->pageHeader(); |
|
918 | + $controller |
|
919 | + ->setPageTitle($record->getFullName() . ' — ' . I18N::translate('Add a media object')) |
|
920 | + ->pageHeader(); |
|
921 | 921 | |
922 | - ?> |
|
923 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
922 | + ?> |
|
923 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
924 | 924 | |
925 | 925 | <form method="post"> |
926 | 926 | <input type="hidden" name="ged" value="<?= e($tree->getName()) ?>"> |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | </button> |
943 | 943 | </span> |
944 | 944 | <?php endif ?> |
945 | - <?= FunctionsEdit::formControlMediaObject($tree, null, ['id' => 'media-xref', 'name' => 'media-xref', 'data-element-id' => 'media-xref']) ?> |
|
945 | + <?= FunctionsEdit::formControlMediaObject($tree, null, ['id' => 'media-xref', 'name' => 'media-xref', 'data-element-id' => 'media-xref']) ?> |
|
946 | 946 | </div> |
947 | 947 | </div> |
948 | 948 | </div> |
@@ -951,57 +951,57 @@ discard block |
||
951 | 951 | <div class="col-sm-9 offset-sm-3"> |
952 | 952 | <button class="btn btn-primary" type="submit"> |
953 | 953 | <?= FontAwesome::decorativeIcon('save') ?> |
954 | - <?= /* I18N: A button label. */ |
|
955 | - I18N::translate('save') ?> |
|
954 | + <?= /* I18N: A button label. */ |
|
955 | + I18N::translate('save') ?> |
|
956 | 956 | </button> |
957 | 957 | <a class="btn btn-secondary" href="<?= e($record->url()) ?>"> |
958 | 958 | <?= FontAwesome::decorativeIcon('cancel') ?> |
959 | - <?= /* I18N: A button label. */ |
|
960 | - I18N::translate('cancel') ?> |
|
959 | + <?= /* I18N: A button label. */ |
|
960 | + I18N::translate('cancel') ?> |
|
961 | 961 | </a> |
962 | 962 | </div> |
963 | 963 | </div> |
964 | 964 | </form> |
965 | 965 | <?= view('modals/ajax') ?> |
966 | - <?php |
|
967 | - break; |
|
966 | + <?php |
|
967 | + break; |
|
968 | 968 | |
969 | -case 'save-media-link': |
|
970 | - ////////////////////////////////////////////////////////////////////////////// |
|
971 | - // Link a media object to a record. |
|
972 | - ////////////////////////////////////////////////////////////////////////////// |
|
973 | - $tree = $controller->tree(); |
|
974 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
975 | - $media_xref = Filter::post('media-xref', WT_REGEX_XREF); |
|
976 | - $record = GedcomRecord::getInstance($xref, $tree); |
|
977 | - check_record_access($record); |
|
969 | + case 'save-media-link': |
|
970 | + ////////////////////////////////////////////////////////////////////////////// |
|
971 | + // Link a media object to a record. |
|
972 | + ////////////////////////////////////////////////////////////////////////////// |
|
973 | + $tree = $controller->tree(); |
|
974 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
975 | + $media_xref = Filter::post('media-xref', WT_REGEX_XREF); |
|
976 | + $record = GedcomRecord::getInstance($xref, $tree); |
|
977 | + check_record_access($record); |
|
978 | 978 | |
979 | - $gedcom = '1 OBJE @' . $media_xref . '@'; |
|
979 | + $gedcom = '1 OBJE @' . $media_xref . '@'; |
|
980 | 980 | |
981 | - $record->createFact($gedcom, true); |
|
981 | + $record->createFact($gedcom, true); |
|
982 | 982 | |
983 | - header('Location: ' . $record->url()); |
|
984 | - break; |
|
983 | + header('Location: ' . $record->url()); |
|
984 | + break; |
|
985 | 985 | |
986 | -case 'changefamily': |
|
987 | - ////////////////////////////////////////////////////////////////////////////// |
|
988 | - // Change the members of a family record |
|
989 | - ////////////////////////////////////////////////////////////////////////////// |
|
990 | - $tree = $controller->tree(); |
|
991 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
986 | + case 'changefamily': |
|
987 | + ////////////////////////////////////////////////////////////////////////////// |
|
988 | + // Change the members of a family record |
|
989 | + ////////////////////////////////////////////////////////////////////////////// |
|
990 | + $tree = $controller->tree(); |
|
991 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
992 | 992 | |
993 | - $family = Family::getInstance($xref, $tree); |
|
994 | - check_record_access($family); |
|
993 | + $family = Family::getInstance($xref, $tree); |
|
994 | + check_record_access($family); |
|
995 | 995 | |
996 | - $controller |
|
997 | - ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName()) |
|
998 | - ->pageHeader(); |
|
996 | + $controller |
|
997 | + ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName()) |
|
998 | + ->pageHeader(); |
|
999 | 999 | |
1000 | - $father = $family->getHusband(); |
|
1001 | - $mother = $family->getWife(); |
|
1002 | - $children = $family->getChildren(); |
|
1003 | - ?> |
|
1004 | - <h2><?= $controller->getPageTitle() ?></h2> |
|
1000 | + $father = $family->getHusband(); |
|
1001 | + $mother = $family->getWife(); |
|
1002 | + $children = $family->getChildren(); |
|
1003 | + ?> |
|
1004 | + <h2><?= $controller->getPageTitle() ?></h2> |
|
1005 | 1005 | |
1006 | 1006 | <div id="changefam"> |
1007 | 1007 | <form name="changefamform" method="post"> |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | <td class="descriptionbox"> |
1016 | 1016 | <b> |
1017 | 1017 | <?php |
1018 | - switch ($father->getSex()) { |
|
1018 | + switch ($father->getSex()) { |
|
1019 | 1019 | case 'M': |
1020 | 1020 | echo I18N::translate('husband'); |
1021 | 1021 | break; |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | default: |
1026 | 1026 | echo I18N::translate('spouse'); |
1027 | 1027 | break; |
1028 | - } |
|
1028 | + } |
|
1029 | 1029 | ?> |
1030 | 1030 | </b> |
1031 | 1031 | <input type="hidden" name="HUSB" value="<?= $father->getXref() ?>"> |
@@ -1157,111 +1157,111 @@ discard block |
||
1157 | 1157 | <?php |
1158 | 1158 | break; |
1159 | 1159 | |
1160 | -case 'changefamily_update': |
|
1161 | - ////////////////////////////////////////////////////////////////////////////// |
|
1162 | - // Change the members of a family record |
|
1163 | - ////////////////////////////////////////////////////////////////////////////// |
|
1164 | - $tree = $controller->tree(); |
|
1165 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
1166 | - $HUSB = Filter::post('HUSB', WT_REGEX_XREF); |
|
1167 | - $WIFE = Filter::post('WIFE', WT_REGEX_XREF); |
|
1168 | - $keep_chan = Filter::postBool('keep_chan'); |
|
1169 | - |
|
1170 | - $CHIL = []; |
|
1171 | - for ($i = 0; isset($_POST['CHIL' . $i]); ++$i) { |
|
1172 | - $CHIL[] = Filter::post('CHIL' . $i, WT_REGEX_XREF); |
|
1173 | - } |
|
1160 | + case 'changefamily_update': |
|
1161 | + ////////////////////////////////////////////////////////////////////////////// |
|
1162 | + // Change the members of a family record |
|
1163 | + ////////////////////////////////////////////////////////////////////////////// |
|
1164 | + $tree = $controller->tree(); |
|
1165 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
1166 | + $HUSB = Filter::post('HUSB', WT_REGEX_XREF); |
|
1167 | + $WIFE = Filter::post('WIFE', WT_REGEX_XREF); |
|
1168 | + $keep_chan = Filter::postBool('keep_chan'); |
|
1169 | + |
|
1170 | + $CHIL = []; |
|
1171 | + for ($i = 0; isset($_POST['CHIL' . $i]); ++$i) { |
|
1172 | + $CHIL[] = Filter::post('CHIL' . $i, WT_REGEX_XREF); |
|
1173 | + } |
|
1174 | 1174 | |
1175 | - $family = Family::getInstance($xref, $tree); |
|
1176 | - check_record_access($family); |
|
1175 | + $family = Family::getInstance($xref, $tree); |
|
1176 | + check_record_access($family); |
|
1177 | 1177 | |
1178 | - // Current family members |
|
1179 | - $old_father = $family->getHusband(); |
|
1180 | - $old_mother = $family->getWife(); |
|
1181 | - $old_children = $family->getChildren(); |
|
1178 | + // Current family members |
|
1179 | + $old_father = $family->getHusband(); |
|
1180 | + $old_mother = $family->getWife(); |
|
1181 | + $old_children = $family->getChildren(); |
|
1182 | 1182 | |
1183 | - // New family members |
|
1184 | - $new_father = Individual::getInstance($HUSB, $tree); |
|
1185 | - $new_mother = Individual::getInstance($WIFE, $tree); |
|
1186 | - $new_children = []; |
|
1187 | - foreach ($CHIL as $child) { |
|
1188 | - $new_children[] = Individual::getInstance($child, $tree); |
|
1189 | - } |
|
1183 | + // New family members |
|
1184 | + $new_father = Individual::getInstance($HUSB, $tree); |
|
1185 | + $new_mother = Individual::getInstance($WIFE, $tree); |
|
1186 | + $new_children = []; |
|
1187 | + foreach ($CHIL as $child) { |
|
1188 | + $new_children[] = Individual::getInstance($child, $tree); |
|
1189 | + } |
|
1190 | 1190 | |
1191 | - if ($old_father !== $new_father) { |
|
1192 | - if ($old_father) { |
|
1193 | - // Remove old FAMS link |
|
1194 | - foreach ($old_father->getFacts('FAMS') as $fact) { |
|
1195 | - if ($fact->getTarget() === $family) { |
|
1196 | - $old_father->deleteFact($fact->getFactId(), !$keep_chan); |
|
1191 | + if ($old_father !== $new_father) { |
|
1192 | + if ($old_father) { |
|
1193 | + // Remove old FAMS link |
|
1194 | + foreach ($old_father->getFacts('FAMS') as $fact) { |
|
1195 | + if ($fact->getTarget() === $family) { |
|
1196 | + $old_father->deleteFact($fact->getFactId(), !$keep_chan); |
|
1197 | + } |
|
1197 | 1198 | } |
1198 | - } |
|
1199 | - // Remove old HUSB link |
|
1200 | - foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
1201 | - if ($fact->getTarget() === $old_father) { |
|
1202 | - $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1199 | + // Remove old HUSB link |
|
1200 | + foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
1201 | + if ($fact->getTarget() === $old_father) { |
|
1202 | + $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1203 | + } |
|
1203 | 1204 | } |
1204 | 1205 | } |
1206 | + if ($new_father) { |
|
1207 | + // Add new FAMS link |
|
1208 | + $new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
1209 | + // Add new HUSB link |
|
1210 | + $family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan); |
|
1211 | + } |
|
1205 | 1212 | } |
1206 | - if ($new_father) { |
|
1207 | - // Add new FAMS link |
|
1208 | - $new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
1209 | - // Add new HUSB link |
|
1210 | - $family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan); |
|
1211 | - } |
|
1212 | - } |
|
1213 | 1213 | |
1214 | - if ($old_mother !== $new_mother) { |
|
1215 | - if ($old_mother) { |
|
1216 | - // Remove old FAMS link |
|
1217 | - foreach ($old_mother->getFacts('FAMS') as $fact) { |
|
1218 | - if ($fact->getTarget() === $family) { |
|
1219 | - $old_mother->deleteFact($fact->getFactId(), !$keep_chan); |
|
1214 | + if ($old_mother !== $new_mother) { |
|
1215 | + if ($old_mother) { |
|
1216 | + // Remove old FAMS link |
|
1217 | + foreach ($old_mother->getFacts('FAMS') as $fact) { |
|
1218 | + if ($fact->getTarget() === $family) { |
|
1219 | + $old_mother->deleteFact($fact->getFactId(), !$keep_chan); |
|
1220 | + } |
|
1220 | 1221 | } |
1221 | - } |
|
1222 | - // Remove old WIFE link |
|
1223 | - foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
1224 | - if ($fact->getTarget() === $old_mother) { |
|
1225 | - $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1222 | + // Remove old WIFE link |
|
1223 | + foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
1224 | + if ($fact->getTarget() === $old_mother) { |
|
1225 | + $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1226 | + } |
|
1226 | 1227 | } |
1227 | 1228 | } |
1229 | + if ($new_mother) { |
|
1230 | + // Add new FAMS link |
|
1231 | + $new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
1232 | + // Add new WIFE link |
|
1233 | + $family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan); |
|
1234 | + } |
|
1228 | 1235 | } |
1229 | - if ($new_mother) { |
|
1230 | - // Add new FAMS link |
|
1231 | - $new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
1232 | - // Add new WIFE link |
|
1233 | - $family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan); |
|
1234 | - } |
|
1235 | - } |
|
1236 | 1236 | |
1237 | - foreach ($old_children as $old_child) { |
|
1238 | - if ($old_child && !in_array($old_child, $new_children)) { |
|
1239 | - // Remove old FAMC link |
|
1240 | - foreach ($old_child->getFacts('FAMC') as $fact) { |
|
1241 | - if ($fact->getTarget() === $family) { |
|
1242 | - $old_child->deleteFact($fact->getFactId(), !$keep_chan); |
|
1237 | + foreach ($old_children as $old_child) { |
|
1238 | + if ($old_child && !in_array($old_child, $new_children)) { |
|
1239 | + // Remove old FAMC link |
|
1240 | + foreach ($old_child->getFacts('FAMC') as $fact) { |
|
1241 | + if ($fact->getTarget() === $family) { |
|
1242 | + $old_child->deleteFact($fact->getFactId(), !$keep_chan); |
|
1243 | + } |
|
1243 | 1244 | } |
1244 | - } |
|
1245 | - // Remove old CHIL link |
|
1246 | - foreach ($family->getFacts('CHIL') as $fact) { |
|
1247 | - if ($fact->getTarget() === $old_child) { |
|
1248 | - $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1245 | + // Remove old CHIL link |
|
1246 | + foreach ($family->getFacts('CHIL') as $fact) { |
|
1247 | + if ($fact->getTarget() === $old_child) { |
|
1248 | + $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
1249 | + } |
|
1249 | 1250 | } |
1250 | 1251 | } |
1251 | 1252 | } |
1252 | - } |
|
1253 | 1253 | |
1254 | - foreach ($new_children as $new_child) { |
|
1255 | - if ($new_child && !in_array($new_child, $old_children)) { |
|
1256 | - // Add new FAMC link |
|
1257 | - $new_child->createFact('1 FAMC @' . $family->getXref() . '@', !$keep_chan); |
|
1258 | - // Add new CHIL link |
|
1259 | - $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
1254 | + foreach ($new_children as $new_child) { |
|
1255 | + if ($new_child && !in_array($new_child, $old_children)) { |
|
1256 | + // Add new FAMC link |
|
1257 | + $new_child->createFact('1 FAMC @' . $family->getXref() . '@', !$keep_chan); |
|
1258 | + // Add new CHIL link |
|
1259 | + $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
1260 | + } |
|
1260 | 1261 | } |
1261 | - } |
|
1262 | 1262 | |
1263 | - header('Location: ' . $family->url()); |
|
1264 | - break; |
|
1263 | + header('Location: ' . $family->url()); |
|
1264 | + break; |
|
1265 | 1265 | } |
1266 | 1266 | |
1267 | 1267 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | echo view('cards/add-source-citation', [ |
92 | 92 | 'level' => 2, |
93 | 93 | 'full_citations' => $tree->getPreference('FULL_SOURCES'), |
94 | - ]); } |
|
94 | + ]); } |
|
95 | 95 | if ($level1type !== 'OBJE') { |
96 | 96 | if ($tree->getPreference('MEDIA_UPLOAD') >= Auth::accessLevel($tree)) { |
97 | 97 | echo view('cards/add-media-object', [ |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | ////////////////////////////////////////////////////////////////////////////// |
400 | 400 | // Add a child to an existing individual (creating a one-parent family) |
401 | 401 | ////////////////////////////////////////////////////////////////////////////// |
402 | - $tree = $controller->tree(); |
|
402 | + $tree = $controller->tree(); |
|
403 | 403 | $xref = Filter::post('xref', WT_REGEX_XREF); |
404 | 404 | $PEDI = Filter::post('PEDI'); |
405 | 405 | $glevels = Filter::postArray('glevels', '[0-9]'); |