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