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