$tag = Filter::postArray('tag', WT_REGEX_TAG); $text = Filter::postArray('text'); $islink = Filter::postArray('islink', '[01]'); $family = Family::getInstance($xref, $WT_TREE); check_record_access($family); if (!Filter::checkCsrf()) { $famtag = Filter::get('famtag', 'HUSB|WIFE'); header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_family&xref=' . $xref . '&famtag=' . $famtag); return; } $controller->pageHeader(); // Create the new spouse FunctionsEdit::splitSource(); // separate SOUR record from the rest $gedrec = '0 @REF@ INDI'; $gedrec .= FunctionsEdit::addNewName(); $gedrec .= FunctionsEdit::addNewSex(); if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { foreach ($matches[1] as $match) { $gedrec .= FunctionsEdit::addNewFact($match); } } if (Filter::postBool('SOUR_INDI')) { $gedrec = FunctionsEdit::handleUpdates($gedrec); } else { $gedrec = FunctionsEdit::updateRest($gedrec); } $gedrec .= "\n1 FAMS @" . $family->getXref() . '@'; $spouse = $family->getTree()->createRecord($gedrec); // Update the existing family - add marriage, etc if ($family->getFirstFact('HUSB')) {