@@ -98,52 +98,52 @@ |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | switch ($action) { |
| 101 | - case 'delete': |
|
| 102 | - $sql_delete = |
|
| 103 | - "DELETE `##log` FROM `##log`" . |
|
| 104 | - " LEFT JOIN `##user` USING (user_id)" . // user may be deleted |
|
| 105 | - " LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted |
|
| 106 | - |
|
| 107 | - Database::prepare($sql_delete . $where)->execute($args); |
|
| 108 | - break; |
|
| 109 | - |
|
| 110 | - case 'export': |
|
| 111 | - header('Content-Type: text/csv'); |
|
| 112 | - header('Content-Disposition: attachment; filename="webtrees-logs.csv"'); |
|
| 113 | - $rows = Database::prepare($sql_select . $where . ' ORDER BY log_id')->execute($args)->fetchAll(); |
|
| 114 | - foreach ($rows as $row) { |
|
| 115 | - echo |
|
| 116 | - '"', $row->log_time, '",', |
|
| 117 | - '"', $row->log_type, '",', |
|
| 118 | - '"', str_replace('"', '""', $row->log_message), '",', |
|
| 119 | - '"', $row->ip_address, '",', |
|
| 120 | - '"', str_replace('"', '""', $row->user_name), '",', |
|
| 121 | - '"', str_replace('"', '""', $row->gedcom_name), '"', |
|
| 122 | - "\n"; |
|
| 123 | - } |
|
| 101 | + case 'delete': |
|
| 102 | + $sql_delete = |
|
| 103 | + "DELETE `##log` FROM `##log`" . |
|
| 104 | + " LEFT JOIN `##user` USING (user_id)" . // user may be deleted |
|
| 105 | + " LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted |
|
| 106 | + |
|
| 107 | + Database::prepare($sql_delete . $where)->execute($args); |
|
| 108 | + break; |
|
| 109 | + |
|
| 110 | + case 'export': |
|
| 111 | + header('Content-Type: text/csv'); |
|
| 112 | + header('Content-Disposition: attachment; filename="webtrees-logs.csv"'); |
|
| 113 | + $rows = Database::prepare($sql_select . $where . ' ORDER BY log_id')->execute($args)->fetchAll(); |
|
| 114 | + foreach ($rows as $row) { |
|
| 115 | + echo |
|
| 116 | + '"', $row->log_time, '",', |
|
| 117 | + '"', $row->log_type, '",', |
|
| 118 | + '"', str_replace('"', '""', $row->log_message), '",', |
|
| 119 | + '"', $row->ip_address, '",', |
|
| 120 | + '"', str_replace('"', '""', $row->user_name), '",', |
|
| 121 | + '"', str_replace('"', '""', $row->gedcom_name), '"', |
|
| 122 | + "\n"; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - return; |
|
| 126 | - case 'load_json': |
|
| 127 | - $start = Filter::getInteger('start'); |
|
| 128 | - $length = Filter::getInteger('length'); |
|
| 129 | - $order = Filter::getArray('order'); |
|
| 130 | - |
|
| 131 | - if ($order) { |
|
| 132 | - $order_by = " ORDER BY "; |
|
| 133 | - foreach ($order as $key => $value) { |
|
| 134 | - if ($key > 0) { |
|
| 135 | - $order_by .= ','; |
|
| 136 | - } |
|
| 137 | - // Datatables numbers columns 0, 1, 2 |
|
| 138 | - // MySQL numbers columns 1, 2, 3 |
|
| 139 | - switch ($value['dir']) { |
|
| 125 | + return; |
|
| 126 | + case 'load_json': |
|
| 127 | + $start = Filter::getInteger('start'); |
|
| 128 | + $length = Filter::getInteger('length'); |
|
| 129 | + $order = Filter::getArray('order'); |
|
| 130 | + |
|
| 131 | + if ($order) { |
|
| 132 | + $order_by = " ORDER BY "; |
|
| 133 | + foreach ($order as $key => $value) { |
|
| 134 | + if ($key > 0) { |
|
| 135 | + $order_by .= ','; |
|
| 136 | + } |
|
| 137 | + // Datatables numbers columns 0, 1, 2 |
|
| 138 | + // MySQL numbers columns 1, 2, 3 |
|
| 139 | + switch ($value['dir']) { |
|
| 140 | 140 | case 'asc': |
| 141 | 141 | $order_by .= (1 + $value['column']) . " ASC "; |
| 142 | 142 | break; |
| 143 | 143 | case 'desc': |
| 144 | 144 | $order_by .= (1 + $value['column']) . " DESC "; |
| 145 | 145 | break; |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | } |
| 148 | 148 | } else { |
| 149 | 149 | $order_by = " ORDER BY 1 ASC"; |
@@ -217,7 +217,7 @@ |
||
| 217 | 217 | $father = $family->getHusband(); |
| 218 | 218 | $mother = $family->getWife(); |
| 219 | 219 | $html .= $this->getHTML($father) . |
| 220 | - $this->getHTML($mother); |
|
| 220 | + $this->getHTML($mother); |
|
| 221 | 221 | |
| 222 | 222 | // Can only have a step parent if one & only one parent found at this point |
| 223 | 223 | if ($father instanceof Individual xor $mother instanceof Individual) { |
@@ -199,7 +199,7 @@ |
||
| 199 | 199 | '<a class="sb_desc_indi" href="#"><i class="plusminus icon-minus"></i>' . $spouse_name . $marr . '</a>' . |
| 200 | 200 | $spouse_link . |
| 201 | 201 | '<a href="' . $family->getHtmlUrl() . '" class="icon-button_family"></a>' . |
| 202 | - '<div>' . $this->loadChildren($family, $generations) . '</div>' . |
|
| 202 | + '<div>' . $this->loadChildren($family, $generations) . '</div>' . |
|
| 203 | 203 | '</li>'; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -759,7 +759,7 @@ |
||
| 759 | 759 | new JewishDate($jd), |
| 760 | 760 | new HijriDate($jd), |
| 761 | 761 | new JalaliDate($jd), |
| 762 | - ) as $anniv) { |
|
| 762 | + ) as $anniv) { |
|
| 763 | 763 | // Build a SQL where clause to match anniversaries in the appropriate calendar. |
| 764 | 764 | $ind_sql = |
| 765 | 765 | "SELECT DISTINCT i_id AS xref, i_gedcom AS gedcom, d_type, d_day, d_month, d_year, d_fact" . |
@@ -137,25 +137,25 @@ |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | switch (Filter::get('action')) { |
| 140 | - case 'site': |
|
| 141 | - $controller->setPageTitle(I18N::translate('Website preferences')); |
|
| 142 | - break; |
|
| 143 | - case 'email': |
|
| 144 | - $controller->setPageTitle(I18N::translate('Sending email')); |
|
| 145 | - break; |
|
| 146 | - case 'login': |
|
| 147 | - $controller->setPageTitle(I18N::translate('Sign-in and registration')); |
|
| 148 | - break; |
|
| 149 | - case 'tracking': |
|
| 150 | - $controller->setPageTitle(/* I18N: e.g. http://www.google.com/analytics */ I18N::translate('Tracking and analytics')); |
|
| 151 | - break; |
|
| 152 | - case 'languages': |
|
| 153 | - $controller->setPageTitle(I18N::translate('Languages')); |
|
| 154 | - break; |
|
| 155 | - default: |
|
| 156 | - header('Location: ' . WT_BASE_URL . 'admin.php'); |
|
| 157 | - |
|
| 158 | - return; |
|
| 140 | + case 'site': |
|
| 141 | + $controller->setPageTitle(I18N::translate('Website preferences')); |
|
| 142 | + break; |
|
| 143 | + case 'email': |
|
| 144 | + $controller->setPageTitle(I18N::translate('Sending email')); |
|
| 145 | + break; |
|
| 146 | + case 'login': |
|
| 147 | + $controller->setPageTitle(I18N::translate('Sign-in and registration')); |
|
| 148 | + break; |
|
| 149 | + case 'tracking': |
|
| 150 | + $controller->setPageTitle(/* I18N: e.g. http://www.google.com/analytics */ I18N::translate('Tracking and analytics')); |
|
| 151 | + break; |
|
| 152 | + case 'languages': |
|
| 153 | + $controller->setPageTitle(I18N::translate('Languages')); |
|
| 154 | + break; |
|
| 155 | + default: |
|
| 156 | + header('Location: ' . WT_BASE_URL . 'admin.php'); |
|
| 157 | + |
|
| 158 | + return; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | $controller->pageHeader(); |
@@ -129,46 +129,46 @@ |
||
| 129 | 129 | return; |
| 130 | 130 | } |
| 131 | 131 | switch ($controller->chart_style) { |
| 132 | - case 0: |
|
| 133 | - // List |
|
| 134 | - echo '<ul id="ancestry_chart" class="chart_common">'; |
|
| 135 | - $controller->printChildAscendancy($controller->root, 1, $controller->generations - 1); |
|
| 136 | - echo '</ul>'; |
|
| 137 | - echo '<br>'; |
|
| 138 | - break; |
|
| 139 | - case 1: |
|
| 140 | - echo '<div id="ancestry_booklet">'; |
|
| 141 | - // Booklet |
|
| 142 | - // first page : show indi facts |
|
| 143 | - FunctionsPrint::printPedigreePerson($controller->root, $controller->showFull()); |
|
| 144 | - // process the tree |
|
| 145 | - $ancestors = $controller->sosaAncestors($controller->generations - 1); |
|
| 146 | - $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders |
|
| 132 | + case 0: |
|
| 133 | + // List |
|
| 134 | + echo '<ul id="ancestry_chart" class="chart_common">'; |
|
| 135 | + $controller->printChildAscendancy($controller->root, 1, $controller->generations - 1); |
|
| 136 | + echo '</ul>'; |
|
| 137 | + echo '<br>'; |
|
| 138 | + break; |
|
| 139 | + case 1: |
|
| 140 | + echo '<div id="ancestry_booklet">'; |
|
| 141 | + // Booklet |
|
| 142 | + // first page : show indi facts |
|
| 143 | + FunctionsPrint::printPedigreePerson($controller->root, $controller->showFull()); |
|
| 144 | + // process the tree |
|
| 145 | + $ancestors = $controller->sosaAncestors($controller->generations - 1); |
|
| 146 | + $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders |
|
| 147 | 147 | |
| 148 | - foreach ($ancestors as $sosa => $individual) { |
|
| 149 | - foreach ($individual->getChildFamilies() as $family) { |
|
| 150 | - FunctionsCharts::printSosaFamily($family->getXref(), $individual->getXref(), $sosa, '', '', '', $controller->show_cousins, $controller->showFull()); |
|
| 148 | + foreach ($ancestors as $sosa => $individual) { |
|
| 149 | + foreach ($individual->getChildFamilies() as $family) { |
|
| 150 | + FunctionsCharts::printSosaFamily($family->getXref(), $individual->getXref(), $sosa, '', '', '', $controller->show_cousins, $controller->showFull()); |
|
| 151 | + } |
|
| 151 | 152 | } |
| 152 | - } |
|
| 153 | - echo '</div>'; |
|
| 154 | - break; |
|
| 155 | - case 2: |
|
| 156 | - // Individual list |
|
| 157 | - $ancestors = $controller->sosaAncestors($controller->generations); |
|
| 158 | - $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders |
|
| 159 | - echo '<div id="ancestry-list">', FunctionsPrintLists::individualTable($ancestors, 'sosa'), '</div>'; |
|
| 160 | - break; |
|
| 161 | - case 3: |
|
| 162 | - // Family list |
|
| 163 | - $ancestors = $controller->sosaAncestors($controller->generations - 1); |
|
| 164 | - $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders |
|
| 165 | - $families = array(); |
|
| 166 | - foreach ($ancestors as $individual) { |
|
| 167 | - foreach ($individual->getChildFamilies() as $family) { |
|
| 168 | - $families[$family->getXref()] = $family; |
|
| 153 | + echo '</div>'; |
|
| 154 | + break; |
|
| 155 | + case 2: |
|
| 156 | + // Individual list |
|
| 157 | + $ancestors = $controller->sosaAncestors($controller->generations); |
|
| 158 | + $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders |
|
| 159 | + echo '<div id="ancestry-list">', FunctionsPrintLists::individualTable($ancestors, 'sosa'), '</div>'; |
|
| 160 | + break; |
|
| 161 | + case 3: |
|
| 162 | + // Family list |
|
| 163 | + $ancestors = $controller->sosaAncestors($controller->generations - 1); |
|
| 164 | + $ancestors = array_filter($ancestors); // The SOSA array includes empty placeholders |
|
| 165 | + $families = array(); |
|
| 166 | + foreach ($ancestors as $individual) { |
|
| 167 | + foreach ($individual->getChildFamilies() as $family) { |
|
| 168 | + $families[$family->getXref()] = $family; |
|
| 169 | + } |
|
| 169 | 170 | } |
| 170 | - } |
|
| 171 | - echo '<div id="ancestry-list">', FunctionsPrintLists::familyTable($families), '</div>'; |
|
| 172 | - break; |
|
| 171 | + echo '<div id="ancestry-list">', FunctionsPrintLists::familyTable($families), '</div>'; |
|
| 172 | + break; |
|
| 173 | 173 | } |
| 174 | 174 | echo '</div>'; |
@@ -38,34 +38,34 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | switch (Filter::post('action')) { |
| 41 | - case 'accept-changes': |
|
| 42 | - // Accept all the pending changes for a record |
|
| 43 | - $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
| 44 | - if ($record && Auth::isModerator($record->getTree()) && $record->canShow() && $record->canEdit()) { |
|
| 45 | - if ($record->isPendingDeletion()) { |
|
| 46 | - FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */ |
|
| 47 | - I18N::translate('“%s” has been deleted.', $record->getFullName())); |
|
| 41 | + case 'accept-changes': |
|
| 42 | + // Accept all the pending changes for a record |
|
| 43 | + $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
| 44 | + if ($record && Auth::isModerator($record->getTree()) && $record->canShow() && $record->canEdit()) { |
|
| 45 | + if ($record->isPendingDeletion()) { |
|
| 46 | + FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */ |
|
| 47 | + I18N::translate('“%s” has been deleted.', $record->getFullName())); |
|
| 48 | + } else { |
|
| 49 | + FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */ |
|
| 50 | + I18N::translate('The changes to “%s” have been accepted.', $record->getFullName())); |
|
| 51 | + } |
|
| 52 | + FunctionsImport::acceptAllChanges($record->getXref(), $record->getTree()->getTreeId()); |
|
| 48 | 53 | } else { |
| 49 | - FlashMessages::addMessage(/* I18N: %s is the name of a genealogy record */ |
|
| 50 | - I18N::translate('The changes to “%s” have been accepted.', $record->getFullName())); |
|
| 54 | + http_response_code(406); |
|
| 51 | 55 | } |
| 52 | - FunctionsImport::acceptAllChanges($record->getXref(), $record->getTree()->getTreeId()); |
|
| 53 | - } else { |
|
| 54 | - http_response_code(406); |
|
| 55 | - } |
|
| 56 | - break; |
|
| 56 | + break; |
|
| 57 | 57 | |
| 58 | - case 'copy-fact': |
|
| 59 | - // Copy a fact to the clipboard |
|
| 60 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 61 | - $fact_id = Filter::post('fact_id'); |
|
| 58 | + case 'copy-fact': |
|
| 59 | + // Copy a fact to the clipboard |
|
| 60 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 61 | + $fact_id = Filter::post('fact_id'); |
|
| 62 | 62 | |
| 63 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 63 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 64 | 64 | |
| 65 | - if ($record && $record->canEdit()) { |
|
| 66 | - foreach ($record->getFacts() as $fact) { |
|
| 67 | - if ($fact->getFactId() == $fact_id) { |
|
| 68 | - switch ($fact->getTag()) { |
|
| 65 | + if ($record && $record->canEdit()) { |
|
| 66 | + foreach ($record->getFacts() as $fact) { |
|
| 67 | + if ($fact->getFactId() == $fact_id) { |
|
| 68 | + switch ($fact->getTag()) { |
|
| 69 | 69 | case 'NOTE': |
| 70 | 70 | case 'SOUR': |
| 71 | 71 | case 'OBJE': |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | default: |
| 75 | 75 | $type = $record::RECORD_TYPE; // paste only to the same record type |
| 76 | 76 | break; |
| 77 | - } |
|
| 77 | + } |
|
| 78 | 78 | $clipboard = Session::get('clipboard'); |
| 79 | 79 | if (!is_array($clipboard)) { |
| 80 | 80 | $clipboard = array(); |
@@ -96,158 +96,158 @@ discard block |
||
| 96 | 96 | } |
| 97 | 97 | break; |
| 98 | 98 | |
| 99 | - case 'paste-fact': |
|
| 100 | - // Paste a fact from the clipboard |
|
| 101 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 102 | - $fact_id = Filter::post('fact_id'); |
|
| 103 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 104 | - $clipboard = Session::get('clipboard'); |
|
| 99 | + case 'paste-fact': |
|
| 100 | + // Paste a fact from the clipboard |
|
| 101 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 102 | + $fact_id = Filter::post('fact_id'); |
|
| 103 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 104 | + $clipboard = Session::get('clipboard'); |
|
| 105 | 105 | |
| 106 | - if ($record && $record->canEdit() && isset($clipboard[$fact_id])) { |
|
| 107 | - $record->createFact($clipboard[$fact_id]['factrec'], true); |
|
| 108 | - } |
|
| 109 | - break; |
|
| 110 | - |
|
| 111 | - case 'delete-fact': |
|
| 112 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 113 | - $fact_id = Filter::post('fact_id'); |
|
| 114 | - |
|
| 115 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 116 | - if ($record && $record->canShow() && $record->canEdit()) { |
|
| 117 | - foreach ($record->getFacts() as $fact) { |
|
| 118 | - if ($fact->getFactId() == $fact_id && $fact->canShow() && $fact->canEdit()) { |
|
| 119 | - $record->deleteFact($fact_id, true); |
|
| 120 | - break 2; |
|
| 106 | + if ($record && $record->canEdit() && isset($clipboard[$fact_id])) { |
|
| 107 | + $record->createFact($clipboard[$fact_id]['factrec'], true); |
|
| 108 | + } |
|
| 109 | + break; |
|
| 110 | + |
|
| 111 | + case 'delete-fact': |
|
| 112 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 113 | + $fact_id = Filter::post('fact_id'); |
|
| 114 | + |
|
| 115 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 116 | + if ($record && $record->canShow() && $record->canEdit()) { |
|
| 117 | + foreach ($record->getFacts() as $fact) { |
|
| 118 | + if ($fact->getFactId() == $fact_id && $fact->canShow() && $fact->canEdit()) { |
|
| 119 | + $record->deleteFact($fact_id, true); |
|
| 120 | + break 2; |
|
| 121 | + } |
|
| 121 | 122 | } |
| 122 | 123 | } |
| 123 | - } |
|
| 124 | - |
|
| 125 | - // Can’t find the record/fact, or don’t have permission to delete it. |
|
| 126 | - http_response_code(406); |
|
| 127 | - break; |
|
| 128 | 124 | |
| 129 | - case 'delete-record': |
|
| 130 | - $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
| 131 | - if ($record && Auth::isEditor($record->getTree()) && $record->canShow() && $record->canEdit()) { |
|
| 132 | - // Delete links to this record |
|
| 133 | - foreach (FunctionsDb::fetchAllLinks($record->getXref(), $record->getTree()->getTreeId()) as $xref) { |
|
| 134 | - $linker = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 135 | - $old_gedcom = $linker->getGedcom(); |
|
| 136 | - $new_gedcom = FunctionsEdit::removeLinks($old_gedcom, $record->getXref()); |
|
| 137 | - // FunctionsDb::fetch_all_links() does not take account of pending changes. The links (or even the |
|
| 138 | - // record itself) may have already been deleted. |
|
| 139 | - if ($old_gedcom !== $new_gedcom) { |
|
| 140 | - // If we have removed a link from a family to an individual, and it has only one member |
|
| 141 | - if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) { |
|
| 142 | - // Delete the family |
|
| 143 | - $family = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 144 | - FlashMessages::addMessage(/* I18N: %s is the name of a family group, e.g. “Husband name + Wife name” */ I18N::translate('The family “%s” has been deleted because it only has one member.', $family->getFullName())); |
|
| 145 | - $family->deleteRecord(); |
|
| 146 | - // Delete any remaining link to this family |
|
| 147 | - if ($match) { |
|
| 148 | - $relict = GedcomRecord::getInstance($match[2][0], $WT_TREE); |
|
| 149 | - $new_gedcom = $relict->getGedcom(); |
|
| 150 | - $new_gedcom = FunctionsEdit::removeLinks($new_gedcom, $linker->getXref()); |
|
| 151 | - $relict->updateRecord($new_gedcom, false); |
|
| 152 | - FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $relict->getFullName(), $family->getFullName())); |
|
| 125 | + // Can’t find the record/fact, or don’t have permission to delete it. |
|
| 126 | + http_response_code(406); |
|
| 127 | + break; |
|
| 128 | + |
|
| 129 | + case 'delete-record': |
|
| 130 | + $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
| 131 | + if ($record && Auth::isEditor($record->getTree()) && $record->canShow() && $record->canEdit()) { |
|
| 132 | + // Delete links to this record |
|
| 133 | + foreach (FunctionsDb::fetchAllLinks($record->getXref(), $record->getTree()->getTreeId()) as $xref) { |
|
| 134 | + $linker = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 135 | + $old_gedcom = $linker->getGedcom(); |
|
| 136 | + $new_gedcom = FunctionsEdit::removeLinks($old_gedcom, $record->getXref()); |
|
| 137 | + // FunctionsDb::fetch_all_links() does not take account of pending changes. The links (or even the |
|
| 138 | + // record itself) may have already been deleted. |
|
| 139 | + if ($old_gedcom !== $new_gedcom) { |
|
| 140 | + // If we have removed a link from a family to an individual, and it has only one member |
|
| 141 | + if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) { |
|
| 142 | + // Delete the family |
|
| 143 | + $family = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 144 | + FlashMessages::addMessage(/* I18N: %s is the name of a family group, e.g. “Husband name + Wife name” */ I18N::translate('The family “%s” has been deleted because it only has one member.', $family->getFullName())); |
|
| 145 | + $family->deleteRecord(); |
|
| 146 | + // Delete any remaining link to this family |
|
| 147 | + if ($match) { |
|
| 148 | + $relict = GedcomRecord::getInstance($match[2][0], $WT_TREE); |
|
| 149 | + $new_gedcom = $relict->getGedcom(); |
|
| 150 | + $new_gedcom = FunctionsEdit::removeLinks($new_gedcom, $linker->getXref()); |
|
| 151 | + $relict->updateRecord($new_gedcom, false); |
|
| 152 | + FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $relict->getFullName(), $family->getFullName())); |
|
| 153 | + } |
|
| 154 | + } else { |
|
| 155 | + // Remove links from $linker to $record |
|
| 156 | + FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $linker->getFullName(), $record->getFullName())); |
|
| 157 | + $linker->updateRecord($new_gedcom, false); |
|
| 153 | 158 | } |
| 154 | - } else { |
|
| 155 | - // Remove links from $linker to $record |
|
| 156 | - FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $linker->getFullName(), $record->getFullName())); |
|
| 157 | - $linker->updateRecord($new_gedcom, false); |
|
| 158 | 159 | } |
| 159 | 160 | } |
| 161 | + // Delete the record itself |
|
| 162 | + $record->deleteRecord(); |
|
| 163 | + } else { |
|
| 164 | + http_response_code(406); |
|
| 160 | 165 | } |
| 161 | - // Delete the record itself |
|
| 162 | - $record->deleteRecord(); |
|
| 163 | - } else { |
|
| 164 | - http_response_code(406); |
|
| 165 | - } |
|
| 166 | - break; |
|
| 167 | - |
|
| 168 | - case 'delete-user': |
|
| 169 | - $user = User::find(Filter::postInteger('user_id')); |
|
| 166 | + break; |
|
| 170 | 167 | |
| 171 | - if ($user && Auth::isAdmin() && Auth::user() !== $user) { |
|
| 172 | - Log::addAuthenticationLog('Deleted user: ' . $user->getUserName()); |
|
| 173 | - $user->delete(); |
|
| 174 | - } |
|
| 175 | - break; |
|
| 168 | + case 'delete-user': |
|
| 169 | + $user = User::find(Filter::postInteger('user_id')); |
|
| 176 | 170 | |
| 177 | - case 'language': |
|
| 178 | - // Change the current language |
|
| 179 | - $language = Filter::post('language'); |
|
| 180 | - try { |
|
| 181 | - I18N::init($language); |
|
| 182 | - Session::put('locale', $language); |
|
| 183 | - // Remember our selection |
|
| 184 | - Auth::user()->setPreference('language', $language); |
|
| 185 | - } catch (\Exception $ex) { |
|
| 186 | - // Request for a non-existant language. |
|
| 187 | - http_response_code(406); |
|
| 188 | - } |
|
| 189 | - break; |
|
| 190 | - |
|
| 191 | - case 'masquerade': |
|
| 192 | - $user = User::find(Filter::postInteger('user_id')); |
|
| 171 | + if ($user && Auth::isAdmin() && Auth::user() !== $user) { |
|
| 172 | + Log::addAuthenticationLog('Deleted user: ' . $user->getUserName()); |
|
| 173 | + $user->delete(); |
|
| 174 | + } |
|
| 175 | + break; |
|
| 176 | + |
|
| 177 | + case 'language': |
|
| 178 | + // Change the current language |
|
| 179 | + $language = Filter::post('language'); |
|
| 180 | + try { |
|
| 181 | + I18N::init($language); |
|
| 182 | + Session::put('locale', $language); |
|
| 183 | + // Remember our selection |
|
| 184 | + Auth::user()->setPreference('language', $language); |
|
| 185 | + } catch (\Exception $ex) { |
|
| 186 | + // Request for a non-existant language. |
|
| 187 | + http_response_code(406); |
|
| 188 | + } |
|
| 189 | + break; |
|
| 193 | 190 | |
| 194 | - if ($user && Auth::isAdmin() && Auth::user() !== $user) { |
|
| 195 | - Log::addAuthenticationLog('Masquerade as user: ' . $user->getUserName()); |
|
| 196 | - Auth::login($user); |
|
| 197 | - Session::put('masquerade', '1'); |
|
| 198 | - } else { |
|
| 199 | - http_response_code(406); |
|
| 200 | - } |
|
| 201 | - break; |
|
| 191 | + case 'masquerade': |
|
| 192 | + $user = User::find(Filter::postInteger('user_id')); |
|
| 202 | 193 | |
| 203 | - case 'unlink-media': |
|
| 204 | - // Remove links from an individual and their spouse-family records to a media object. |
|
| 205 | - // Used by the "unlink" option on the album (lightbox) tab. |
|
| 206 | - $source = Individual::getInstance(Filter::post('source', WT_REGEX_XREF), $WT_TREE); |
|
| 207 | - $target = Filter::post('target', WT_REGEX_XREF); |
|
| 208 | - if ($source && $source->canShow() && $source->canEdit() && $target) { |
|
| 209 | - // Consider the individual and their spouse-family records |
|
| 210 | - $sources = $source->getSpouseFamilies(); |
|
| 211 | - $sources[] = $source; |
|
| 212 | - foreach ($sources as $source) { |
|
| 213 | - foreach ($source->getFacts() as $fact) { |
|
| 214 | - if (!$fact->isPendingDeletion()) { |
|
| 215 | - if ($fact->getValue() == '@' . $target . '@') { |
|
| 216 | - // Level 1 links |
|
| 217 | - $source->deleteFact($fact->getFactId(), true); |
|
| 218 | - } elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) { |
|
| 219 | - // Level 2-3 links |
|
| 220 | - $source->updateFact($fact->getFactId(), preg_replace(array('/\n2 OBJE @' . $target . '@(\n[3-9].*)*/', '/\n3 OBJE @' . $target . '@(\n[4-9].*)*/'), '', $fact->getGedcom()), true); |
|
| 194 | + if ($user && Auth::isAdmin() && Auth::user() !== $user) { |
|
| 195 | + Log::addAuthenticationLog('Masquerade as user: ' . $user->getUserName()); |
|
| 196 | + Auth::login($user); |
|
| 197 | + Session::put('masquerade', '1'); |
|
| 198 | + } else { |
|
| 199 | + http_response_code(406); |
|
| 200 | + } |
|
| 201 | + break; |
|
| 202 | + |
|
| 203 | + case 'unlink-media': |
|
| 204 | + // Remove links from an individual and their spouse-family records to a media object. |
|
| 205 | + // Used by the "unlink" option on the album (lightbox) tab. |
|
| 206 | + $source = Individual::getInstance(Filter::post('source', WT_REGEX_XREF), $WT_TREE); |
|
| 207 | + $target = Filter::post('target', WT_REGEX_XREF); |
|
| 208 | + if ($source && $source->canShow() && $source->canEdit() && $target) { |
|
| 209 | + // Consider the individual and their spouse-family records |
|
| 210 | + $sources = $source->getSpouseFamilies(); |
|
| 211 | + $sources[] = $source; |
|
| 212 | + foreach ($sources as $source) { |
|
| 213 | + foreach ($source->getFacts() as $fact) { |
|
| 214 | + if (!$fact->isPendingDeletion()) { |
|
| 215 | + if ($fact->getValue() == '@' . $target . '@') { |
|
| 216 | + // Level 1 links |
|
| 217 | + $source->deleteFact($fact->getFactId(), true); |
|
| 218 | + } elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) { |
|
| 219 | + // Level 2-3 links |
|
| 220 | + $source->updateFact($fact->getFactId(), preg_replace(array('/\n2 OBJE @' . $target . '@(\n[3-9].*)*/', '/\n3 OBJE @' . $target . '@(\n[4-9].*)*/'), '', $fact->getGedcom()), true); |
|
| 221 | + } |
|
| 221 | 222 | } |
| 222 | 223 | } |
| 223 | 224 | } |
| 225 | + } else { |
|
| 226 | + http_response_code(406); |
|
| 224 | 227 | } |
| 225 | - } else { |
|
| 226 | - http_response_code(406); |
|
| 227 | - } |
|
| 228 | - break; |
|
| 229 | - |
|
| 230 | - case 'reject-changes': |
|
| 231 | - // Reject all the pending changes for a record |
|
| 232 | - $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
| 233 | - if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) { |
|
| 234 | - FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('The changes to “%s” have been rejected.', $record->getFullName())); |
|
| 235 | - FunctionsImport::rejectAllChanges($record); |
|
| 236 | - } else { |
|
| 237 | - http_response_code(406); |
|
| 238 | - } |
|
| 239 | - break; |
|
| 240 | - |
|
| 241 | - case 'theme': |
|
| 242 | - // Change the current theme |
|
| 243 | - $theme = Filter::post('theme'); |
|
| 244 | - if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) { |
|
| 245 | - Session::put('theme_id', $theme); |
|
| 246 | - // Remember our selection |
|
| 247 | - Auth::user()->setPreference('theme', $theme); |
|
| 248 | - } else { |
|
| 249 | - // Request for a non-existant theme. |
|
| 250 | - http_response_code(406); |
|
| 251 | - } |
|
| 252 | - break; |
|
| 228 | + break; |
|
| 229 | + |
|
| 230 | + case 'reject-changes': |
|
| 231 | + // Reject all the pending changes for a record |
|
| 232 | + $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE); |
|
| 233 | + if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) { |
|
| 234 | + FlashMessages::addMessage(/* I18N: %s is the name of an individual, source or other record */ I18N::translate('The changes to “%s” have been rejected.', $record->getFullName())); |
|
| 235 | + FunctionsImport::rejectAllChanges($record); |
|
| 236 | + } else { |
|
| 237 | + http_response_code(406); |
|
| 238 | + } |
|
| 239 | + break; |
|
| 240 | + |
|
| 241 | + case 'theme': |
|
| 242 | + // Change the current theme |
|
| 243 | + $theme = Filter::post('theme'); |
|
| 244 | + if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) { |
|
| 245 | + Session::put('theme_id', $theme); |
|
| 246 | + // Remember our selection |
|
| 247 | + Auth::user()->setPreference('theme', $theme); |
|
| 248 | + } else { |
|
| 249 | + // Request for a non-existant theme. |
|
| 250 | + http_response_code(406); |
|
| 251 | + } |
|
| 252 | + break; |
|
| 253 | 253 | } |
@@ -111,53 +111,53 @@ |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | switch ($action) { |
| 114 | - case 'delete': |
|
| 115 | - $sql_delete = |
|
| 116 | - "DELETE `##change` FROM `##change`" . |
|
| 117 | - " LEFT JOIN `##user` USING (user_id)" . // user may be deleted |
|
| 118 | - " LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted |
|
| 119 | - |
|
| 120 | - Database::prepare($sql_delete . $where)->execute($args); |
|
| 121 | - break; |
|
| 122 | - |
|
| 123 | - case 'export': |
|
| 124 | - header('Content-Type: text/csv'); |
|
| 125 | - header('Content-Disposition: attachment; filename="webtrees-changes.csv"'); |
|
| 126 | - $rows = Database::prepare($sql_select . $where . ' ORDER BY change_id')->execute($args)->fetchAll(); |
|
| 127 | - foreach ($rows as $row) { |
|
| 128 | - echo |
|
| 129 | - '"', $row->change_time, '",', |
|
| 130 | - '"', $row->status, '",', |
|
| 131 | - '"', $row->xref, '",', |
|
| 132 | - '"', str_replace('"', '""', $row->old_gedcom), '",', |
|
| 133 | - '"', str_replace('"', '""', $row->new_gedcom), '",', |
|
| 134 | - '"', str_replace('"', '""', $row->user_name), '",', |
|
| 135 | - '"', str_replace('"', '""', $row->gedcom_name), '"', |
|
| 136 | - "\n"; |
|
| 137 | - } |
|
| 114 | + case 'delete': |
|
| 115 | + $sql_delete = |
|
| 116 | + "DELETE `##change` FROM `##change`" . |
|
| 117 | + " LEFT JOIN `##user` USING (user_id)" . // user may be deleted |
|
| 118 | + " LEFT JOIN `##gedcom` USING (gedcom_id)"; // gedcom may be deleted |
|
| 119 | + |
|
| 120 | + Database::prepare($sql_delete . $where)->execute($args); |
|
| 121 | + break; |
|
| 122 | + |
|
| 123 | + case 'export': |
|
| 124 | + header('Content-Type: text/csv'); |
|
| 125 | + header('Content-Disposition: attachment; filename="webtrees-changes.csv"'); |
|
| 126 | + $rows = Database::prepare($sql_select . $where . ' ORDER BY change_id')->execute($args)->fetchAll(); |
|
| 127 | + foreach ($rows as $row) { |
|
| 128 | + echo |
|
| 129 | + '"', $row->change_time, '",', |
|
| 130 | + '"', $row->status, '",', |
|
| 131 | + '"', $row->xref, '",', |
|
| 132 | + '"', str_replace('"', '""', $row->old_gedcom), '",', |
|
| 133 | + '"', str_replace('"', '""', $row->new_gedcom), '",', |
|
| 134 | + '"', str_replace('"', '""', $row->user_name), '",', |
|
| 135 | + '"', str_replace('"', '""', $row->gedcom_name), '"', |
|
| 136 | + "\n"; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - return; |
|
| 140 | - case 'load_json': |
|
| 141 | - $start = Filter::getInteger('start'); |
|
| 142 | - $length = Filter::getInteger('length'); |
|
| 143 | - $order = Filter::getArray('order'); |
|
| 144 | - |
|
| 145 | - if ($order) { |
|
| 146 | - $order_by = " ORDER BY "; |
|
| 147 | - foreach ($order as $key => $value) { |
|
| 148 | - if ($key > 0) { |
|
| 149 | - $order_by .= ','; |
|
| 150 | - } |
|
| 151 | - // Datatables numbers columns 0, 1, 2 |
|
| 152 | - // MySQL numbers columns 1, 2, 3 |
|
| 153 | - switch ($value['dir']) { |
|
| 139 | + return; |
|
| 140 | + case 'load_json': |
|
| 141 | + $start = Filter::getInteger('start'); |
|
| 142 | + $length = Filter::getInteger('length'); |
|
| 143 | + $order = Filter::getArray('order'); |
|
| 144 | + |
|
| 145 | + if ($order) { |
|
| 146 | + $order_by = " ORDER BY "; |
|
| 147 | + foreach ($order as $key => $value) { |
|
| 148 | + if ($key > 0) { |
|
| 149 | + $order_by .= ','; |
|
| 150 | + } |
|
| 151 | + // Datatables numbers columns 0, 1, 2 |
|
| 152 | + // MySQL numbers columns 1, 2, 3 |
|
| 153 | + switch ($value['dir']) { |
|
| 154 | 154 | case 'asc': |
| 155 | 155 | $order_by .= (1 + $value['column']) . " ASC "; |
| 156 | 156 | break; |
| 157 | 157 | case 'desc': |
| 158 | 158 | $order_by .= (1 + $value['column']) . " DESC "; |
| 159 | 159 | break; |
| 160 | - } |
|
| 160 | + } |
|
| 161 | 161 | } |
| 162 | 162 | } else { |
| 163 | 163 | $order_by = " ORDER BY 1 DESC"; |
@@ -41,22 +41,22 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | switch ($action) { |
| 43 | 43 | //////////////////////////////////////////////////////////////////////////////// |
| 44 | - case 'editraw': |
|
| 45 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 44 | + case 'editraw': |
|
| 45 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 46 | 46 | |
| 47 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 48 | - check_record_access($record); |
|
| 47 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 48 | + check_record_access($record); |
|
| 49 | 49 | |
| 50 | - $controller |
|
| 51 | - ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM')) |
|
| 52 | - ->pageHeader() |
|
| 53 | - ->addInlineJavascript('jQuery("#raw-gedcom-list").sortable({opacity: 0.7, cursor: "move", axis: "y"});'); |
|
| 50 | + $controller |
|
| 51 | + ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM')) |
|
| 52 | + ->pageHeader() |
|
| 53 | + ->addInlineJavascript('jQuery("#raw-gedcom-list").sortable({opacity: 0.7, cursor: "move", axis: "y"});'); |
|
| 54 | 54 | |
| 55 | - ?> |
|
| 55 | + ?> |
|
| 56 | 56 | <div id="edit_interface-page"> |
| 57 | 57 | <h2> |
| 58 | 58 | <?php echo $controller->getPageTitle(); ?> |
| 59 | - <?php echo FunctionsPrint::helpLink('edit_edit_raw'); ?> |
|
| 59 | + <?php echo FunctionsPrint::helpLink('edit_edit_raw'); ?> |
|
| 60 | 60 | </h2> |
| 61 | 61 | <pre> <?php echo '0 @' . $record->getXref() . '@ ' . $record::RECORD_TYPE; ?></pre> |
| 62 | 62 | <form method="post" action="edit_interface.php"> |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | <input type="hidden" name="action" value="updateraw"> |
| 65 | 65 | <input type="hidden" name="xref" value="<?php echo $xref; ?>"> |
| 66 | 66 | <?php echo Filter::getCsrf(); ?> |
| 67 | - <ul id="raw-gedcom-list"> |
|
| 67 | + <ul id="raw-gedcom-list"> |
|
| 68 | 68 | <?php foreach ($record->getFacts() as $fact) { ?> |
| 69 | - <?php if (!$fact->isPendingDeletion()) { ?> |
|
| 69 | + <?php if (!$fact->isPendingDeletion()) { ?> |
|
| 70 | 70 | <li> |
| 71 | 71 | <div style="cursor:move;"> |
| 72 | 72 | <?php echo $fact->summary(); ?> |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | <textarea name="fact[]" dir="ltr" rows="<?php echo preg_match_all('/\n/', $fact->getGedcom(), $dummy_parameter_for_php53); ?>" style="width:100%;"><?php echo Filter::escapeHtml($fact->getGedcom()); ?></textarea> |
| 76 | 76 | </li> |
| 77 | 77 | <?php } ?> |
| 78 | - <?php } ?> |
|
| 78 | + <?php } ?> |
|
| 79 | 79 | <li> |
| 80 | 80 | <div style="cursor:move;"> |
| 81 | 81 | <b><i><?php echo I18N::translate('Add a fact'); ?><i></b> |
@@ -91,83 +91,83 @@ discard block |
||
| 91 | 91 | </form> |
| 92 | 92 | </div> |
| 93 | 93 | <?php |
| 94 | - break; |
|
| 94 | + break; |
|
| 95 | 95 | |
| 96 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 97 | - case 'updateraw': |
|
| 98 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 99 | - $facts = Filter::postArray('fact'); |
|
| 100 | - $fact_ids = Filter::postArray('fact_id'); |
|
| 96 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 97 | + case 'updateraw': |
|
| 98 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 99 | + $facts = Filter::postArray('fact'); |
|
| 100 | + $fact_ids = Filter::postArray('fact_id'); |
|
| 101 | 101 | |
| 102 | - if (!Filter::checkCsrf()) { |
|
| 103 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editraw&xref=' . $xref); |
|
| 102 | + if (!Filter::checkCsrf()) { |
|
| 103 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editraw&xref=' . $xref); |
|
| 104 | 104 | |
| 105 | - return; |
|
| 106 | - } |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 109 | - check_record_access($record); |
|
| 108 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 109 | + check_record_access($record); |
|
| 110 | 110 | |
| 111 | - $controller |
|
| 112 | - ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM')) |
|
| 113 | - ->pageHeader(); |
|
| 111 | + $controller |
|
| 112 | + ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM')) |
|
| 113 | + ->pageHeader(); |
|
| 114 | 114 | |
| 115 | - $gedcom = '0 @' . $record->getXref() . '@ ' . $record::RECORD_TYPE; |
|
| 115 | + $gedcom = '0 @' . $record->getXref() . '@ ' . $record::RECORD_TYPE; |
|
| 116 | 116 | |
| 117 | - // Retain any private facts |
|
| 118 | - foreach ($record->getFacts(null, false, Auth::PRIV_HIDE) as $fact) { |
|
| 119 | - if (!in_array($fact->getFactId(), $fact_ids) && !$fact->isPendingDeletion()) { |
|
| 120 | - $gedcom .= "\n" . $fact->getGedcom(); |
|
| 117 | + // Retain any private facts |
|
| 118 | + foreach ($record->getFacts(null, false, Auth::PRIV_HIDE) as $fact) { |
|
| 119 | + if (!in_array($fact->getFactId(), $fact_ids) && !$fact->isPendingDeletion()) { |
|
| 120 | + $gedcom .= "\n" . $fact->getGedcom(); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + // Append the new facts |
|
| 124 | + foreach ($facts as $fact) { |
|
| 125 | + $gedcom .= "\n" . $fact; |
|
| 121 | 126 | } |
| 122 | - } |
|
| 123 | - // Append the new facts |
|
| 124 | - foreach ($facts as $fact) { |
|
| 125 | - $gedcom .= "\n" . $fact; |
|
| 126 | - } |
|
| 127 | 127 | |
| 128 | - // Cleanup the client’s bad editing? |
|
| 129 | - $gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom); // Empty lines |
|
| 130 | - $gedcom = trim($gedcom); // Leading/trailing spaces |
|
| 128 | + // Cleanup the client’s bad editing? |
|
| 129 | + $gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom); // Empty lines |
|
| 130 | + $gedcom = trim($gedcom); // Leading/trailing spaces |
|
| 131 | 131 | |
| 132 | - $record->updateRecord($gedcom, false); |
|
| 132 | + $record->updateRecord($gedcom, false); |
|
| 133 | 133 | |
| 134 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 135 | - break; |
|
| 134 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 135 | + break; |
|
| 136 | 136 | |
| 137 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 138 | - case 'editrawfact': |
|
| 139 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 140 | - $fact_id = Filter::get('fact_id'); |
|
| 141 | - |
|
| 142 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 143 | - check_record_access($record); |
|
| 144 | - |
|
| 145 | - // Find the fact to edit |
|
| 146 | - $edit_fact = null; |
|
| 147 | - foreach ($record->getFacts() as $fact) { |
|
| 148 | - if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
| 149 | - $edit_fact = $fact; |
|
| 150 | - break; |
|
| 137 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 138 | + case 'editrawfact': |
|
| 139 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 140 | + $fact_id = Filter::get('fact_id'); |
|
| 141 | + |
|
| 142 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 143 | + check_record_access($record); |
|
| 144 | + |
|
| 145 | + // Find the fact to edit |
|
| 146 | + $edit_fact = null; |
|
| 147 | + foreach ($record->getFacts() as $fact) { |
|
| 148 | + if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
| 149 | + $edit_fact = $fact; |
|
| 150 | + break; |
|
| 151 | + } |
|
| 151 | 152 | } |
| 152 | - } |
|
| 153 | - if (!$edit_fact) { |
|
| 154 | - $controller |
|
| 155 | - ->pageHeader() |
|
| 156 | - ->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 153 | + if (!$edit_fact) { |
|
| 154 | + $controller |
|
| 155 | + ->pageHeader() |
|
| 156 | + ->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 157 | 157 | |
| 158 | - return; |
|
| 159 | - } |
|
| 158 | + return; |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - $controller |
|
| 162 | - ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM')) |
|
| 163 | - ->pageHeader(); |
|
| 161 | + $controller |
|
| 162 | + ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM')) |
|
| 163 | + ->pageHeader(); |
|
| 164 | 164 | |
| 165 | - ?> |
|
| 165 | + ?> |
|
| 166 | 166 | <div id="edit_interface-page"> |
| 167 | 167 | <h2> |
| 168 | 168 | <?php echo $controller->getPageTitle(); ?> |
| 169 | - <?php echo FunctionsPrint::helpLink('edit_edit_raw'); ?> |
|
| 170 | - <?php FunctionsPrint::printSpecialCharacterLink('gedcom'); ?> |
|
| 169 | + <?php echo FunctionsPrint::helpLink('edit_edit_raw'); ?> |
|
| 170 | + <?php FunctionsPrint::printSpecialCharacterLink('gedcom'); ?> |
|
| 171 | 171 | </h2> |
| 172 | 172 | <form method="post" action="edit_interface.php"> |
| 173 | 173 | <input type="hidden" name="ged" value="<?php echo $WT_TREE->getNameHtml(); ?>"> |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | <input type="hidden" name="xref" value="<?php echo $xref; ?>"> |
| 176 | 176 | <input type="hidden" name="fact_id" value="<?php echo $fact_id; ?>"> |
| 177 | 177 | <?php echo Filter::getCsrf(); ?> |
| 178 | - <textarea name="gedcom" id="gedcom" dir="ltr"><?php echo Filter::escapeHtml($edit_fact->getGedcom()); ?></textarea> |
|
| 178 | + <textarea name="gedcom" id="gedcom" dir="ltr"><?php echo Filter::escapeHtml($edit_fact->getGedcom()); ?></textarea> |
|
| 179 | 179 | <table class="facts_table"> |
| 180 | 180 | <?php echo keep_chan($record); ?> |
| 181 | 181 | </table> |
@@ -186,98 +186,98 @@ discard block |
||
| 186 | 186 | </form> |
| 187 | 187 | </div> |
| 188 | 188 | <?php |
| 189 | - break; |
|
| 189 | + break; |
|
| 190 | 190 | |
| 191 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 192 | - case 'updaterawfact': |
|
| 193 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 194 | - $fact_id = Filter::post('fact_id'); |
|
| 195 | - $gedcom = Filter::post('gedcom'); |
|
| 196 | - $keep_chan = Filter::postBool('keep_chan'); |
|
| 191 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 192 | + case 'updaterawfact': |
|
| 193 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 194 | + $fact_id = Filter::post('fact_id'); |
|
| 195 | + $gedcom = Filter::post('gedcom'); |
|
| 196 | + $keep_chan = Filter::postBool('keep_chan'); |
|
| 197 | 197 | |
| 198 | - if (!Filter::checkCsrf()) { |
|
| 199 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editrawfact&xref=' . $xref . '&fact_id=' . $fact_id); |
|
| 198 | + if (!Filter::checkCsrf()) { |
|
| 199 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editrawfact&xref=' . $xref . '&fact_id=' . $fact_id); |
|
| 200 | 200 | |
| 201 | - return; |
|
| 202 | - } |
|
| 201 | + return; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 205 | - check_record_access($record); |
|
| 204 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 205 | + check_record_access($record); |
|
| 206 | 206 | |
| 207 | - // Find the fact to edit |
|
| 208 | - $edit_fact = null; |
|
| 209 | - foreach ($record->getFacts() as $fact) { |
|
| 210 | - if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
| 211 | - $edit_fact = $fact; |
|
| 212 | - break; |
|
| 207 | + // Find the fact to edit |
|
| 208 | + $edit_fact = null; |
|
| 209 | + foreach ($record->getFacts() as $fact) { |
|
| 210 | + if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
| 211 | + $edit_fact = $fact; |
|
| 212 | + break; |
|
| 213 | + } |
|
| 213 | 214 | } |
| 214 | - } |
|
| 215 | - if (!$edit_fact) { |
|
| 215 | + if (!$edit_fact) { |
|
| 216 | + $controller |
|
| 217 | + ->pageHeader() |
|
| 218 | + ->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 219 | + |
|
| 220 | + return; |
|
| 221 | + } |
|
| 222 | + |
|
| 216 | 223 | $controller |
| 217 | - ->pageHeader() |
|
| 218 | - ->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 224 | + ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM')) |
|
| 225 | + ->pageHeader(); |
|
| 219 | 226 | |
| 220 | - return; |
|
| 221 | - } |
|
| 227 | + // Cleanup the client’s bad editing? |
|
| 228 | + $gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom); // Empty lines |
|
| 229 | + $gedcom = trim($gedcom); // Leading/trailing spaces |
|
| 222 | 230 | |
| 223 | - $controller |
|
| 224 | - ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit the raw GEDCOM')) |
|
| 225 | - ->pageHeader(); |
|
| 231 | + $record->updateFact($fact_id, $gedcom, !$keep_chan); |
|
| 226 | 232 | |
| 227 | - // Cleanup the client’s bad editing? |
|
| 228 | - $gedcom = preg_replace('/[\r\n]+/', "\n", $gedcom); // Empty lines |
|
| 229 | - $gedcom = trim($gedcom); // Leading/trailing spaces |
|
| 233 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 234 | + break; |
|
| 230 | 235 | |
| 231 | - $record->updateFact($fact_id, $gedcom, !$keep_chan); |
|
| 236 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 237 | + case 'edit': |
|
| 238 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 239 | + $fact_id = Filter::get('fact_id'); |
|
| 232 | 240 | |
| 233 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 234 | - break; |
|
| 241 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 242 | + check_record_access($record); |
|
| 235 | 243 | |
| 236 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 237 | - case 'edit': |
|
| 238 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 239 | - $fact_id = Filter::get('fact_id'); |
|
| 240 | - |
|
| 241 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 242 | - check_record_access($record); |
|
| 243 | - |
|
| 244 | - // Find the fact to edit |
|
| 245 | - $edit_fact = null; |
|
| 246 | - foreach ($record->getFacts() as $fact) { |
|
| 247 | - if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
| 248 | - $edit_fact = $fact; |
|
| 249 | - break; |
|
| 244 | + // Find the fact to edit |
|
| 245 | + $edit_fact = null; |
|
| 246 | + foreach ($record->getFacts() as $fact) { |
|
| 247 | + if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
| 248 | + $edit_fact = $fact; |
|
| 249 | + break; |
|
| 250 | + } |
|
| 250 | 251 | } |
| 251 | - } |
|
| 252 | - if (!$edit_fact) { |
|
| 253 | - $controller |
|
| 254 | - ->pageHeader() |
|
| 255 | - ->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 252 | + if (!$edit_fact) { |
|
| 253 | + $controller |
|
| 254 | + ->pageHeader() |
|
| 255 | + ->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 256 | 256 | |
| 257 | - return; |
|
| 258 | - } |
|
| 257 | + return; |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - $controller |
|
| 261 | - ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit')) |
|
| 262 | - ->pageHeader(); |
|
| 263 | - |
|
| 264 | - echo '<div id="edit_interface-page">'; |
|
| 265 | - echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
| 266 | - FunctionsPrint::initializeCalendarPopup(); |
|
| 267 | - echo '<form name="editform" method="post" action="edit_interface.php" enctype="multipart/form-data">'; |
|
| 268 | - echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">'; |
|
| 269 | - echo '<input type="hidden" name="action" value="update">'; |
|
| 270 | - echo '<input type="hidden" name="fact_id" value="', $fact_id, '">'; |
|
| 271 | - echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
| 272 | - echo '<input type="hidden" name="prev_action" value="edit">'; |
|
| 273 | - echo Filter::getCsrf(); |
|
| 274 | - echo '<table class="facts_table">'; |
|
| 275 | - FunctionsEdit::createEditForm($edit_fact); |
|
| 276 | - echo keep_chan($record); |
|
| 277 | - echo '</table>'; |
|
| 278 | - |
|
| 279 | - $level1type = $edit_fact->getTag(); |
|
| 280 | - switch ($record::RECORD_TYPE) { |
|
| 260 | + $controller |
|
| 261 | + ->setPageTitle($record->getFullName() . ' - ' . I18N::translate('Edit')) |
|
| 262 | + ->pageHeader(); |
|
| 263 | + |
|
| 264 | + echo '<div id="edit_interface-page">'; |
|
| 265 | + echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
| 266 | + FunctionsPrint::initializeCalendarPopup(); |
|
| 267 | + echo '<form name="editform" method="post" action="edit_interface.php" enctype="multipart/form-data">'; |
|
| 268 | + echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">'; |
|
| 269 | + echo '<input type="hidden" name="action" value="update">'; |
|
| 270 | + echo '<input type="hidden" name="fact_id" value="', $fact_id, '">'; |
|
| 271 | + echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
| 272 | + echo '<input type="hidden" name="prev_action" value="edit">'; |
|
| 273 | + echo Filter::getCsrf(); |
|
| 274 | + echo '<table class="facts_table">'; |
|
| 275 | + FunctionsEdit::createEditForm($edit_fact); |
|
| 276 | + echo keep_chan($record); |
|
| 277 | + echo '</table>'; |
|
| 278 | + |
|
| 279 | + $level1type = $edit_fact->getTag(); |
|
| 280 | + switch ($record::RECORD_TYPE) { |
|
| 281 | 281 | case 'REPO': |
| 282 | 282 | // REPO:NAME facts may take a NOTE (but the REPO record may not). |
| 283 | 283 | if ($level1type === 'NAME') { |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | default: |
| 313 | 313 | // Other types of record do not have these lower-level records |
| 314 | 314 | break; |
| 315 | - } |
|
| 315 | + } |
|
| 316 | 316 | if (Auth::isAdmin() || $WT_TREE->getPreference('SHOW_GEDCOM_RECORD')) { |
| 317 | 317 | echo |
| 318 | 318 | '<br><br><a href="edit_interface.php?action=editrawfact&xref=', $xref, '&fact_id=', $fact_id, '&ged=', $WT_TREE->getNameUrl(), '">', |
@@ -330,57 +330,57 @@ discard block |
||
| 330 | 330 | break; |
| 331 | 331 | |
| 332 | 332 | //////////////////////////////////////////////////////////////////////////////// |
| 333 | - case 'add': |
|
| 334 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 335 | - $fact = Filter::get('fact', WT_REGEX_TAG); |
|
| 333 | + case 'add': |
|
| 334 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 335 | + $fact = Filter::get('fact', WT_REGEX_TAG); |
|
| 336 | 336 | |
| 337 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 338 | - check_record_access($record); |
|
| 337 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 338 | + check_record_access($record); |
|
| 339 | 339 | |
| 340 | - $controller |
|
| 341 | - ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($fact, $record)) |
|
| 342 | - ->pageHeader(); |
|
| 343 | - |
|
| 344 | - $level0type = $record::RECORD_TYPE; |
|
| 345 | - |
|
| 346 | - echo '<div id="edit_interface-page">'; |
|
| 347 | - echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
| 348 | - |
|
| 349 | - FunctionsPrint::initializeCalendarPopup(); |
|
| 350 | - echo '<form name="addform" method="post" action="edit_interface.php" enctype="multipart/form-data">'; |
|
| 351 | - echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">'; |
|
| 352 | - echo '<input type="hidden" name="action" value="update">'; |
|
| 353 | - echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
| 354 | - echo '<input type="hidden" name="prev_action" value="add">'; |
|
| 355 | - echo '<input type="hidden" name="fact_type" value="' . $fact . '">'; |
|
| 356 | - echo Filter::getCsrf(); |
|
| 357 | - echo '<table class="facts_table">'; |
|
| 358 | - |
|
| 359 | - FunctionsEdit::createAddForm($fact); |
|
| 360 | - |
|
| 361 | - echo keep_chan($record); |
|
| 362 | - echo '</table>'; |
|
| 363 | - |
|
| 364 | - // Genealogical facts (e.g. for INDI and FAM records) can have 2 SOUR/NOTE/OBJE/ASSO/RESN ... |
|
| 365 | - if ($level0type === 'INDI' || $level0type === 'FAM') { |
|
| 366 | - // ... but not facts which are simply links to other records |
|
| 367 | - if ($fact !== 'OBJE' && $fact !== 'NOTE' && $fact !== 'SHARED_NOTE' && $fact !== 'REPO' && $fact !== 'SOUR' && $fact !== 'ASSO' && $fact !== 'ALIA') { |
|
| 368 | - FunctionsEdit::printAddLayer('SOUR'); |
|
| 369 | - FunctionsEdit::printAddLayer('OBJE'); |
|
| 370 | - // Don’t add notes to notes! |
|
| 371 | - if ($fact !== 'NOTE') { |
|
| 372 | - FunctionsEdit::printAddLayer('NOTE'); |
|
| 373 | - FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $fact); |
|
| 374 | - } |
|
| 375 | - FunctionsEdit::printAddLayer('ASSO'); |
|
| 376 | - // allow to add godfather and godmother for CHR fact or best man and bridesmaid for MARR fact in one window |
|
| 377 | - if (in_array($fact, Config::twoAssociates())) { |
|
| 378 | - FunctionsEdit::printAddLayer('ASSO2'); |
|
| 340 | + $controller |
|
| 341 | + ->setPageTitle($record->getFullName() . ' - ' . GedcomTag::getLabel($fact, $record)) |
|
| 342 | + ->pageHeader(); |
|
| 343 | + |
|
| 344 | + $level0type = $record::RECORD_TYPE; |
|
| 345 | + |
|
| 346 | + echo '<div id="edit_interface-page">'; |
|
| 347 | + echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
| 348 | + |
|
| 349 | + FunctionsPrint::initializeCalendarPopup(); |
|
| 350 | + echo '<form name="addform" method="post" action="edit_interface.php" enctype="multipart/form-data">'; |
|
| 351 | + echo '<input type="hidden" name="ged" value="', $WT_TREE->getNameHtml(), '">'; |
|
| 352 | + echo '<input type="hidden" name="action" value="update">'; |
|
| 353 | + echo '<input type="hidden" name="xref" value="', $xref, '">'; |
|
| 354 | + echo '<input type="hidden" name="prev_action" value="add">'; |
|
| 355 | + echo '<input type="hidden" name="fact_type" value="' . $fact . '">'; |
|
| 356 | + echo Filter::getCsrf(); |
|
| 357 | + echo '<table class="facts_table">'; |
|
| 358 | + |
|
| 359 | + FunctionsEdit::createAddForm($fact); |
|
| 360 | + |
|
| 361 | + echo keep_chan($record); |
|
| 362 | + echo '</table>'; |
|
| 363 | + |
|
| 364 | + // Genealogical facts (e.g. for INDI and FAM records) can have 2 SOUR/NOTE/OBJE/ASSO/RESN ... |
|
| 365 | + if ($level0type === 'INDI' || $level0type === 'FAM') { |
|
| 366 | + // ... but not facts which are simply links to other records |
|
| 367 | + if ($fact !== 'OBJE' && $fact !== 'NOTE' && $fact !== 'SHARED_NOTE' && $fact !== 'REPO' && $fact !== 'SOUR' && $fact !== 'ASSO' && $fact !== 'ALIA') { |
|
| 368 | + FunctionsEdit::printAddLayer('SOUR'); |
|
| 369 | + FunctionsEdit::printAddLayer('OBJE'); |
|
| 370 | + // Don’t add notes to notes! |
|
| 371 | + if ($fact !== 'NOTE') { |
|
| 372 | + FunctionsEdit::printAddLayer('NOTE'); |
|
| 373 | + FunctionsEdit::printAddLayer('SHARED_NOTE', 2, $fact); |
|
| 374 | + } |
|
| 375 | + FunctionsEdit::printAddLayer('ASSO'); |
|
| 376 | + // allow to add godfather and godmother for CHR fact or best man and bridesmaid for MARR fact in one window |
|
| 377 | + if (in_array($fact, Config::twoAssociates())) { |
|
| 378 | + FunctionsEdit::printAddLayer('ASSO2'); |
|
| 379 | + } |
|
| 380 | + FunctionsEdit::printAddLayer('RESN'); |
|
| 379 | 381 | } |
| 380 | - FunctionsEdit::printAddLayer('RESN'); |
|
| 381 | 382 | } |
| 382 | - } |
|
| 383 | - ?> |
|
| 383 | + ?> |
|
| 384 | 384 | <p id="save-cancel"> |
| 385 | 385 | <input type="submit" class="save" value="<?php echo I18N::translate('save'); ?>"> |
| 386 | 386 | <input type="button" class="cancel" value="<?php echo I18N::translate('close'); ?>" onclick="window.close();"> |
@@ -388,582 +388,582 @@ discard block |
||
| 388 | 388 | </form> |
| 389 | 389 | </div> |
| 390 | 390 | <?php |
| 391 | - break; |
|
| 391 | + break; |
|
| 392 | 392 | |
| 393 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 394 | - case 'update': |
|
| 395 | - // Update a fact |
|
| 396 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 397 | - $fact_id = Filter::post('fact_id'); |
|
| 398 | - $keep_chan = Filter::postBool('keep_chan'); |
|
| 399 | - |
|
| 400 | - if (!Filter::checkCsrf()) { |
|
| 401 | - $prev_action = Filter::post('prev_action', 'add|edit|addname|editname'); |
|
| 402 | - $fact_type = Filter::post('fact_type', WT_REGEX_TAG); |
|
| 403 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=' . $prev_action . '&xref=' . $xref . '&fact_id=' . $fact_id . '&fact=' . $fact_type); |
|
| 404 | - |
|
| 405 | - return; |
|
| 406 | - } |
|
| 393 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 394 | + case 'update': |
|
| 395 | + // Update a fact |
|
| 396 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 397 | + $fact_id = Filter::post('fact_id'); |
|
| 398 | + $keep_chan = Filter::postBool('keep_chan'); |
|
| 407 | 399 | |
| 408 | - $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 409 | - check_record_access($record); |
|
| 400 | + if (!Filter::checkCsrf()) { |
|
| 401 | + $prev_action = Filter::post('prev_action', 'add|edit|addname|editname'); |
|
| 402 | + $fact_type = Filter::post('fact_type', WT_REGEX_TAG); |
|
| 403 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=' . $prev_action . '&xref=' . $xref . '&fact_id=' . $fact_id . '&fact=' . $fact_type); |
|
| 410 | 404 | |
| 411 | - // Arrays for each GEDCOM line |
|
| 412 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 413 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 414 | - $text = Filter::postArray('text'); |
|
| 415 | - $islink = Filter::postArray('islink', '[01]'); |
|
| 405 | + return; |
|
| 406 | + } |
|
| 416 | 407 | |
| 417 | - $controller |
|
| 418 | - ->setPageTitle(I18N::translate('Edit')) |
|
| 419 | - ->pageHeader(); |
|
| 420 | - |
|
| 421 | - // If the fact has a DATE or PLAC, then delete any value of Y |
|
| 422 | - if ($text[0] === 'Y') { |
|
| 423 | - for ($n = 1; $n < count($tag); ++$n) { |
|
| 424 | - if ($glevels[$n] == 2 && ($tag[$n] === 'DATE' || $tag[$n] === 'PLAC') && $text[$n]) { |
|
| 425 | - $text[0] = ''; |
|
| 426 | - break; |
|
| 408 | + $record = GedcomRecord::getInstance($xref, $WT_TREE); |
|
| 409 | + check_record_access($record); |
|
| 410 | + |
|
| 411 | + // Arrays for each GEDCOM line |
|
| 412 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 413 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 414 | + $text = Filter::postArray('text'); |
|
| 415 | + $islink = Filter::postArray('islink', '[01]'); |
|
| 416 | + |
|
| 417 | + $controller |
|
| 418 | + ->setPageTitle(I18N::translate('Edit')) |
|
| 419 | + ->pageHeader(); |
|
| 420 | + |
|
| 421 | + // If the fact has a DATE or PLAC, then delete any value of Y |
|
| 422 | + if ($text[0] === 'Y') { |
|
| 423 | + for ($n = 1; $n < count($tag); ++$n) { |
|
| 424 | + if ($glevels[$n] == 2 && ($tag[$n] === 'DATE' || $tag[$n] === 'PLAC') && $text[$n]) { |
|
| 425 | + $text[0] = ''; |
|
| 426 | + break; |
|
| 427 | + } |
|
| 427 | 428 | } |
| 428 | 429 | } |
| 429 | - } |
|
| 430 | 430 | |
| 431 | - $newged = ''; |
|
| 432 | - if (!empty($_POST['NAME'])) { |
|
| 433 | - $newged .= "\n1 NAME " . $_POST['NAME']; |
|
| 434 | - $name_facts = array('TYPE', 'NPFX', 'GIVN', 'SPFX', 'SURN', 'NSFX'); |
|
| 435 | - foreach ($name_facts as $name_fact) { |
|
| 436 | - if (!empty($_POST[$name_fact])) { |
|
| 437 | - $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
| 431 | + $newged = ''; |
|
| 432 | + if (!empty($_POST['NAME'])) { |
|
| 433 | + $newged .= "\n1 NAME " . $_POST['NAME']; |
|
| 434 | + $name_facts = array('TYPE', 'NPFX', 'GIVN', 'SPFX', 'SURN', 'NSFX'); |
|
| 435 | + foreach ($name_facts as $name_fact) { |
|
| 436 | + if (!empty($_POST[$name_fact])) { |
|
| 437 | + $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
| 438 | + } |
|
| 438 | 439 | } |
| 439 | 440 | } |
| 440 | - } |
|
| 441 | 441 | |
| 442 | - if (isset($_POST['NOTE'])) { |
|
| 443 | - $NOTE = $_POST['NOTE']; |
|
| 444 | - } |
|
| 445 | - if (!empty($NOTE)) { |
|
| 446 | - $tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end |
|
| 447 | - $title[] = '0 @' . $xref . '@ NOTE ' . array_shift($tempnote); |
|
| 448 | - foreach ($tempnote as &$line) { |
|
| 449 | - $line = trim('1 CONT ' . $line, ' '); |
|
| 442 | + if (isset($_POST['NOTE'])) { |
|
| 443 | + $NOTE = $_POST['NOTE']; |
|
| 444 | + } |
|
| 445 | + if (!empty($NOTE)) { |
|
| 446 | + $tempnote = preg_split('/\r?\n/', trim($NOTE) . "\n"); // make sure only one line ending on the end |
|
| 447 | + $title[] = '0 @' . $xref . '@ NOTE ' . array_shift($tempnote); |
|
| 448 | + foreach ($tempnote as &$line) { |
|
| 449 | + $line = trim('1 CONT ' . $line, ' '); |
|
| 450 | + } |
|
| 450 | 451 | } |
| 451 | - } |
|
| 452 | 452 | |
| 453 | - $newged = FunctionsEdit::handleUpdates($newged); |
|
| 453 | + $newged = FunctionsEdit::handleUpdates($newged); |
|
| 454 | 454 | |
| 455 | - // Add new names after existing names |
|
| 456 | - if (!empty($_POST['NAME'])) { |
|
| 457 | - preg_match_all('/[_0-9A-Z]+/', $WT_TREE->getPreference('ADVANCED_NAME_FACTS'), $match); |
|
| 458 | - $name_facts = array_unique(array_merge(array('_MARNM'), $match[0])); |
|
| 459 | - foreach ($name_facts as $name_fact) { |
|
| 460 | - if (!empty($_POST[$name_fact])) { |
|
| 461 | - $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
| 455 | + // Add new names after existing names |
|
| 456 | + if (!empty($_POST['NAME'])) { |
|
| 457 | + preg_match_all('/[_0-9A-Z]+/', $WT_TREE->getPreference('ADVANCED_NAME_FACTS'), $match); |
|
| 458 | + $name_facts = array_unique(array_merge(array('_MARNM'), $match[0])); |
|
| 459 | + foreach ($name_facts as $name_fact) { |
|
| 460 | + if (!empty($_POST[$name_fact])) { |
|
| 461 | + $newged .= "\n2 " . $name_fact . ' ' . $_POST[$name_fact]; |
|
| 462 | + } |
|
| 462 | 463 | } |
| 463 | 464 | } |
| 464 | - } |
|
| 465 | 465 | |
| 466 | - $newged = substr($newged, 1); // Remove leading newline |
|
| 467 | - $record->updateFact($fact_id, $newged, !$keep_chan); |
|
| 468 | - |
|
| 469 | - // For the GEDFact_assistant module |
|
| 470 | - $pid_array = Filter::post('pid_array'); |
|
| 471 | - if ($pid_array) { |
|
| 472 | - foreach (explode(',', $pid_array) as $pid) { |
|
| 473 | - if ($pid !== $xref) { |
|
| 474 | - $indi = Individual::getInstance($pid, $WT_TREE); |
|
| 475 | - if ($indi && $indi->canEdit()) { |
|
| 476 | - $indi->updateFact($fact_id, $newged, !$keep_chan); |
|
| 466 | + $newged = substr($newged, 1); // Remove leading newline |
|
| 467 | + $record->updateFact($fact_id, $newged, !$keep_chan); |
|
| 468 | + |
|
| 469 | + // For the GEDFact_assistant module |
|
| 470 | + $pid_array = Filter::post('pid_array'); |
|
| 471 | + if ($pid_array) { |
|
| 472 | + foreach (explode(',', $pid_array) as $pid) { |
|
| 473 | + if ($pid !== $xref) { |
|
| 474 | + $indi = Individual::getInstance($pid, $WT_TREE); |
|
| 475 | + if ($indi && $indi->canEdit()) { |
|
| 476 | + $indi->updateFact($fact_id, $newged, !$keep_chan); |
|
| 477 | + } |
|
| 477 | 478 | } |
| 478 | 479 | } |
| 479 | 480 | } |
| 480 | - } |
|
| 481 | - |
|
| 482 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 483 | - break; |
|
| 484 | - |
|
| 485 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 486 | -// Add a child to an existing family |
|
| 487 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 488 | - case 'add_child_to_family': |
|
| 489 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 490 | - $gender = Filter::get('gender', '[MFU]', 'U'); |
|
| 491 | 481 | |
| 492 | - $family = Family::getInstance($xref, $WT_TREE); |
|
| 493 | - check_record_access($family); |
|
| 482 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 483 | + break; |
|
| 494 | 484 | |
| 495 | - $controller |
|
| 496 | - ->setPageTitle($family->getFullName() . ' - ' . I18N::translate('Add a child')) |
|
| 497 | - ->pageHeader(); |
|
| 485 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 486 | + // Add a child to an existing family |
|
| 487 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 488 | + case 'add_child_to_family': |
|
| 489 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 490 | + $gender = Filter::get('gender', '[MFU]', 'U'); |
|
| 498 | 491 | |
| 499 | - print_indi_form('add_child_to_family_action', null, $family, null, 'CHIL', $gender); |
|
| 500 | - break; |
|
| 492 | + $family = Family::getInstance($xref, $WT_TREE); |
|
| 493 | + check_record_access($family); |
|
| 501 | 494 | |
| 502 | - case 'add_child_to_family_action': |
|
| 503 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 504 | - $PEDI = Filter::post('PEDI'); |
|
| 505 | - $keep_chan = Filter::postBool('keep_chan'); |
|
| 506 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 507 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 508 | - $text = Filter::postArray('text'); |
|
| 509 | - $islink = Filter::postArray('islink', '[01]'); |
|
| 495 | + $controller |
|
| 496 | + ->setPageTitle($family->getFullName() . ' - ' . I18N::translate('Add a child')) |
|
| 497 | + ->pageHeader(); |
|
| 510 | 498 | |
| 511 | - if (!Filter::checkCsrf()) { |
|
| 512 | - $gender = Filter::get('gender', '[MFU]', 'U'); |
|
| 513 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_family&xref=' . $xref . '&gender=' . $gender); |
|
| 499 | + print_indi_form('add_child_to_family_action', null, $family, null, 'CHIL', $gender); |
|
| 500 | + break; |
|
| 514 | 501 | |
| 515 | - return; |
|
| 516 | - } |
|
| 502 | + case 'add_child_to_family_action': |
|
| 503 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 504 | + $PEDI = Filter::post('PEDI'); |
|
| 505 | + $keep_chan = Filter::postBool('keep_chan'); |
|
| 506 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 507 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 508 | + $text = Filter::postArray('text'); |
|
| 509 | + $islink = Filter::postArray('islink', '[01]'); |
|
| 510 | + |
|
| 511 | + if (!Filter::checkCsrf()) { |
|
| 512 | + $gender = Filter::get('gender', '[MFU]', 'U'); |
|
| 513 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_family&xref=' . $xref . '&gender=' . $gender); |
|
| 514 | + |
|
| 515 | + return; |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - $family = Family::getInstance($xref, $WT_TREE); |
|
| 519 | - check_record_access($family); |
|
| 518 | + $family = Family::getInstance($xref, $WT_TREE); |
|
| 519 | + check_record_access($family); |
|
| 520 | 520 | |
| 521 | - $controller->pageHeader(); |
|
| 521 | + $controller->pageHeader(); |
|
| 522 | 522 | |
| 523 | - FunctionsEdit::splitSource(); |
|
| 524 | - $gedrec = '0 @REF@ INDI'; |
|
| 525 | - $gedrec .= FunctionsEdit::addNewName(); |
|
| 526 | - $gedrec .= FunctionsEdit::addNewSex(); |
|
| 527 | - if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 528 | - foreach ($matches[1] as $match) { |
|
| 529 | - $gedrec .= FunctionsEdit::addNewFact($match); |
|
| 523 | + FunctionsEdit::splitSource(); |
|
| 524 | + $gedrec = '0 @REF@ INDI'; |
|
| 525 | + $gedrec .= FunctionsEdit::addNewName(); |
|
| 526 | + $gedrec .= FunctionsEdit::addNewSex(); |
|
| 527 | + if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 528 | + foreach ($matches[1] as $match) { |
|
| 529 | + $gedrec .= FunctionsEdit::addNewFact($match); |
|
| 530 | + } |
|
| 531 | + } |
|
| 532 | + $gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref); |
|
| 533 | + if (Filter::postBool('SOUR_INDI')) { |
|
| 534 | + $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
| 535 | + } else { |
|
| 536 | + $gedrec = FunctionsEdit::updateRest($gedrec); |
|
| 530 | 537 | } |
| 531 | - } |
|
| 532 | - $gedrec .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $xref); |
|
| 533 | - if (Filter::postBool('SOUR_INDI')) { |
|
| 534 | - $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
| 535 | - } else { |
|
| 536 | - $gedrec = FunctionsEdit::updateRest($gedrec); |
|
| 537 | - } |
|
| 538 | 538 | |
| 539 | - // Create the new child |
|
| 540 | - $new_child = $family->getTree()->createRecord($gedrec); |
|
| 541 | - |
|
| 542 | - // Insert new child at the right place |
|
| 543 | - $done = false; |
|
| 544 | - foreach ($family->getFacts('CHIL') as $fact) { |
|
| 545 | - $old_child = $fact->getTarget(); |
|
| 546 | - if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) { |
|
| 547 | - // Insert before this child |
|
| 548 | - $family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan); |
|
| 549 | - $done = true; |
|
| 550 | - break; |
|
| 539 | + // Create the new child |
|
| 540 | + $new_child = $family->getTree()->createRecord($gedrec); |
|
| 541 | + |
|
| 542 | + // Insert new child at the right place |
|
| 543 | + $done = false; |
|
| 544 | + foreach ($family->getFacts('CHIL') as $fact) { |
|
| 545 | + $old_child = $fact->getTarget(); |
|
| 546 | + if ($old_child && Date::compare($new_child->getEstimatedBirthDate(), $old_child->getEstimatedBirthDate()) < 0) { |
|
| 547 | + // Insert before this child |
|
| 548 | + $family->updateFact($fact->getFactId(), '1 CHIL @' . $new_child->getXref() . "@\n" . $fact->getGedcom(), !$keep_chan); |
|
| 549 | + $done = true; |
|
| 550 | + break; |
|
| 551 | + } |
|
| 552 | + } |
|
| 553 | + if (!$done) { |
|
| 554 | + // Append child at end |
|
| 555 | + $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
| 551 | 556 | } |
| 552 | - } |
|
| 553 | - if (!$done) { |
|
| 554 | - // Append child at end |
|
| 555 | - $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
| 556 | - } |
|
| 557 | 557 | |
| 558 | - if (Filter::post('goto') === 'new') { |
|
| 559 | - $controller->addInlineJavascript('closePopupAndReloadParent("' . $new_child->getRawUrl() . '");'); |
|
| 560 | - } else { |
|
| 561 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 562 | - } |
|
| 563 | - break; |
|
| 558 | + if (Filter::post('goto') === 'new') { |
|
| 559 | + $controller->addInlineJavascript('closePopupAndReloadParent("' . $new_child->getRawUrl() . '");'); |
|
| 560 | + } else { |
|
| 561 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 562 | + } |
|
| 563 | + break; |
|
| 564 | 564 | |
| 565 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 566 | -// Add a child to an existing individual (creating a one-parent family) |
|
| 567 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 568 | - case 'add_child_to_individual': |
|
| 569 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 565 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 566 | + // Add a child to an existing individual (creating a one-parent family) |
|
| 567 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 568 | + case 'add_child_to_individual': |
|
| 569 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 570 | 570 | |
| 571 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 572 | - check_record_access($person); |
|
| 571 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 572 | + check_record_access($person); |
|
| 573 | 573 | |
| 574 | - $controller |
|
| 575 | - ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a child to create a one-parent family')) |
|
| 576 | - ->pageHeader(); |
|
| 574 | + $controller |
|
| 575 | + ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a child to create a one-parent family')) |
|
| 576 | + ->pageHeader(); |
|
| 577 | 577 | |
| 578 | - print_indi_form('add_child_to_individual_action', $person, null, null, 'CHIL', $person->getSex()); |
|
| 579 | - break; |
|
| 578 | + print_indi_form('add_child_to_individual_action', $person, null, null, 'CHIL', $person->getSex()); |
|
| 579 | + break; |
|
| 580 | 580 | |
| 581 | - case 'add_child_to_individual_action': |
|
| 582 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 583 | - $PEDI = Filter::post('PEDI'); |
|
| 584 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 585 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 586 | - $text = Filter::postArray('text'); |
|
| 587 | - $islink = Filter::postArray('islink', '[01]'); |
|
| 581 | + case 'add_child_to_individual_action': |
|
| 582 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 583 | + $PEDI = Filter::post('PEDI'); |
|
| 584 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 585 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 586 | + $text = Filter::postArray('text'); |
|
| 587 | + $islink = Filter::postArray('islink', '[01]'); |
|
| 588 | 588 | |
| 589 | - if (!Filter::checkCsrf()) { |
|
| 590 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_individual&xref=' . $xref); |
|
| 589 | + if (!Filter::checkCsrf()) { |
|
| 590 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_child_to_individual&xref=' . $xref); |
|
| 591 | 591 | |
| 592 | - return; |
|
| 593 | - } |
|
| 592 | + return; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 596 | - check_record_access($person); |
|
| 595 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 596 | + check_record_access($person); |
|
| 597 | 597 | |
| 598 | - $controller->pageHeader(); |
|
| 598 | + $controller->pageHeader(); |
|
| 599 | 599 | |
| 600 | - // Create a family |
|
| 601 | - if ($person->getSex() === 'F') { |
|
| 602 | - $gedcom = "0 @NEW@ FAM\n1 WIFE @" . $person->getXref() . '@'; |
|
| 603 | - } else { |
|
| 604 | - $gedcom = "0 @NEW@ FAM\n1 HUSB @" . $person->getXref() . '@'; |
|
| 605 | - } |
|
| 606 | - $family = $person->getTree()->createRecord($gedcom); |
|
| 600 | + // Create a family |
|
| 601 | + if ($person->getSex() === 'F') { |
|
| 602 | + $gedcom = "0 @NEW@ FAM\n1 WIFE @" . $person->getXref() . '@'; |
|
| 603 | + } else { |
|
| 604 | + $gedcom = "0 @NEW@ FAM\n1 HUSB @" . $person->getXref() . '@'; |
|
| 605 | + } |
|
| 606 | + $family = $person->getTree()->createRecord($gedcom); |
|
| 607 | 607 | |
| 608 | - // Link the parent to the family |
|
| 609 | - $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 608 | + // Link the parent to the family |
|
| 609 | + $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 610 | 610 | |
| 611 | - // Create a child |
|
| 612 | - FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
| 611 | + // Create a child |
|
| 612 | + FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
| 613 | 613 | |
| 614 | - $gedcom = '0 @NEW@ INDI'; |
|
| 615 | - $gedcom .= FunctionsEdit::addNewName(); |
|
| 616 | - $gedcom .= FunctionsEdit::addNewSex(); |
|
| 617 | - $gedcom .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $family->getXref()); |
|
| 618 | - if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 619 | - foreach ($matches[1] as $match) { |
|
| 620 | - $gedcom .= FunctionsEdit::addNewFact($match); |
|
| 614 | + $gedcom = '0 @NEW@ INDI'; |
|
| 615 | + $gedcom .= FunctionsEdit::addNewName(); |
|
| 616 | + $gedcom .= FunctionsEdit::addNewSex(); |
|
| 617 | + $gedcom .= "\n" . GedcomCodePedi::createNewFamcPedi($PEDI, $family->getXref()); |
|
| 618 | + if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 619 | + foreach ($matches[1] as $match) { |
|
| 620 | + $gedcom .= FunctionsEdit::addNewFact($match); |
|
| 621 | + } |
|
| 622 | + } |
|
| 623 | + if (Filter::postBool('SOUR_INDI')) { |
|
| 624 | + $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
| 625 | + } else { |
|
| 626 | + $gedcom = FunctionsEdit::updateRest($gedcom); |
|
| 621 | 627 | } |
| 622 | - } |
|
| 623 | - if (Filter::postBool('SOUR_INDI')) { |
|
| 624 | - $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
| 625 | - } else { |
|
| 626 | - $gedcom = FunctionsEdit::updateRest($gedcom); |
|
| 627 | - } |
|
| 628 | 628 | |
| 629 | - $child = $person->getTree()->createRecord($gedcom); |
|
| 629 | + $child = $person->getTree()->createRecord($gedcom); |
|
| 630 | 630 | |
| 631 | - // Link the family to the child |
|
| 632 | - $family->createFact('1 CHIL @' . $child->getXref() . '@', true); |
|
| 631 | + // Link the family to the child |
|
| 632 | + $family->createFact('1 CHIL @' . $child->getXref() . '@', true); |
|
| 633 | 633 | |
| 634 | - if (Filter::post('goto') === 'new') { |
|
| 635 | - $controller->addInlineJavascript('closePopupAndReloadParent("' . $child->getRawUrl() . '");'); |
|
| 636 | - } else { |
|
| 637 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 638 | - } |
|
| 639 | - break; |
|
| 634 | + if (Filter::post('goto') === 'new') { |
|
| 635 | + $controller->addInlineJavascript('closePopupAndReloadParent("' . $child->getRawUrl() . '");'); |
|
| 636 | + } else { |
|
| 637 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 638 | + } |
|
| 639 | + break; |
|
| 640 | 640 | |
| 641 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 642 | -// Add a new parent to an existing individual (creating a one-parent family) |
|
| 643 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 644 | - case 'add_parent_to_individual': |
|
| 645 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 646 | - $gender = Filter::get('gender', '[MF]', 'U'); |
|
| 641 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 642 | + // Add a new parent to an existing individual (creating a one-parent family) |
|
| 643 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 644 | + case 'add_parent_to_individual': |
|
| 645 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 646 | + $gender = Filter::get('gender', '[MF]', 'U'); |
|
| 647 | 647 | |
| 648 | - $individual = Individual::getInstance($xref, $WT_TREE); |
|
| 649 | - check_record_access($individual); |
|
| 648 | + $individual = Individual::getInstance($xref, $WT_TREE); |
|
| 649 | + check_record_access($individual); |
|
| 650 | 650 | |
| 651 | - if ($gender === 'F') { |
|
| 652 | - $controller->setPageTitle(I18N::translate('Add a mother')); |
|
| 653 | - $famtag = 'WIFE'; |
|
| 654 | - } else { |
|
| 655 | - $controller->setPageTitle(I18N::translate('Add a father')); |
|
| 656 | - $famtag = 'HUSB'; |
|
| 657 | - } |
|
| 658 | - $controller->pageHeader(); |
|
| 651 | + if ($gender === 'F') { |
|
| 652 | + $controller->setPageTitle(I18N::translate('Add a mother')); |
|
| 653 | + $famtag = 'WIFE'; |
|
| 654 | + } else { |
|
| 655 | + $controller->setPageTitle(I18N::translate('Add a father')); |
|
| 656 | + $famtag = 'HUSB'; |
|
| 657 | + } |
|
| 658 | + $controller->pageHeader(); |
|
| 659 | 659 | |
| 660 | - print_indi_form('add_parent_to_individual_action', $individual, null, null, $famtag, $gender); |
|
| 661 | - break; |
|
| 660 | + print_indi_form('add_parent_to_individual_action', $individual, null, null, $famtag, $gender); |
|
| 661 | + break; |
|
| 662 | 662 | |
| 663 | - case 'add_parent_to_individual_action': |
|
| 664 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 665 | - $PEDI = Filter::post('PEDI'); |
|
| 666 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 667 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 668 | - $text = Filter::postArray('text'); |
|
| 669 | - $islink = Filter::postArray('islink', '[01]'); |
|
| 663 | + case 'add_parent_to_individual_action': |
|
| 664 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 665 | + $PEDI = Filter::post('PEDI'); |
|
| 666 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 667 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 668 | + $text = Filter::postArray('text'); |
|
| 669 | + $islink = Filter::postArray('islink', '[01]'); |
|
| 670 | 670 | |
| 671 | - if (!Filter::checkCsrf()) { |
|
| 672 | - $gender = Filter::get('gender', '[MFU]', 'U'); |
|
| 673 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_parent_to_individual&xref=' . $xref . '&gender=' . $gender); |
|
| 671 | + if (!Filter::checkCsrf()) { |
|
| 672 | + $gender = Filter::get('gender', '[MFU]', 'U'); |
|
| 673 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_parent_to_individual&xref=' . $xref . '&gender=' . $gender); |
|
| 674 | 674 | |
| 675 | - return; |
|
| 676 | - } |
|
| 675 | + return; |
|
| 676 | + } |
|
| 677 | 677 | |
| 678 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 679 | - check_record_access($person); |
|
| 678 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 679 | + check_record_access($person); |
|
| 680 | 680 | |
| 681 | - $controller->pageHeader(); |
|
| 681 | + $controller->pageHeader(); |
|
| 682 | 682 | |
| 683 | - // Create a new family |
|
| 684 | - $gedcom = "0 @NEW@ FAM\n1 CHIL @" . $person->getXref() . '@'; |
|
| 685 | - $family = $person->getTree()->createRecord($gedcom); |
|
| 683 | + // Create a new family |
|
| 684 | + $gedcom = "0 @NEW@ FAM\n1 CHIL @" . $person->getXref() . '@'; |
|
| 685 | + $family = $person->getTree()->createRecord($gedcom); |
|
| 686 | 686 | |
| 687 | - // Link the child to the family |
|
| 688 | - $person->createFact('1 FAMC @' . $family->getXref() . '@', true); |
|
| 687 | + // Link the child to the family |
|
| 688 | + $person->createFact('1 FAMC @' . $family->getXref() . '@', true); |
|
| 689 | 689 | |
| 690 | - // Create a child |
|
| 691 | - FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
| 690 | + // Create a child |
|
| 691 | + FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
| 692 | 692 | |
| 693 | - $gedcom = '0 @NEW@ INDI'; |
|
| 694 | - $gedcom .= FunctionsEdit::addNewName(); |
|
| 695 | - $gedcom .= FunctionsEdit::addNewSex(); |
|
| 696 | - if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 697 | - foreach ($matches[1] as $match) { |
|
| 698 | - $gedcom .= FunctionsEdit::addNewFact($match); |
|
| 693 | + $gedcom = '0 @NEW@ INDI'; |
|
| 694 | + $gedcom .= FunctionsEdit::addNewName(); |
|
| 695 | + $gedcom .= FunctionsEdit::addNewSex(); |
|
| 696 | + if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 697 | + foreach ($matches[1] as $match) { |
|
| 698 | + $gedcom .= FunctionsEdit::addNewFact($match); |
|
| 699 | + } |
|
| 699 | 700 | } |
| 700 | - } |
|
| 701 | - if (Filter::postBool('SOUR_INDI')) { |
|
| 702 | - $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
| 703 | - } else { |
|
| 704 | - $gedcom = FunctionsEdit::updateRest($gedcom); |
|
| 705 | - } |
|
| 706 | - $gedcom .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
| 701 | + if (Filter::postBool('SOUR_INDI')) { |
|
| 702 | + $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
| 703 | + } else { |
|
| 704 | + $gedcom = FunctionsEdit::updateRest($gedcom); |
|
| 705 | + } |
|
| 706 | + $gedcom .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
| 707 | 707 | |
| 708 | - $parent = $person->getTree()->createRecord($gedcom); |
|
| 708 | + $parent = $person->getTree()->createRecord($gedcom); |
|
| 709 | 709 | |
| 710 | - // Link the family to the child |
|
| 711 | - if ($parent->getSex() === 'F') { |
|
| 712 | - $family->createFact('1 WIFE @' . $parent->getXref() . '@', true); |
|
| 713 | - } else { |
|
| 714 | - $family->createFact('1 HUSB @' . $parent->getXref() . '@', true); |
|
| 715 | - } |
|
| 710 | + // Link the family to the child |
|
| 711 | + if ($parent->getSex() === 'F') { |
|
| 712 | + $family->createFact('1 WIFE @' . $parent->getXref() . '@', true); |
|
| 713 | + } else { |
|
| 714 | + $family->createFact('1 HUSB @' . $parent->getXref() . '@', true); |
|
| 715 | + } |
|
| 716 | 716 | |
| 717 | - if (Filter::post('goto') === 'new') { |
|
| 718 | - $controller->addInlineJavascript('closePopupAndReloadParent("' . $parent->getRawUrl() . '");'); |
|
| 719 | - } else { |
|
| 720 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 721 | - } |
|
| 722 | - break; |
|
| 717 | + if (Filter::post('goto') === 'new') { |
|
| 718 | + $controller->addInlineJavascript('closePopupAndReloadParent("' . $parent->getRawUrl() . '");'); |
|
| 719 | + } else { |
|
| 720 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 721 | + } |
|
| 722 | + break; |
|
| 723 | 723 | |
| 724 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 725 | -// Add a new, unlinked individual |
|
| 726 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 727 | - case 'add_unlinked_indi': |
|
| 728 | - $controller |
|
| 729 | - ->restrictAccess(Auth::isManager($WT_TREE)) |
|
| 730 | - ->setPageTitle(I18N::translate('Create an individual')) |
|
| 731 | - ->pageHeader(); |
|
| 724 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 725 | + // Add a new, unlinked individual |
|
| 726 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 727 | + case 'add_unlinked_indi': |
|
| 728 | + $controller |
|
| 729 | + ->restrictAccess(Auth::isManager($WT_TREE)) |
|
| 730 | + ->setPageTitle(I18N::translate('Create an individual')) |
|
| 731 | + ->pageHeader(); |
|
| 732 | 732 | |
| 733 | - print_indi_form('add_unlinked_indi_action', null, null, null, null, null); |
|
| 734 | - break; |
|
| 733 | + print_indi_form('add_unlinked_indi_action', null, null, null, null, null); |
|
| 734 | + break; |
|
| 735 | 735 | |
| 736 | - case 'add_unlinked_indi_action': |
|
| 737 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 738 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 739 | - $text = Filter::postArray('text'); |
|
| 740 | - $islink = Filter::postArray('islink', '[01]'); |
|
| 736 | + case 'add_unlinked_indi_action': |
|
| 737 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 738 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 739 | + $text = Filter::postArray('text'); |
|
| 740 | + $islink = Filter::postArray('islink', '[01]'); |
|
| 741 | 741 | |
| 742 | - if (!Filter::checkCsrf()) { |
|
| 743 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_unlinked_indi'); |
|
| 742 | + if (!Filter::checkCsrf()) { |
|
| 743 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_unlinked_indi'); |
|
| 744 | 744 | |
| 745 | - return; |
|
| 746 | - } |
|
| 745 | + return; |
|
| 746 | + } |
|
| 747 | 747 | |
| 748 | - $controller |
|
| 749 | - ->restrictAccess(Auth::isManager($WT_TREE)) |
|
| 750 | - ->pageHeader(); |
|
| 751 | - |
|
| 752 | - FunctionsEdit::splitSource(); |
|
| 753 | - $gedrec = '0 @REF@ INDI'; |
|
| 754 | - $gedrec .= FunctionsEdit::addNewName(); |
|
| 755 | - $gedrec .= FunctionsEdit::addNewSex(); |
|
| 756 | - if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 757 | - foreach ($matches[1] as $match) { |
|
| 758 | - $gedrec .= FunctionsEdit::addNewFact($match); |
|
| 748 | + $controller |
|
| 749 | + ->restrictAccess(Auth::isManager($WT_TREE)) |
|
| 750 | + ->pageHeader(); |
|
| 751 | + |
|
| 752 | + FunctionsEdit::splitSource(); |
|
| 753 | + $gedrec = '0 @REF@ INDI'; |
|
| 754 | + $gedrec .= FunctionsEdit::addNewName(); |
|
| 755 | + $gedrec .= FunctionsEdit::addNewSex(); |
|
| 756 | + if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 757 | + foreach ($matches[1] as $match) { |
|
| 758 | + $gedrec .= FunctionsEdit::addNewFact($match); |
|
| 759 | + } |
|
| 760 | + } |
|
| 761 | + if (Filter::postBool('SOUR_INDI')) { |
|
| 762 | + $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
| 763 | + } else { |
|
| 764 | + $gedrec = FunctionsEdit::updateRest($gedrec); |
|
| 759 | 765 | } |
| 760 | - } |
|
| 761 | - if (Filter::postBool('SOUR_INDI')) { |
|
| 762 | - $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
| 763 | - } else { |
|
| 764 | - $gedrec = FunctionsEdit::updateRest($gedrec); |
|
| 765 | - } |
|
| 766 | 766 | |
| 767 | - $new_indi = $WT_TREE->createRecord($gedrec); |
|
| 767 | + $new_indi = $WT_TREE->createRecord($gedrec); |
|
| 768 | 768 | |
| 769 | - if (Filter::post('goto') === 'new') { |
|
| 770 | - $controller->addInlineJavascript('closePopupAndReloadParent("' . $new_indi->getRawUrl() . '");'); |
|
| 771 | - } else { |
|
| 772 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 773 | - } |
|
| 774 | - break; |
|
| 769 | + if (Filter::post('goto') === 'new') { |
|
| 770 | + $controller->addInlineJavascript('closePopupAndReloadParent("' . $new_indi->getRawUrl() . '");'); |
|
| 771 | + } else { |
|
| 772 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 773 | + } |
|
| 774 | + break; |
|
| 775 | 775 | |
| 776 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 777 | -// Add a spouse to an existing individual (creating a new family) |
|
| 778 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 779 | - case 'add_spouse_to_individual': |
|
| 780 | - $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 781 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 776 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 777 | + // Add a spouse to an existing individual (creating a new family) |
|
| 778 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 779 | + case 'add_spouse_to_individual': |
|
| 780 | + $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 781 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 782 | 782 | |
| 783 | - $individual = Individual::getInstance($xref, $WT_TREE); |
|
| 784 | - check_record_access($individual); |
|
| 783 | + $individual = Individual::getInstance($xref, $WT_TREE); |
|
| 784 | + check_record_access($individual); |
|
| 785 | 785 | |
| 786 | - if ($famtag === 'WIFE') { |
|
| 787 | - $controller->setPageTitle(I18N::translate('Add a wife')); |
|
| 788 | - $sex = 'F'; |
|
| 789 | - } else { |
|
| 790 | - $controller->setPageTitle(I18N::translate('Add a husband')); |
|
| 791 | - $sex = 'M'; |
|
| 792 | - } |
|
| 793 | - $controller->pageHeader(); |
|
| 786 | + if ($famtag === 'WIFE') { |
|
| 787 | + $controller->setPageTitle(I18N::translate('Add a wife')); |
|
| 788 | + $sex = 'F'; |
|
| 789 | + } else { |
|
| 790 | + $controller->setPageTitle(I18N::translate('Add a husband')); |
|
| 791 | + $sex = 'M'; |
|
| 792 | + } |
|
| 793 | + $controller->pageHeader(); |
|
| 794 | 794 | |
| 795 | - print_indi_form('add_spouse_to_individual_action', $individual, null, null, $famtag, $sex); |
|
| 796 | - break; |
|
| 795 | + print_indi_form('add_spouse_to_individual_action', $individual, null, null, $famtag, $sex); |
|
| 796 | + break; |
|
| 797 | 797 | |
| 798 | - case 'add_spouse_to_individual_action': |
|
| 799 | - $xref = Filter::post('xref'); // Add a spouse to this individual |
|
| 800 | - $sex = Filter::post('SEX', '[MFU]', 'U'); |
|
| 801 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 802 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 803 | - $text = Filter::postArray('text'); |
|
| 804 | - $islink = Filter::postArray('islink', '[01]'); |
|
| 798 | + case 'add_spouse_to_individual_action': |
|
| 799 | + $xref = Filter::post('xref'); // Add a spouse to this individual |
|
| 800 | + $sex = Filter::post('SEX', '[MFU]', 'U'); |
|
| 801 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 802 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 803 | + $text = Filter::postArray('text'); |
|
| 804 | + $islink = Filter::postArray('islink', '[01]'); |
|
| 805 | 805 | |
| 806 | - if (!Filter::checkCsrf()) { |
|
| 807 | - $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 808 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_individual&xref=' . $xref . '&famtag=' . $famtag); |
|
| 806 | + if (!Filter::checkCsrf()) { |
|
| 807 | + $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 808 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_individual&xref=' . $xref . '&famtag=' . $famtag); |
|
| 809 | 809 | |
| 810 | - return; |
|
| 811 | - } |
|
| 810 | + return; |
|
| 811 | + } |
|
| 812 | 812 | |
| 813 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 814 | - check_record_access($person); |
|
| 813 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 814 | + check_record_access($person); |
|
| 815 | 815 | |
| 816 | - $controller |
|
| 817 | - ->setPageTitle(I18N::translate('Add a spouse')) |
|
| 818 | - ->pageHeader(); |
|
| 819 | - |
|
| 820 | - FunctionsEdit::splitSource(); |
|
| 821 | - $indi_gedcom = '0 @REF@ INDI'; |
|
| 822 | - $indi_gedcom .= FunctionsEdit::addNewName(); |
|
| 823 | - $indi_gedcom .= FunctionsEdit::addNewSex(); |
|
| 824 | - if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 825 | - foreach ($matches[1] as $match) { |
|
| 826 | - $indi_gedcom .= FunctionsEdit::addNewFact($match); |
|
| 816 | + $controller |
|
| 817 | + ->setPageTitle(I18N::translate('Add a spouse')) |
|
| 818 | + ->pageHeader(); |
|
| 819 | + |
|
| 820 | + FunctionsEdit::splitSource(); |
|
| 821 | + $indi_gedcom = '0 @REF@ INDI'; |
|
| 822 | + $indi_gedcom .= FunctionsEdit::addNewName(); |
|
| 823 | + $indi_gedcom .= FunctionsEdit::addNewSex(); |
|
| 824 | + if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 825 | + foreach ($matches[1] as $match) { |
|
| 826 | + $indi_gedcom .= FunctionsEdit::addNewFact($match); |
|
| 827 | + } |
|
| 828 | + } |
|
| 829 | + if (Filter::postBool('SOUR_INDI')) { |
|
| 830 | + $indi_gedcom = FunctionsEdit::handleUpdates($indi_gedcom); |
|
| 831 | + } else { |
|
| 832 | + $indi_gedcom = FunctionsEdit::updateRest($indi_gedcom); |
|
| 827 | 833 | } |
| 828 | - } |
|
| 829 | - if (Filter::postBool('SOUR_INDI')) { |
|
| 830 | - $indi_gedcom = FunctionsEdit::handleUpdates($indi_gedcom); |
|
| 831 | - } else { |
|
| 832 | - $indi_gedcom = FunctionsEdit::updateRest($indi_gedcom); |
|
| 833 | - } |
|
| 834 | 834 | |
| 835 | - $fam_gedcom = ''; |
|
| 836 | - if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
| 837 | - foreach ($matches[1] as $match) { |
|
| 838 | - $fam_gedcom .= FunctionsEdit::addNewFact($match); |
|
| 835 | + $fam_gedcom = ''; |
|
| 836 | + if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
| 837 | + foreach ($matches[1] as $match) { |
|
| 838 | + $fam_gedcom .= FunctionsEdit::addNewFact($match); |
|
| 839 | + } |
|
| 840 | + } |
|
| 841 | + if (Filter::postBool('SOUR_FAM')) { |
|
| 842 | + $fam_gedcom = FunctionsEdit::handleUpdates($fam_gedcom); |
|
| 843 | + } else { |
|
| 844 | + $fam_gedcom = FunctionsEdit::updateRest($fam_gedcom); |
|
| 839 | 845 | } |
| 840 | - } |
|
| 841 | - if (Filter::postBool('SOUR_FAM')) { |
|
| 842 | - $fam_gedcom = FunctionsEdit::handleUpdates($fam_gedcom); |
|
| 843 | - } else { |
|
| 844 | - $fam_gedcom = FunctionsEdit::updateRest($fam_gedcom); |
|
| 845 | - } |
|
| 846 | 846 | |
| 847 | - // Create the new spouse |
|
| 848 | - $spouse = $person->getTree()->createRecord($indi_gedcom); |
|
| 849 | - // Create a new family |
|
| 850 | - if ($sex === 'F') { |
|
| 851 | - $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 WIFE @" . $spouse->getXref() . "@\n1 HUSB @" . $person->getXref() . '@' . $fam_gedcom); |
|
| 852 | - } else { |
|
| 853 | - $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@' . $fam_gedcom); |
|
| 854 | - } |
|
| 855 | - // Link the spouses to the family |
|
| 856 | - $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 857 | - $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 847 | + // Create the new spouse |
|
| 848 | + $spouse = $person->getTree()->createRecord($indi_gedcom); |
|
| 849 | + // Create a new family |
|
| 850 | + if ($sex === 'F') { |
|
| 851 | + $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 WIFE @" . $spouse->getXref() . "@\n1 HUSB @" . $person->getXref() . '@' . $fam_gedcom); |
|
| 852 | + } else { |
|
| 853 | + $family = $spouse->getTree()->createRecord("0 @NEW@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@' . $fam_gedcom); |
|
| 854 | + } |
|
| 855 | + // Link the spouses to the family |
|
| 856 | + $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 857 | + $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 858 | 858 | |
| 859 | - if (Filter::post('goto') === 'new') { |
|
| 860 | - $controller->addInlineJavascript('closePopupAndReloadParent("' . $spouse->getRawUrl() . '");'); |
|
| 861 | - } else { |
|
| 862 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 863 | - } |
|
| 864 | - break; |
|
| 859 | + if (Filter::post('goto') === 'new') { |
|
| 860 | + $controller->addInlineJavascript('closePopupAndReloadParent("' . $spouse->getRawUrl() . '");'); |
|
| 861 | + } else { |
|
| 862 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 863 | + } |
|
| 864 | + break; |
|
| 865 | 865 | |
| 866 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 867 | -// Add a spouse to an existing family |
|
| 868 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 869 | - case 'add_spouse_to_family': |
|
| 870 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 871 | - $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 866 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 867 | + // Add a spouse to an existing family |
|
| 868 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 869 | + case 'add_spouse_to_family': |
|
| 870 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 871 | + $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 872 | 872 | |
| 873 | - $family = Family::getInstance($xref, $WT_TREE); |
|
| 874 | - check_record_access($family); |
|
| 873 | + $family = Family::getInstance($xref, $WT_TREE); |
|
| 874 | + check_record_access($family); |
|
| 875 | 875 | |
| 876 | - if ($famtag === 'WIFE') { |
|
| 877 | - $controller->setPageTitle(I18N::translate('Add a wife')); |
|
| 878 | - $sex = 'F'; |
|
| 879 | - } else { |
|
| 880 | - $controller->setPageTitle(I18N::translate('Add a husband')); |
|
| 881 | - $sex = 'M'; |
|
| 882 | - } |
|
| 883 | - $controller->pageHeader(); |
|
| 876 | + if ($famtag === 'WIFE') { |
|
| 877 | + $controller->setPageTitle(I18N::translate('Add a wife')); |
|
| 878 | + $sex = 'F'; |
|
| 879 | + } else { |
|
| 880 | + $controller->setPageTitle(I18N::translate('Add a husband')); |
|
| 881 | + $sex = 'M'; |
|
| 882 | + } |
|
| 883 | + $controller->pageHeader(); |
|
| 884 | 884 | |
| 885 | - print_indi_form('add_spouse_to_family_action', null, $family, null, $famtag, $sex); |
|
| 886 | - break; |
|
| 885 | + print_indi_form('add_spouse_to_family_action', null, $family, null, $famtag, $sex); |
|
| 886 | + break; |
|
| 887 | 887 | |
| 888 | - case 'add_spouse_to_family_action': |
|
| 889 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 890 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 891 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 892 | - $text = Filter::postArray('text'); |
|
| 893 | - $islink = Filter::postArray('islink', '[01]'); |
|
| 888 | + case 'add_spouse_to_family_action': |
|
| 889 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 890 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 891 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 892 | + $text = Filter::postArray('text'); |
|
| 893 | + $islink = Filter::postArray('islink', '[01]'); |
|
| 894 | 894 | |
| 895 | - $family = Family::getInstance($xref, $WT_TREE); |
|
| 896 | - check_record_access($family); |
|
| 895 | + $family = Family::getInstance($xref, $WT_TREE); |
|
| 896 | + check_record_access($family); |
|
| 897 | 897 | |
| 898 | - if (!Filter::checkCsrf()) { |
|
| 899 | - $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 900 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_family&xref=' . $xref . '&famtag=' . $famtag); |
|
| 898 | + if (!Filter::checkCsrf()) { |
|
| 899 | + $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 900 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=add_spouse_to_family&xref=' . $xref . '&famtag=' . $famtag); |
|
| 901 | 901 | |
| 902 | - return; |
|
| 903 | - } |
|
| 902 | + return; |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | - $controller->pageHeader(); |
|
| 905 | + $controller->pageHeader(); |
|
| 906 | 906 | |
| 907 | - // Create the new spouse |
|
| 908 | - FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
| 907 | + // Create the new spouse |
|
| 908 | + FunctionsEdit::splitSource(); // separate SOUR record from the rest |
|
| 909 | 909 | |
| 910 | - $gedrec = '0 @REF@ INDI'; |
|
| 911 | - $gedrec .= FunctionsEdit::addNewName(); |
|
| 912 | - $gedrec .= FunctionsEdit::addNewSex(); |
|
| 913 | - if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 914 | - foreach ($matches[1] as $match) { |
|
| 915 | - $gedrec .= FunctionsEdit::addNewFact($match); |
|
| 910 | + $gedrec = '0 @REF@ INDI'; |
|
| 911 | + $gedrec .= FunctionsEdit::addNewName(); |
|
| 912 | + $gedrec .= FunctionsEdit::addNewSex(); |
|
| 913 | + if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FACTS'), $matches)) { |
|
| 914 | + foreach ($matches[1] as $match) { |
|
| 915 | + $gedrec .= FunctionsEdit::addNewFact($match); |
|
| 916 | + } |
|
| 916 | 917 | } |
| 917 | - } |
|
| 918 | 918 | |
| 919 | - if (Filter::postBool('SOUR_INDI')) { |
|
| 920 | - $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
| 921 | - } else { |
|
| 922 | - $gedrec = FunctionsEdit::updateRest($gedrec); |
|
| 923 | - } |
|
| 924 | - $gedrec .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
| 925 | - $spouse = $family->getTree()->createRecord($gedrec); |
|
| 919 | + if (Filter::postBool('SOUR_INDI')) { |
|
| 920 | + $gedrec = FunctionsEdit::handleUpdates($gedrec); |
|
| 921 | + } else { |
|
| 922 | + $gedrec = FunctionsEdit::updateRest($gedrec); |
|
| 923 | + } |
|
| 924 | + $gedrec .= "\n1 FAMS @" . $family->getXref() . '@'; |
|
| 925 | + $spouse = $family->getTree()->createRecord($gedrec); |
|
| 926 | 926 | |
| 927 | - // Update the existing family - add marriage, etc |
|
| 928 | - if ($family->getFirstFact('HUSB')) { |
|
| 929 | - $family->createFact('1 WIFE @' . $spouse->getXref() . '@', true); |
|
| 930 | - } else { |
|
| 931 | - $family->createFact('1 HUSB @' . $spouse->getXref() . '@', true); |
|
| 932 | - } |
|
| 933 | - $famrec = ''; |
|
| 934 | - if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
| 935 | - foreach ($matches[1] as $match) { |
|
| 936 | - $famrec .= FunctionsEdit::addNewFact($match); |
|
| 927 | + // Update the existing family - add marriage, etc |
|
| 928 | + if ($family->getFirstFact('HUSB')) { |
|
| 929 | + $family->createFact('1 WIFE @' . $spouse->getXref() . '@', true); |
|
| 930 | + } else { |
|
| 931 | + $family->createFact('1 HUSB @' . $spouse->getXref() . '@', true); |
|
| 937 | 932 | } |
| 938 | - } |
|
| 939 | - if (Filter::postBool('SOUR_FAM')) { |
|
| 940 | - $famrec = FunctionsEdit::handleUpdates($famrec); |
|
| 941 | - } else { |
|
| 942 | - $famrec = FunctionsEdit::updateRest($famrec); |
|
| 943 | - } |
|
| 944 | - $family->createFact(trim($famrec), true); // trim leading \n |
|
| 933 | + $famrec = ''; |
|
| 934 | + if (preg_match_all('/([A-Z0-9_]+)/', $WT_TREE->getPreference('QUICK_REQUIRED_FAMFACTS'), $matches)) { |
|
| 935 | + foreach ($matches[1] as $match) { |
|
| 936 | + $famrec .= FunctionsEdit::addNewFact($match); |
|
| 937 | + } |
|
| 938 | + } |
|
| 939 | + if (Filter::postBool('SOUR_FAM')) { |
|
| 940 | + $famrec = FunctionsEdit::handleUpdates($famrec); |
|
| 941 | + } else { |
|
| 942 | + $famrec = FunctionsEdit::updateRest($famrec); |
|
| 943 | + } |
|
| 944 | + $family->createFact(trim($famrec), true); // trim leading \n |
|
| 945 | 945 | |
| 946 | - if (Filter::post('goto') === 'new') { |
|
| 947 | - $controller->addInlineJavascript('closePopupAndReloadParent("' . $spouse->getRawUrl() . '");'); |
|
| 948 | - } else { |
|
| 949 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 950 | - } |
|
| 951 | - break; |
|
| 946 | + if (Filter::post('goto') === 'new') { |
|
| 947 | + $controller->addInlineJavascript('closePopupAndReloadParent("' . $spouse->getRawUrl() . '");'); |
|
| 948 | + } else { |
|
| 949 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 950 | + } |
|
| 951 | + break; |
|
| 952 | 952 | |
| 953 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 954 | -// Link an individual to an existing family, as a child |
|
| 955 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 956 | - case 'addfamlink': |
|
| 957 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 953 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 954 | + // Link an individual to an existing family, as a child |
|
| 955 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 956 | + case 'addfamlink': |
|
| 957 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 958 | 958 | |
| 959 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 960 | - check_record_access($person); |
|
| 959 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 960 | + check_record_access($person); |
|
| 961 | 961 | |
| 962 | - $controller |
|
| 963 | - ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child')) |
|
| 964 | - ->pageHeader(); |
|
| 962 | + $controller |
|
| 963 | + ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child')) |
|
| 964 | + ->pageHeader(); |
|
| 965 | 965 | |
| 966 | - ?> |
|
| 966 | + ?> |
|
| 967 | 967 | <div id="edit_interface-page"> |
| 968 | 968 | <h2><?php echo $controller->getPageTitle(); ?></h2> |
| 969 | 969 | <form method="post" name="addchildform" action="edit_interface.php"> |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | </td> |
| 988 | 988 | <td class="facts_value"> |
| 989 | 989 | <?php echo FunctionsEdit::editFieldPedigree('PEDI', '', '', $person); ?> |
| 990 | - <p class="small text-muted"> |
|
| 990 | + <p class="small text-muted"> |
|
| 991 | 991 | <?php echo 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.'); ?> |
| 992 | 992 | </p> |
| 993 | 993 | </td> |
@@ -1001,77 +1001,77 @@ discard block |
||
| 1001 | 1001 | </form> |
| 1002 | 1002 | </div> |
| 1003 | 1003 | <?php |
| 1004 | - break; |
|
| 1004 | + break; |
|
| 1005 | 1005 | |
| 1006 | - case 'linkfamaction': |
|
| 1007 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1008 | - $famid = Filter::post('famid', WT_REGEX_XREF); |
|
| 1009 | - $PEDI = Filter::post('PEDI'); |
|
| 1006 | + case 'linkfamaction': |
|
| 1007 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1008 | + $famid = Filter::post('famid', WT_REGEX_XREF); |
|
| 1009 | + $PEDI = Filter::post('PEDI'); |
|
| 1010 | 1010 | |
| 1011 | - if (!Filter::checkCsrf()) { |
|
| 1012 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addfamlink&xref=' . $xref); |
|
| 1011 | + if (!Filter::checkCsrf()) { |
|
| 1012 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addfamlink&xref=' . $xref); |
|
| 1013 | 1013 | |
| 1014 | - return; |
|
| 1015 | - } |
|
| 1014 | + return; |
|
| 1015 | + } |
|
| 1016 | 1016 | |
| 1017 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1018 | - $family = Family::getInstance($famid, $WT_TREE); |
|
| 1019 | - check_record_access($person); |
|
| 1020 | - check_record_access($family); |
|
| 1017 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1018 | + $family = Family::getInstance($famid, $WT_TREE); |
|
| 1019 | + check_record_access($person); |
|
| 1020 | + check_record_access($family); |
|
| 1021 | 1021 | |
| 1022 | - $controller |
|
| 1023 | - ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child')) |
|
| 1024 | - ->pageHeader(); |
|
| 1025 | - |
|
| 1026 | - // Replace any existing child->family link (we may be changing the PEDI); |
|
| 1027 | - $fact_id = null; |
|
| 1028 | - foreach ($person->getFacts('FAMC') as $fact) { |
|
| 1029 | - if ($family === $fact->getTarget()) { |
|
| 1030 | - $fact_id = $fact->getFactId(); |
|
| 1031 | - break; |
|
| 1022 | + $controller |
|
| 1023 | + ->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Link this individual to an existing family as a child')) |
|
| 1024 | + ->pageHeader(); |
|
| 1025 | + |
|
| 1026 | + // Replace any existing child->family link (we may be changing the PEDI); |
|
| 1027 | + $fact_id = null; |
|
| 1028 | + foreach ($person->getFacts('FAMC') as $fact) { |
|
| 1029 | + if ($family === $fact->getTarget()) { |
|
| 1030 | + $fact_id = $fact->getFactId(); |
|
| 1031 | + break; |
|
| 1032 | + } |
|
| 1032 | 1033 | } |
| 1033 | - } |
|
| 1034 | 1034 | |
| 1035 | - $gedcom = GedcomCodePedi::createNewFamcPedi($PEDI, $famid); |
|
| 1036 | - $person->updateFact($fact_id, $gedcom, true); |
|
| 1035 | + $gedcom = GedcomCodePedi::createNewFamcPedi($PEDI, $famid); |
|
| 1036 | + $person->updateFact($fact_id, $gedcom, true); |
|
| 1037 | 1037 | |
| 1038 | - // Only set the family->child link if it does not already exist |
|
| 1039 | - $edit_fact = null; |
|
| 1040 | - foreach ($family->getFacts('CHIL') as $fact) { |
|
| 1041 | - if ($person === $fact->getTarget()) { |
|
| 1042 | - $edit_fact = $fact; |
|
| 1043 | - break; |
|
| 1038 | + // Only set the family->child link if it does not already exist |
|
| 1039 | + $edit_fact = null; |
|
| 1040 | + foreach ($family->getFacts('CHIL') as $fact) { |
|
| 1041 | + if ($person === $fact->getTarget()) { |
|
| 1042 | + $edit_fact = $fact; |
|
| 1043 | + break; |
|
| 1044 | + } |
|
| 1045 | + } |
|
| 1046 | + if (!$edit_fact) { |
|
| 1047 | + $family->createFact('1 CHIL @' . $person->getXref() . '@', true); |
|
| 1044 | 1048 | } |
| 1045 | - } |
|
| 1046 | - if (!$edit_fact) { |
|
| 1047 | - $family->createFact('1 CHIL @' . $person->getXref() . '@', true); |
|
| 1048 | - } |
|
| 1049 | 1049 | |
| 1050 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1051 | - break; |
|
| 1050 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1051 | + break; |
|
| 1052 | 1052 | |
| 1053 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1054 | -// Link and individual to an existing individual as a spouse |
|
| 1055 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1056 | - case 'linkspouse': |
|
| 1057 | - $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 1058 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1053 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1054 | + // Link and individual to an existing individual as a spouse |
|
| 1055 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1056 | + case 'linkspouse': |
|
| 1057 | + $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 1058 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1059 | 1059 | |
| 1060 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1061 | - check_record_access($person); |
|
| 1060 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1061 | + check_record_access($person); |
|
| 1062 | 1062 | |
| 1063 | - if ($person->getSex() === 'F') { |
|
| 1064 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
| 1065 | - $label = I18N::translate('Husband'); |
|
| 1066 | - } else { |
|
| 1067 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
| 1068 | - $label = I18N::translate('Wife'); |
|
| 1069 | - } |
|
| 1063 | + if ($person->getSex() === 'F') { |
|
| 1064 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
| 1065 | + $label = I18N::translate('Husband'); |
|
| 1066 | + } else { |
|
| 1067 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
| 1068 | + $label = I18N::translate('Wife'); |
|
| 1069 | + } |
|
| 1070 | 1070 | |
| 1071 | - $controller->pageHeader(); |
|
| 1072 | - FunctionsPrint::initializeCalendarPopup(); |
|
| 1071 | + $controller->pageHeader(); |
|
| 1072 | + FunctionsPrint::initializeCalendarPopup(); |
|
| 1073 | 1073 | |
| 1074 | - ?> |
|
| 1074 | + ?> |
|
| 1075 | 1075 | <div id="edit_interface-page"> |
| 1076 | 1076 | <h2><?php echo $controller->getPageTitle(); ?></h2> |
| 1077 | 1077 | <form method="post" name="addchildform" action="edit_interface.php"> |
@@ -1091,17 +1091,17 @@ discard block |
||
| 1091 | 1091 | </td> |
| 1092 | 1092 | </tr> |
| 1093 | 1093 | <?php FunctionsEdit::addSimpleTag('0 MARR Y'); ?> |
| 1094 | - <?php FunctionsEdit::addSimpleTag('0 DATE', 'MARR'); ?> |
|
| 1095 | - <?php FunctionsEdit::addSimpleTag('0 PLAC', 'MARR'); ?> |
|
| 1096 | - <?php echo keep_chan($person); ?> |
|
| 1097 | - </table> |
|
| 1094 | + <?php FunctionsEdit::addSimpleTag('0 DATE', 'MARR'); ?> |
|
| 1095 | + <?php FunctionsEdit::addSimpleTag('0 PLAC', 'MARR'); ?> |
|
| 1096 | + <?php echo keep_chan($person); ?> |
|
| 1097 | + </table> |
|
| 1098 | 1098 | <?php FunctionsEdit::printAddLayer('SOUR'); ?> |
| 1099 | - <?php FunctionsEdit::printAddLayer('OBJE'); ?> |
|
| 1100 | - <?php FunctionsEdit::printAddLayer('NOTE'); ?> |
|
| 1101 | - <?php FunctionsEdit::printAddLayer('SHARED_NOTE'); ?> |
|
| 1102 | - <?php FunctionsEdit::printAddLayer('ASSO'); ?> |
|
| 1103 | - <?php FunctionsEdit::printAddLayer('ASSO2'); ?> |
|
| 1104 | - <?php FunctionsEdit::printAddLayer('RESN'); ?> |
|
| 1099 | + <?php FunctionsEdit::printAddLayer('OBJE'); ?> |
|
| 1100 | + <?php FunctionsEdit::printAddLayer('NOTE'); ?> |
|
| 1101 | + <?php FunctionsEdit::printAddLayer('SHARED_NOTE'); ?> |
|
| 1102 | + <?php FunctionsEdit::printAddLayer('ASSO'); ?> |
|
| 1103 | + <?php FunctionsEdit::printAddLayer('ASSO2'); ?> |
|
| 1104 | + <?php FunctionsEdit::printAddLayer('RESN'); ?> |
|
| 1105 | 1105 | <p id="save-cancel"> |
| 1106 | 1106 | <input type="submit" class="save" value="<?php echo I18N::translate('save'); ?>"> |
| 1107 | 1107 | <input type="button" class="cancel" value="<?php echo I18N::translate('close'); ?>" onclick="window.close();"> |
@@ -1109,74 +1109,74 @@ discard block |
||
| 1109 | 1109 | </form> |
| 1110 | 1110 | </div> |
| 1111 | 1111 | <?php |
| 1112 | - break; |
|
| 1113 | - |
|
| 1114 | - case 'linkspouseaction': |
|
| 1115 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1116 | - $spid = Filter::post('spid', WT_REGEX_XREF); |
|
| 1117 | - $famtag = Filter::post('famtag', 'HUSB|WIFE'); |
|
| 1118 | - $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 1119 | - $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 1120 | - $text = Filter::postArray('text'); |
|
| 1121 | - $islink = Filter::postArray('islink', '[01]'); |
|
| 1112 | + break; |
|
| 1122 | 1113 | |
| 1123 | - if (!Filter::checkCsrf()) { |
|
| 1124 | - $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 1125 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=linkspouse&xref=' . $xref . '&famtag=' . $famtag); |
|
| 1114 | + case 'linkspouseaction': |
|
| 1115 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1116 | + $spid = Filter::post('spid', WT_REGEX_XREF); |
|
| 1117 | + $famtag = Filter::post('famtag', 'HUSB|WIFE'); |
|
| 1118 | + $glevels = Filter::postArray('glevels', '[0-9]'); |
|
| 1119 | + $tag = Filter::postArray('tag', WT_REGEX_TAG); |
|
| 1120 | + $text = Filter::postArray('text'); |
|
| 1121 | + $islink = Filter::postArray('islink', '[01]'); |
|
| 1126 | 1122 | |
| 1127 | - return; |
|
| 1128 | - } |
|
| 1123 | + if (!Filter::checkCsrf()) { |
|
| 1124 | + $famtag = Filter::get('famtag', 'HUSB|WIFE'); |
|
| 1125 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=linkspouse&xref=' . $xref . '&famtag=' . $famtag); |
|
| 1129 | 1126 | |
| 1130 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1131 | - $spouse = Individual::getInstance($spid, $WT_TREE); |
|
| 1132 | - check_record_access($person); |
|
| 1133 | - check_record_access($spouse); |
|
| 1127 | + return; |
|
| 1128 | + } |
|
| 1134 | 1129 | |
| 1135 | - if ($person->getSex() === 'F') { |
|
| 1136 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
| 1137 | - } else { |
|
| 1138 | - $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
| 1139 | - } |
|
| 1140 | - $controller->pageHeader(); |
|
| 1130 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1131 | + $spouse = Individual::getInstance($spid, $WT_TREE); |
|
| 1132 | + check_record_access($person); |
|
| 1133 | + check_record_access($spouse); |
|
| 1141 | 1134 | |
| 1142 | - if ($person->getSex() === 'M') { |
|
| 1143 | - $gedcom = "0 @new@ FAM\n1 HUSB @" . $person->getXref() . "@\n1 WIFE @" . $spouse->getXref() . '@'; |
|
| 1144 | - } else { |
|
| 1145 | - $gedcom = "0 @new@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@'; |
|
| 1146 | - } |
|
| 1147 | - FunctionsEdit::splitSource(); |
|
| 1148 | - $gedcom .= FunctionsEdit::addNewFact('MARR'); |
|
| 1135 | + if ($person->getSex() === 'F') { |
|
| 1136 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a husband using an existing individual')); |
|
| 1137 | + } else { |
|
| 1138 | + $controller->setPageTitle($person->getFullName() . ' - ' . I18N::translate('Add a wife using an existing individual')); |
|
| 1139 | + } |
|
| 1140 | + $controller->pageHeader(); |
|
| 1149 | 1141 | |
| 1150 | - if (Filter::postBool('SOUR_FAM') || count($tagSOUR) > 0) { |
|
| 1151 | - // before adding 2 SOUR it needs to add 1 MARR Y first |
|
| 1152 | - if (FunctionsEdit::addNewFact('MARR') === '') { |
|
| 1153 | - $gedcom .= "\n1 MARR Y"; |
|
| 1142 | + if ($person->getSex() === 'M') { |
|
| 1143 | + $gedcom = "0 @new@ FAM\n1 HUSB @" . $person->getXref() . "@\n1 WIFE @" . $spouse->getXref() . '@'; |
|
| 1144 | + } else { |
|
| 1145 | + $gedcom = "0 @new@ FAM\n1 HUSB @" . $spouse->getXref() . "@\n1 WIFE @" . $person->getXref() . '@'; |
|
| 1154 | 1146 | } |
| 1155 | - $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
| 1156 | - } else { |
|
| 1157 | - // before adding level 2 facts it needs to add 1 MARR Y first |
|
| 1158 | - if (FunctionsEdit::addNewFact('MARR') === '') { |
|
| 1159 | - $gedcom .= "\n1 MARR Y"; |
|
| 1147 | + FunctionsEdit::splitSource(); |
|
| 1148 | + $gedcom .= FunctionsEdit::addNewFact('MARR'); |
|
| 1149 | + |
|
| 1150 | + if (Filter::postBool('SOUR_FAM') || count($tagSOUR) > 0) { |
|
| 1151 | + // before adding 2 SOUR it needs to add 1 MARR Y first |
|
| 1152 | + if (FunctionsEdit::addNewFact('MARR') === '') { |
|
| 1153 | + $gedcom .= "\n1 MARR Y"; |
|
| 1154 | + } |
|
| 1155 | + $gedcom = FunctionsEdit::handleUpdates($gedcom); |
|
| 1156 | + } else { |
|
| 1157 | + // before adding level 2 facts it needs to add 1 MARR Y first |
|
| 1158 | + if (FunctionsEdit::addNewFact('MARR') === '') { |
|
| 1159 | + $gedcom .= "\n1 MARR Y"; |
|
| 1160 | + } |
|
| 1161 | + $gedcom = FunctionsEdit::updateRest($gedcom); |
|
| 1160 | 1162 | } |
| 1161 | - $gedcom = FunctionsEdit::updateRest($gedcom); |
|
| 1162 | - } |
|
| 1163 | 1163 | |
| 1164 | - $family = $person->getTree()->createRecord($gedcom); |
|
| 1165 | - $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 1166 | - $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 1164 | + $family = $person->getTree()->createRecord($gedcom); |
|
| 1165 | + $person->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 1166 | + $spouse->createFact('1 FAMS @' . $family->getXref() . '@', true); |
|
| 1167 | 1167 | |
| 1168 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1169 | - break; |
|
| 1168 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1169 | + break; |
|
| 1170 | 1170 | |
| 1171 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1172 | -// Create a new source record |
|
| 1173 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1174 | - case 'addnewsource': |
|
| 1175 | - $controller |
|
| 1176 | - ->setPageTitle(I18N::translate('Create a source')) |
|
| 1177 | - ->pageHeader(); |
|
| 1171 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1172 | + // Create a new source record |
|
| 1173 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1174 | + case 'addnewsource': |
|
| 1175 | + $controller |
|
| 1176 | + ->setPageTitle(I18N::translate('Create a source')) |
|
| 1177 | + ->pageHeader(); |
|
| 1178 | 1178 | |
| 1179 | - ?> |
|
| 1179 | + ?> |
|
| 1180 | 1180 | <script> |
| 1181 | 1181 | function check_form(frm) { |
| 1182 | 1182 | if (frm.TITL.value=="") { |
@@ -1200,14 +1200,14 @@ discard block |
||
| 1200 | 1200 | <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('ABBR'); ?></td> |
| 1201 | 1201 | <td class="optionbox wrap"><input type="text" name="ABBR" id="ABBR" value="" size="40" maxlength="255"> <?php echo FunctionsPrint::printSpecialCharacterLink('ABBR'); ?></td></tr> |
| 1202 | 1202 | <?php if (strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), "_HEB") !== false) { ?> |
| 1203 | - <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('_HEB'); ?></td> |
|
| 1203 | + <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('_HEB'); ?></td> |
|
| 1204 | 1204 | <td class="optionbox wrap"><input type="text" name="_HEB" id="_HEB" value="" size="60"> <?php echo FunctionsPrint::printSpecialCharacterLink('_HEB'); ?></td></tr> |
| 1205 | 1205 | <?php } ?> |
| 1206 | - <?php if (strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), "ROMN") !== false) { ?> |
|
| 1207 | - <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('ROMN'); ?></td> |
|
| 1206 | + <?php if (strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), "ROMN") !== false) { ?> |
|
| 1207 | + <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('ROMN'); ?></td> |
|
| 1208 | 1208 | <td class="optionbox wrap"><input type="text" name="ROMN" id="ROMN" value="" size="60"> <?php echo FunctionsPrint::printSpecialCharacterLink('ROMN'); ?></td></tr> |
| 1209 | 1209 | <?php } ?> |
| 1210 | - <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('AUTH'); ?></td> |
|
| 1210 | + <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('AUTH'); ?></td> |
|
| 1211 | 1211 | <td class="optionbox wrap"><input type="text" name="AUTH" id="AUTH" value="" size="40" maxlength="255"> <?php echo FunctionsPrint::printSpecialCharacterLink('AUTH'); ?></td></tr> |
| 1212 | 1212 | <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('PUBL'); ?></td> |
| 1213 | 1213 | <td class="optionbox wrap"><textarea name="PUBL" id="PUBL" rows="5" cols="60"></textarea><br><?php echo FunctionsPrint::printSpecialCharacterLink('PUBL'); ?></td></tr> |
@@ -1225,24 +1225,24 @@ discard block |
||
| 1225 | 1225 | <td class="descriptionbox wrap width25"><?php echo I18N::translate('Select events'), FunctionsPrint::helpLink('edit_SOUR_EVEN'); ?></td> |
| 1226 | 1226 | <td class="optionbox wrap"><select name="EVEN[]" multiple="multiple" size="5"> |
| 1227 | 1227 | <?php |
| 1228 | - $parts = explode(',', $WT_TREE->getPreference('INDI_FACTS_ADD')); |
|
| 1229 | - foreach ($parts as $key) { |
|
| 1230 | - ?><option value="<?php echo $key; ?>"><?php echo GedcomTag::getLabel($key); ?></option> |
|
| 1228 | + $parts = explode(',', $WT_TREE->getPreference('INDI_FACTS_ADD')); |
|
| 1229 | + foreach ($parts as $key) { |
|
| 1230 | + ?><option value="<?php echo $key; ?>"><?php echo GedcomTag::getLabel($key); ?></option> |
|
| 1231 | 1231 | <?php |
| 1232 | - } |
|
| 1233 | - $parts = explode(',', $WT_TREE->getPreference('FAM_FACTS_ADD')); |
|
| 1234 | - foreach ($parts as $key) { |
|
| 1235 | - ?><option value="<?php echo $key; ?>"><?php echo GedcomTag::getLabel($key); ?></option> |
|
| 1232 | + } |
|
| 1233 | + $parts = explode(',', $WT_TREE->getPreference('FAM_FACTS_ADD')); |
|
| 1234 | + foreach ($parts as $key) { |
|
| 1235 | + ?><option value="<?php echo $key; ?>"><?php echo GedcomTag::getLabel($key); ?></option> |
|
| 1236 | 1236 | <?php |
| 1237 | - } |
|
| 1238 | - ?> |
|
| 1237 | + } |
|
| 1238 | + ?> |
|
| 1239 | 1239 | </select></td> |
| 1240 | 1240 | </tr> |
| 1241 | 1241 | <?php |
| 1242 | - FunctionsEdit::addSimpleTag('0 DATE', 'EVEN'); |
|
| 1243 | - FunctionsEdit::addSimpleTag('0 PLAC', 'EVEN'); |
|
| 1244 | - FunctionsEdit::addSimpleTag('0 AGNC'); |
|
| 1245 | - ?> |
|
| 1242 | + FunctionsEdit::addSimpleTag('0 DATE', 'EVEN'); |
|
| 1243 | + FunctionsEdit::addSimpleTag('0 PLAC', 'EVEN'); |
|
| 1244 | + FunctionsEdit::addSimpleTag('0 AGNC'); |
|
| 1245 | + ?> |
|
| 1246 | 1246 | </table> |
| 1247 | 1247 | </div> |
| 1248 | 1248 | <p id="save-cancel"> |
@@ -1252,83 +1252,83 @@ discard block |
||
| 1252 | 1252 | </form> |
| 1253 | 1253 | </div> |
| 1254 | 1254 | <?php |
| 1255 | - break; |
|
| 1255 | + break; |
|
| 1256 | 1256 | |
| 1257 | - case 'addsourceaction': |
|
| 1258 | - $controller |
|
| 1259 | - ->setPageTitle(I18N::translate('Create a source')) |
|
| 1260 | - ->pageHeader(); |
|
| 1257 | + case 'addsourceaction': |
|
| 1258 | + $controller |
|
| 1259 | + ->setPageTitle(I18N::translate('Create a source')) |
|
| 1260 | + ->pageHeader(); |
|
| 1261 | 1261 | |
| 1262 | - if (!Filter::checkCsrf()) { |
|
| 1263 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewsource'); |
|
| 1262 | + if (!Filter::checkCsrf()) { |
|
| 1263 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewsource'); |
|
| 1264 | 1264 | |
| 1265 | - return; |
|
| 1266 | - } |
|
| 1265 | + return; |
|
| 1266 | + } |
|
| 1267 | 1267 | |
| 1268 | - $newgedrec = '0 @XREF@ SOUR'; |
|
| 1269 | - $ABBR = Filter::post('ABBR'); |
|
| 1270 | - if ($ABBR) { |
|
| 1271 | - $newgedrec .= "\n1 ABBR " . $ABBR; |
|
| 1272 | - } |
|
| 1273 | - $TITL = Filter::post('TITL'); |
|
| 1274 | - if ($TITL) { |
|
| 1275 | - $newgedrec .= "\n1 TITL " . $TITL; |
|
| 1276 | - $_HEB = Filter::post('_HEB'); |
|
| 1277 | - if ($_HEB) { |
|
| 1278 | - $newgedrec .= "\n2 _HEB " . $_HEB; |
|
| 1268 | + $newgedrec = '0 @XREF@ SOUR'; |
|
| 1269 | + $ABBR = Filter::post('ABBR'); |
|
| 1270 | + if ($ABBR) { |
|
| 1271 | + $newgedrec .= "\n1 ABBR " . $ABBR; |
|
| 1279 | 1272 | } |
| 1280 | - $ROMN = Filter::post('ROMN'); |
|
| 1281 | - if ($ROMN) { |
|
| 1282 | - $newgedrec .= "\n2 ROMN " . $ROMN; |
|
| 1273 | + $TITL = Filter::post('TITL'); |
|
| 1274 | + if ($TITL) { |
|
| 1275 | + $newgedrec .= "\n1 TITL " . $TITL; |
|
| 1276 | + $_HEB = Filter::post('_HEB'); |
|
| 1277 | + if ($_HEB) { |
|
| 1278 | + $newgedrec .= "\n2 _HEB " . $_HEB; |
|
| 1279 | + } |
|
| 1280 | + $ROMN = Filter::post('ROMN'); |
|
| 1281 | + if ($ROMN) { |
|
| 1282 | + $newgedrec .= "\n2 ROMN " . $ROMN; |
|
| 1283 | + } |
|
| 1283 | 1284 | } |
| 1284 | - } |
|
| 1285 | - $AUTH = Filter::post('AUTH'); |
|
| 1286 | - if ($AUTH) { |
|
| 1287 | - $newgedrec .= "\n1 AUTH " . $AUTH; |
|
| 1288 | - } |
|
| 1289 | - $PUBL = Filter::post('PUBL'); |
|
| 1290 | - if ($PUBL) { |
|
| 1291 | - $newgedrec .= "\n1 PUBL " . preg_replace('/\r?\n/', "\n2 CONT ", $PUBL); |
|
| 1292 | - } |
|
| 1293 | - $REPO = Filter::post('REPO', WT_REGEX_XREF); |
|
| 1294 | - if ($REPO) { |
|
| 1295 | - $newgedrec .= "\n1 REPO @" . $REPO . '@'; |
|
| 1296 | - $CALN = Filter::post('CALN'); |
|
| 1297 | - if ($CALN) { |
|
| 1298 | - $newgedrec .= "\n2 CALN " . $CALN; |
|
| 1285 | + $AUTH = Filter::post('AUTH'); |
|
| 1286 | + if ($AUTH) { |
|
| 1287 | + $newgedrec .= "\n1 AUTH " . $AUTH; |
|
| 1299 | 1288 | } |
| 1300 | - } |
|
| 1301 | - $EVEN = Filter::postArray('EVEN', WT_REGEX_TAG); |
|
| 1302 | - if ($EVEN) { |
|
| 1303 | - $newgedrec .= "\n1 DATA"; |
|
| 1304 | - $newgedrec .= "\n2 EVEN " . implode(',', $EVEN); |
|
| 1305 | - $EVEN_DATE = Filter::post('EVEN_DATE'); |
|
| 1306 | - if ($EVEN_DATE) { |
|
| 1307 | - $newgedrec .= "\n3 EVEN_DATE " . $EVEN_DATE; |
|
| 1308 | - } |
|
| 1309 | - $EVEN_PLAC = Filter::post('EVEN_PLAC'); |
|
| 1310 | - if ($EVEN_PLAC) { |
|
| 1311 | - $newgedrec .= "\n3 EVEN_PLAC " . $EVEN_PLAC; |
|
| 1312 | - } |
|
| 1313 | - $AGNC = Filter::post('AGNC'); |
|
| 1314 | - if ($AGNC) { |
|
| 1315 | - $newgedrec .= "\n2 AGNC " . $AGNC; |
|
| 1289 | + $PUBL = Filter::post('PUBL'); |
|
| 1290 | + if ($PUBL) { |
|
| 1291 | + $newgedrec .= "\n1 PUBL " . preg_replace('/\r?\n/', "\n2 CONT ", $PUBL); |
|
| 1292 | + } |
|
| 1293 | + $REPO = Filter::post('REPO', WT_REGEX_XREF); |
|
| 1294 | + if ($REPO) { |
|
| 1295 | + $newgedrec .= "\n1 REPO @" . $REPO . '@'; |
|
| 1296 | + $CALN = Filter::post('CALN'); |
|
| 1297 | + if ($CALN) { |
|
| 1298 | + $newgedrec .= "\n2 CALN " . $CALN; |
|
| 1299 | + } |
|
| 1300 | + } |
|
| 1301 | + $EVEN = Filter::postArray('EVEN', WT_REGEX_TAG); |
|
| 1302 | + if ($EVEN) { |
|
| 1303 | + $newgedrec .= "\n1 DATA"; |
|
| 1304 | + $newgedrec .= "\n2 EVEN " . implode(',', $EVEN); |
|
| 1305 | + $EVEN_DATE = Filter::post('EVEN_DATE'); |
|
| 1306 | + if ($EVEN_DATE) { |
|
| 1307 | + $newgedrec .= "\n3 EVEN_DATE " . $EVEN_DATE; |
|
| 1308 | + } |
|
| 1309 | + $EVEN_PLAC = Filter::post('EVEN_PLAC'); |
|
| 1310 | + if ($EVEN_PLAC) { |
|
| 1311 | + $newgedrec .= "\n3 EVEN_PLAC " . $EVEN_PLAC; |
|
| 1312 | + } |
|
| 1313 | + $AGNC = Filter::post('AGNC'); |
|
| 1314 | + if ($AGNC) { |
|
| 1315 | + $newgedrec .= "\n2 AGNC " . $AGNC; |
|
| 1316 | + } |
|
| 1316 | 1317 | } |
| 1317 | - } |
|
| 1318 | 1318 | |
| 1319 | - $record = $WT_TREE->createRecord($newgedrec); |
|
| 1320 | - $controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");'); |
|
| 1321 | - break; |
|
| 1319 | + $record = $WT_TREE->createRecord($newgedrec); |
|
| 1320 | + $controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");'); |
|
| 1321 | + break; |
|
| 1322 | 1322 | |
| 1323 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1324 | -// Create a new note record |
|
| 1325 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1326 | - case 'addnewnote': |
|
| 1327 | - $controller |
|
| 1328 | - ->setPageTitle(I18N::translate('Create a shared note')) |
|
| 1329 | - ->pageHeader(); |
|
| 1323 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1324 | + // Create a new note record |
|
| 1325 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1326 | + case 'addnewnote': |
|
| 1327 | + $controller |
|
| 1328 | + ->setPageTitle(I18N::translate('Create a shared note')) |
|
| 1329 | + ->pageHeader(); |
|
| 1330 | 1330 | |
| 1331 | - ?> |
|
| 1331 | + ?> |
|
| 1332 | 1332 | <div id="edit_interface-page"> |
| 1333 | 1333 | <h2><?php echo $controller->getPageTitle(); ?></h2> |
| 1334 | 1334 | |
@@ -1337,19 +1337,19 @@ discard block |
||
| 1337 | 1337 | <input type="hidden" name="action" value="addnoteaction"> |
| 1338 | 1338 | <input type="hidden" name="noteid" value="newnote"> |
| 1339 | 1339 | <?php echo Filter::getCsrf(); ?> |
| 1340 | - <?php |
|
| 1341 | - echo '<table class="facts_table">'; |
|
| 1342 | - echo '<tr>'; |
|
| 1343 | - echo '<td class="descriptionbox nowrap">'; |
|
| 1344 | - echo I18N::translate('Shared note'); |
|
| 1345 | - echo '</td>'; |
|
| 1346 | - echo '<td class="optionbox wrap"><textarea name="NOTE" id="NOTE" rows="15" cols="87"></textarea>'; |
|
| 1347 | - echo FunctionsPrint::printSpecialCharacterLink('NOTE'); |
|
| 1348 | - echo '</td>'; |
|
| 1349 | - echo '</tr>'; |
|
| 1350 | - echo keep_chan(); |
|
| 1351 | - echo '</table>'; |
|
| 1352 | - ?> |
|
| 1340 | + <?php |
|
| 1341 | + echo '<table class="facts_table">'; |
|
| 1342 | + echo '<tr>'; |
|
| 1343 | + echo '<td class="descriptionbox nowrap">'; |
|
| 1344 | + echo I18N::translate('Shared note'); |
|
| 1345 | + echo '</td>'; |
|
| 1346 | + echo '<td class="optionbox wrap"><textarea name="NOTE" id="NOTE" rows="15" cols="87"></textarea>'; |
|
| 1347 | + echo FunctionsPrint::printSpecialCharacterLink('NOTE'); |
|
| 1348 | + echo '</td>'; |
|
| 1349 | + echo '</tr>'; |
|
| 1350 | + echo keep_chan(); |
|
| 1351 | + echo '</table>'; |
|
| 1352 | + ?> |
|
| 1353 | 1353 | <p id="save-cancel"> |
| 1354 | 1354 | <input type="submit" class="save" value="<?php echo I18N::translate('save'); ?>"> |
| 1355 | 1355 | <input type="button" class="cancel" value="<?php echo I18N::translate('close'); ?>" onclick="window.close();"> |
@@ -1357,47 +1357,47 @@ discard block |
||
| 1357 | 1357 | </form> |
| 1358 | 1358 | </div> |
| 1359 | 1359 | <?php |
| 1360 | - break; |
|
| 1360 | + break; |
|
| 1361 | 1361 | |
| 1362 | - case 'addnoteaction': |
|
| 1363 | - $controller |
|
| 1364 | - ->setPageTitle(I18N::translate('Create a shared note')) |
|
| 1365 | - ->pageHeader(); |
|
| 1362 | + case 'addnoteaction': |
|
| 1363 | + $controller |
|
| 1364 | + ->setPageTitle(I18N::translate('Create a shared note')) |
|
| 1365 | + ->pageHeader(); |
|
| 1366 | 1366 | |
| 1367 | - if (!Filter::checkCsrf()) { |
|
| 1368 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewnote'); |
|
| 1367 | + if (!Filter::checkCsrf()) { |
|
| 1368 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewnote'); |
|
| 1369 | 1369 | |
| 1370 | - return; |
|
| 1371 | - } |
|
| 1370 | + return; |
|
| 1371 | + } |
|
| 1372 | 1372 | |
| 1373 | - $gedrec = '0 @XREF@ NOTE ' . preg_replace("/\r?\n/", "\n1 CONT ", Filter::post('NOTE')); |
|
| 1373 | + $gedrec = '0 @XREF@ NOTE ' . preg_replace("/\r?\n/", "\n1 CONT ", Filter::post('NOTE')); |
|
| 1374 | 1374 | |
| 1375 | - $record = $WT_TREE->createRecord($gedrec); |
|
| 1376 | - $controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");'); |
|
| 1377 | - break; |
|
| 1375 | + $record = $WT_TREE->createRecord($gedrec); |
|
| 1376 | + $controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");'); |
|
| 1377 | + break; |
|
| 1378 | 1378 | |
| 1379 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1380 | - case 'addnewnote_assisted': |
|
| 1381 | - require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/census/census-edit.php'; |
|
| 1382 | - break; |
|
| 1379 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1380 | + case 'addnewnote_assisted': |
|
| 1381 | + require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/census/census-edit.php'; |
|
| 1382 | + break; |
|
| 1383 | 1383 | |
| 1384 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1385 | - case 'addnoteaction_assisted': |
|
| 1386 | - require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/census/census-save.php'; |
|
| 1387 | - break; |
|
| 1384 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1385 | + case 'addnoteaction_assisted': |
|
| 1386 | + require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/census/census-save.php'; |
|
| 1387 | + break; |
|
| 1388 | 1388 | |
| 1389 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1390 | - case 'addmedia_links': |
|
| 1391 | - $pid = Filter::get('pid', WT_REGEX_XREF); |
|
| 1389 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1390 | + case 'addmedia_links': |
|
| 1391 | + $pid = Filter::get('pid', WT_REGEX_XREF); |
|
| 1392 | 1392 | |
| 1393 | - $person = Individual::getInstance($pid, $WT_TREE); |
|
| 1394 | - check_record_access($person); |
|
| 1393 | + $person = Individual::getInstance($pid, $WT_TREE); |
|
| 1394 | + check_record_access($person); |
|
| 1395 | 1395 | |
| 1396 | - $controller |
|
| 1397 | - ->setPageTitle(I18N::translate('Family navigator') . ' — ' . $person->getFullName()) |
|
| 1398 | - ->pageHeader(); |
|
| 1396 | + $controller |
|
| 1397 | + ->setPageTitle(I18N::translate('Family navigator') . ' — ' . $person->getFullName()) |
|
| 1398 | + ->pageHeader(); |
|
| 1399 | 1399 | |
| 1400 | - ?> |
|
| 1400 | + ?> |
|
| 1401 | 1401 | <div id="edit_interface-page"> |
| 1402 | 1402 | <h2><?php echo $controller->getPageTitle(); ?></h2> |
| 1403 | 1403 | <form method="post" action="edit_interface.php?xref=<?php echo $person->getXref(); ?>" onsubmit="findindi()"> |
@@ -1405,26 +1405,26 @@ discard block |
||
| 1405 | 1405 | <input type="hidden" name="action" value="addmedia_links"> |
| 1406 | 1406 | <input type="hidden" name="noteid" value="newnote"> |
| 1407 | 1407 | <?php echo Filter::getCsrf(); ?> |
| 1408 | - <?php require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/MEDIA_ctrl.php'; ?> |
|
| 1408 | + <?php require WT_ROOT . WT_MODULES_DIR . 'GEDFact_assistant/MEDIA_ctrl.php'; ?> |
|
| 1409 | 1409 | </form> |
| 1410 | 1410 | </div> |
| 1411 | 1411 | <?php |
| 1412 | - break; |
|
| 1412 | + break; |
|
| 1413 | 1413 | |
| 1414 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1415 | -// Edit a note record |
|
| 1416 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1417 | - case 'editnote': |
|
| 1418 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1414 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1415 | + // Edit a note record |
|
| 1416 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1417 | + case 'editnote': |
|
| 1418 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1419 | 1419 | |
| 1420 | - $note = Note::getInstance($xref, $WT_TREE); |
|
| 1421 | - check_record_access($note); |
|
| 1420 | + $note = Note::getInstance($xref, $WT_TREE); |
|
| 1421 | + check_record_access($note); |
|
| 1422 | 1422 | |
| 1423 | - $controller |
|
| 1424 | - ->setPageTitle(I18N::translate('Edit the shared note')) |
|
| 1425 | - ->pageHeader(); |
|
| 1423 | + $controller |
|
| 1424 | + ->setPageTitle(I18N::translate('Edit the shared note')) |
|
| 1425 | + ->pageHeader(); |
|
| 1426 | 1426 | |
| 1427 | - ?> |
|
| 1427 | + ?> |
|
| 1428 | 1428 | <div id="edit_interface-page"> |
| 1429 | 1429 | <h2><?php echo $controller->getPageTitle(); ?></h2> |
| 1430 | 1430 | <form method="post" action="edit_interface.php"> |
@@ -1450,53 +1450,53 @@ discard block |
||
| 1450 | 1450 | </form> |
| 1451 | 1451 | </div> |
| 1452 | 1452 | <?php |
| 1453 | - break; |
|
| 1453 | + break; |
|
| 1454 | 1454 | |
| 1455 | - case 'editnoteaction': |
|
| 1456 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1457 | - $keep_chan = Filter::postBool('keep_chan'); |
|
| 1458 | - $note = Filter::post('NOTE'); |
|
| 1455 | + case 'editnoteaction': |
|
| 1456 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1457 | + $keep_chan = Filter::postBool('keep_chan'); |
|
| 1458 | + $note = Filter::post('NOTE'); |
|
| 1459 | 1459 | |
| 1460 | - if (!Filter::checkCsrf()) { |
|
| 1461 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editnote&xref=' . $xref); |
|
| 1460 | + if (!Filter::checkCsrf()) { |
|
| 1461 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=editnote&xref=' . $xref); |
|
| 1462 | 1462 | |
| 1463 | - return; |
|
| 1464 | - } |
|
| 1463 | + return; |
|
| 1464 | + } |
|
| 1465 | 1465 | |
| 1466 | - $record = Note::getInstance($xref, $WT_TREE); |
|
| 1467 | - check_record_access($record); |
|
| 1466 | + $record = Note::getInstance($xref, $WT_TREE); |
|
| 1467 | + check_record_access($record); |
|
| 1468 | 1468 | |
| 1469 | - $controller |
|
| 1470 | - ->setPageTitle(I18N::translate('Edit the shared note')) |
|
| 1471 | - ->pageHeader(); |
|
| 1469 | + $controller |
|
| 1470 | + ->setPageTitle(I18N::translate('Edit the shared note')) |
|
| 1471 | + ->pageHeader(); |
|
| 1472 | 1472 | |
| 1473 | - // We have user-supplied data in a replacement string - escape it against backreferences |
|
| 1474 | - $note = str_replace(array('\\', '$'), array('\\\\', '\\$'), $note); |
|
| 1473 | + // We have user-supplied data in a replacement string - escape it against backreferences |
|
| 1474 | + $note = str_replace(array('\\', '$'), array('\\\\', '\\$'), $note); |
|
| 1475 | 1475 | |
| 1476 | - $gedrec = preg_replace( |
|
| 1477 | - '/^0 @' . $record->getXref() . '@ NOTE.*(\n1 CONT.*)*/', |
|
| 1478 | - '0 @' . $record->getXref() . '@ NOTE ' . preg_replace("/\r?\n/", "\n1 CONT ", $note), |
|
| 1479 | - $record->getGedcom() |
|
| 1480 | - ); |
|
| 1476 | + $gedrec = preg_replace( |
|
| 1477 | + '/^0 @' . $record->getXref() . '@ NOTE.*(\n1 CONT.*)*/', |
|
| 1478 | + '0 @' . $record->getXref() . '@ NOTE ' . preg_replace("/\r?\n/", "\n1 CONT ", $note), |
|
| 1479 | + $record->getGedcom() |
|
| 1480 | + ); |
|
| 1481 | 1481 | |
| 1482 | - $record->updateRecord($gedrec, !$keep_chan); |
|
| 1482 | + $record->updateRecord($gedrec, !$keep_chan); |
|
| 1483 | 1483 | |
| 1484 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1485 | - break; |
|
| 1484 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1485 | + break; |
|
| 1486 | 1486 | |
| 1487 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1488 | -// Create a new repository |
|
| 1489 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1490 | - case 'addnewrepository': |
|
| 1491 | - $controller |
|
| 1492 | - ->setPageTitle(I18N::translate('Create a repository')) |
|
| 1493 | - ->pageHeader(); |
|
| 1487 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1488 | + // Create a new repository |
|
| 1489 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1490 | + case 'addnewrepository': |
|
| 1491 | + $controller |
|
| 1492 | + ->setPageTitle(I18N::translate('Create a repository')) |
|
| 1493 | + ->pageHeader(); |
|
| 1494 | 1494 | |
| 1495 | - echo '<div id="edit_interface-page">'; |
|
| 1496 | - echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
| 1495 | + echo '<div id="edit_interface-page">'; |
|
| 1496 | + echo '<h2>', $controller->getPageTitle(), '</h2>'; |
|
| 1497 | 1497 | |
| 1498 | - echo '<script>'; |
|
| 1499 | - ?> |
|
| 1498 | + echo '<script>'; |
|
| 1499 | + ?> |
|
| 1500 | 1500 | function check_form(frm) { |
| 1501 | 1501 | if (frm.NAME.value=="") { |
| 1502 | 1502 | alert('<?php echo I18N::translate('You must provide a repository name.'); ?>'); |
@@ -1506,8 +1506,8 @@ discard block |
||
| 1506 | 1506 | return true; |
| 1507 | 1507 | } |
| 1508 | 1508 | <?php |
| 1509 | - echo '</script>'; |
|
| 1510 | - ?> |
|
| 1509 | + echo '</script>'; |
|
| 1510 | + ?> |
|
| 1511 | 1511 | <form method="post" action="edit_interface.php" onsubmit="return check_form(this);"> |
| 1512 | 1512 | <input type="hidden" name="ged" value="<?php echo $WT_TREE->getNameHtml(); ?>"> |
| 1513 | 1513 | <input type="hidden" name="action" value="addrepoaction"> |
@@ -1517,14 +1517,14 @@ discard block |
||
| 1517 | 1517 | <tr><td class="descriptionbox wrap width25"><?php echo I18N::translate('Repository name'); ?></td> |
| 1518 | 1518 | <td class="optionbox wrap"><input type="text" name="REPO_NAME" id="REPO_NAME" value="" size="40" maxlength="255"> <?php echo FunctionsPrint::printSpecialCharacterLink('REPO_NAME'); ?></td></tr> |
| 1519 | 1519 | <?php if (strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), "_HEB") !== false) { ?> |
| 1520 | - <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('_HEB'); ?></td> |
|
| 1520 | + <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('_HEB'); ?></td> |
|
| 1521 | 1521 | <td class="optionbox wrap"><input type="text" name="_HEB" id="_HEB" value="" size="40" maxlength="255"> <?php echo FunctionsPrint::printSpecialCharacterLink('_HEB'); ?></td></tr> |
| 1522 | 1522 | <?php } ?> |
| 1523 | - <?php if (strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), "ROMN") !== false) { ?> |
|
| 1524 | - <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('ROMN'); ?></td> |
|
| 1523 | + <?php if (strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), "ROMN") !== false) { ?> |
|
| 1524 | + <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('ROMN'); ?></td> |
|
| 1525 | 1525 | <td class="optionbox wrap"><input type="text" name="ROMN" id="ROMN" value="" size="40" maxlength="255"> <?php echo FunctionsPrint::printSpecialCharacterLink('ROMN'); ?></td></tr> |
| 1526 | 1526 | <?php } ?> |
| 1527 | - <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('ADDR'); ?></td> |
|
| 1527 | + <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('ADDR'); ?></td> |
|
| 1528 | 1528 | <td class="optionbox wrap"><textarea name="ADDR" id="ADDR" rows="5" cols="60"></textarea><?php echo FunctionsPrint::printSpecialCharacterLink('ADDR'); ?> </td></tr> |
| 1529 | 1529 | <tr><td class="descriptionbox wrap width25"><?php echo GedcomTag::getLabel('PHON'); ?></td> |
| 1530 | 1530 | <td class="optionbox wrap"><input type="text" name="PHON" id="PHON" value="" size="40" maxlength="255"> </td></tr> |
@@ -1541,115 +1541,115 @@ discard block |
||
| 1541 | 1541 | </form> |
| 1542 | 1542 | </div> |
| 1543 | 1543 | <?php |
| 1544 | - break; |
|
| 1545 | - |
|
| 1546 | - case 'addrepoaction': |
|
| 1547 | - if (!Filter::checkCsrf()) { |
|
| 1548 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewrepository'); |
|
| 1544 | + break; |
|
| 1549 | 1545 | |
| 1550 | - return; |
|
| 1551 | - } |
|
| 1546 | + case 'addrepoaction': |
|
| 1547 | + if (!Filter::checkCsrf()) { |
|
| 1548 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=addnewrepository'); |
|
| 1552 | 1549 | |
| 1553 | - $controller |
|
| 1554 | - ->setPageTitle(I18N::translate('Create a repository')) |
|
| 1555 | - ->pageHeader(); |
|
| 1550 | + return; |
|
| 1551 | + } |
|
| 1556 | 1552 | |
| 1557 | - $gedrec = '0 @XREF@ REPO'; |
|
| 1558 | - $REPO_NAME = Filter::post('REPO_NAME'); |
|
| 1559 | - if ($REPO_NAME) { |
|
| 1560 | - $gedrec .= "\n1 NAME " . $REPO_NAME; |
|
| 1561 | - $_HEB = Filter::post('_HEB'); |
|
| 1562 | - if ($_HEB) { |
|
| 1563 | - $gedrec .= "\n2 _HEB " . $_HEB; |
|
| 1553 | + $controller |
|
| 1554 | + ->setPageTitle(I18N::translate('Create a repository')) |
|
| 1555 | + ->pageHeader(); |
|
| 1556 | + |
|
| 1557 | + $gedrec = '0 @XREF@ REPO'; |
|
| 1558 | + $REPO_NAME = Filter::post('REPO_NAME'); |
|
| 1559 | + if ($REPO_NAME) { |
|
| 1560 | + $gedrec .= "\n1 NAME " . $REPO_NAME; |
|
| 1561 | + $_HEB = Filter::post('_HEB'); |
|
| 1562 | + if ($_HEB) { |
|
| 1563 | + $gedrec .= "\n2 _HEB " . $_HEB; |
|
| 1564 | + } |
|
| 1565 | + $ROMN = Filter::post('ROMN'); |
|
| 1566 | + if ($ROMN) { |
|
| 1567 | + $gedrec .= "\n2 ROMN " . $ROMN; |
|
| 1568 | + } |
|
| 1564 | 1569 | } |
| 1565 | - $ROMN = Filter::post('ROMN'); |
|
| 1566 | - if ($ROMN) { |
|
| 1567 | - $gedrec .= "\n2 ROMN " . $ROMN; |
|
| 1570 | + $ADDR = Filter::post('ADDR'); |
|
| 1571 | + if ($ADDR) { |
|
| 1572 | + $gedrec .= "\n1 ADDR " . preg_replace('/\r?\n/', "\n2 CONT ", $ADDR); |
|
| 1573 | + } |
|
| 1574 | + $PHON = Filter::post('PHON'); |
|
| 1575 | + if ($PHON) { |
|
| 1576 | + $gedrec .= "\n1 PHON " . $PHON; |
|
| 1577 | + } |
|
| 1578 | + $FAX = Filter::post('FAX'); |
|
| 1579 | + if ($FAX) { |
|
| 1580 | + $gedrec .= "\n1 FAX " . $FAX; |
|
| 1581 | + } |
|
| 1582 | + $EMAIL = Filter::post('EMAIL'); |
|
| 1583 | + if ($EMAIL) { |
|
| 1584 | + $gedrec .= "\n1 EMAIL " . $EMAIL; |
|
| 1585 | + } |
|
| 1586 | + $WWW = Filter::post('WWW'); |
|
| 1587 | + if ($WWW) { |
|
| 1588 | + $gedrec .= "\n1 WWW " . $WWW; |
|
| 1568 | 1589 | } |
| 1569 | - } |
|
| 1570 | - $ADDR = Filter::post('ADDR'); |
|
| 1571 | - if ($ADDR) { |
|
| 1572 | - $gedrec .= "\n1 ADDR " . preg_replace('/\r?\n/', "\n2 CONT ", $ADDR); |
|
| 1573 | - } |
|
| 1574 | - $PHON = Filter::post('PHON'); |
|
| 1575 | - if ($PHON) { |
|
| 1576 | - $gedrec .= "\n1 PHON " . $PHON; |
|
| 1577 | - } |
|
| 1578 | - $FAX = Filter::post('FAX'); |
|
| 1579 | - if ($FAX) { |
|
| 1580 | - $gedrec .= "\n1 FAX " . $FAX; |
|
| 1581 | - } |
|
| 1582 | - $EMAIL = Filter::post('EMAIL'); |
|
| 1583 | - if ($EMAIL) { |
|
| 1584 | - $gedrec .= "\n1 EMAIL " . $EMAIL; |
|
| 1585 | - } |
|
| 1586 | - $WWW = Filter::post('WWW'); |
|
| 1587 | - if ($WWW) { |
|
| 1588 | - $gedrec .= "\n1 WWW " . $WWW; |
|
| 1589 | - } |
|
| 1590 | 1590 | |
| 1591 | - $record = $WT_TREE->createRecord($gedrec); |
|
| 1592 | - $controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");'); |
|
| 1593 | - break; |
|
| 1591 | + $record = $WT_TREE->createRecord($gedrec); |
|
| 1592 | + $controller->addInlineJavascript('openerpasteid("' . $record->getXref() . '");'); |
|
| 1593 | + break; |
|
| 1594 | 1594 | |
| 1595 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1596 | - case 'editname': |
|
| 1597 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1598 | - $fact_id = Filter::get('fact_id'); |
|
| 1595 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1596 | + case 'editname': |
|
| 1597 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1598 | + $fact_id = Filter::get('fact_id'); |
|
| 1599 | 1599 | |
| 1600 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1601 | - check_record_access($person); |
|
| 1600 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1601 | + check_record_access($person); |
|
| 1602 | 1602 | |
| 1603 | - // Find the fact to edit |
|
| 1604 | - $name_fact = null; |
|
| 1605 | - foreach ($person->getFacts() as $fact) { |
|
| 1606 | - if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
| 1607 | - $name_fact = $fact; |
|
| 1603 | + // Find the fact to edit |
|
| 1604 | + $name_fact = null; |
|
| 1605 | + foreach ($person->getFacts() as $fact) { |
|
| 1606 | + if ($fact->getFactId() === $fact_id && $fact->canEdit()) { |
|
| 1607 | + $name_fact = $fact; |
|
| 1608 | + } |
|
| 1608 | 1609 | } |
| 1609 | - } |
|
| 1610 | - if (!$name_fact) { |
|
| 1611 | - $controller |
|
| 1612 | - ->pageHeader() |
|
| 1613 | - ->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1610 | + if (!$name_fact) { |
|
| 1611 | + $controller |
|
| 1612 | + ->pageHeader() |
|
| 1613 | + ->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1614 | 1614 | |
| 1615 | - return; |
|
| 1616 | - } |
|
| 1615 | + return; |
|
| 1616 | + } |
|
| 1617 | 1617 | |
| 1618 | - $controller |
|
| 1619 | - ->setPageTitle(I18N::translate('Edit the name')) |
|
| 1620 | - ->pageHeader(); |
|
| 1618 | + $controller |
|
| 1619 | + ->setPageTitle(I18N::translate('Edit the name')) |
|
| 1620 | + ->pageHeader(); |
|
| 1621 | 1621 | |
| 1622 | - print_indi_form('update', $person, null, $name_fact, '', $person->getSex()); |
|
| 1622 | + print_indi_form('update', $person, null, $name_fact, '', $person->getSex()); |
|
| 1623 | 1623 | |
| 1624 | - break; |
|
| 1624 | + break; |
|
| 1625 | 1625 | |
| 1626 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1627 | - case 'addname': |
|
| 1628 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1626 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1627 | + case 'addname': |
|
| 1628 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1629 | 1629 | |
| 1630 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1631 | - check_record_access($person); |
|
| 1630 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1631 | + check_record_access($person); |
|
| 1632 | 1632 | |
| 1633 | - $controller |
|
| 1634 | - ->setPageTitle(I18N::translate('Add a name')) |
|
| 1635 | - ->pageHeader(); |
|
| 1633 | + $controller |
|
| 1634 | + ->setPageTitle(I18N::translate('Add a name')) |
|
| 1635 | + ->pageHeader(); |
|
| 1636 | 1636 | |
| 1637 | - print_indi_form('update', $person, null, null, '', $person->getSex()); |
|
| 1638 | - break; |
|
| 1637 | + print_indi_form('update', $person, null, null, '', $person->getSex()); |
|
| 1638 | + break; |
|
| 1639 | 1639 | |
| 1640 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1641 | -// Change the order of media objects |
|
| 1642 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1643 | - case 'reorder_media': |
|
| 1644 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1640 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1641 | + // Change the order of media objects |
|
| 1642 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1643 | + case 'reorder_media': |
|
| 1644 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1645 | 1645 | |
| 1646 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1647 | - check_record_access($person); |
|
| 1646 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1647 | + check_record_access($person); |
|
| 1648 | 1648 | |
| 1649 | - $controller |
|
| 1650 | - ->setPageTitle(I18N::translate('Re-order media')) |
|
| 1651 | - ->pageHeader() |
|
| 1652 | - ->addInlineJavascript(' |
|
| 1649 | + $controller |
|
| 1650 | + ->setPageTitle(I18N::translate('Re-order media')) |
|
| 1651 | + ->pageHeader() |
|
| 1652 | + ->addInlineJavascript(' |
|
| 1653 | 1653 | jQuery("#reorder_media_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"}); |
| 1654 | 1654 | |
| 1655 | 1655 | //-- update the order numbers after drag-n-drop sorting is complete |
@@ -1662,37 +1662,37 @@ discard block |
||
| 1662 | 1662 | }); |
| 1663 | 1663 | '); |
| 1664 | 1664 | |
| 1665 | - // Get the current sort order |
|
| 1666 | - $sort_obje = array(); |
|
| 1667 | - foreach ($person->getFacts('_WT_OBJE_SORT') as $fact) { |
|
| 1668 | - $media = $fact->getTarget(); |
|
| 1669 | - if ($media && $media->canShow()) { |
|
| 1670 | - $sort_obje[] = $media; |
|
| 1665 | + // Get the current sort order |
|
| 1666 | + $sort_obje = array(); |
|
| 1667 | + foreach ($person->getFacts('_WT_OBJE_SORT') as $fact) { |
|
| 1668 | + $media = $fact->getTarget(); |
|
| 1669 | + if ($media && $media->canShow()) { |
|
| 1670 | + $sort_obje[] = $media; |
|
| 1671 | + } |
|
| 1671 | 1672 | } |
| 1672 | - } |
|
| 1673 | 1673 | |
| 1674 | - // Add other media objects from the individual and any spouse-families |
|
| 1675 | - $record_list = array($person); |
|
| 1676 | - foreach ($person->getSpouseFamilies() as $family) { |
|
| 1677 | - $record_list[] = $family; |
|
| 1678 | - } |
|
| 1679 | - foreach ($record_list as $record) { |
|
| 1680 | - if ($record->canShow()) { |
|
| 1681 | - foreach ($record->getFacts() as $fact) { |
|
| 1682 | - if (!$fact->isPendingDeletion()) { |
|
| 1683 | - preg_match_all('/(?:^1|\n\d) OBJE @(' . WT_REGEX_XREF . ')@/', $fact->getGedcom(), $matches); |
|
| 1684 | - foreach ($matches[1] as $match) { |
|
| 1685 | - $media = Media::getInstance($match, $WT_TREE); |
|
| 1686 | - if (!in_array($media, $sort_obje)) { |
|
| 1687 | - $sort_obje[] = $media; |
|
| 1674 | + // Add other media objects from the individual and any spouse-families |
|
| 1675 | + $record_list = array($person); |
|
| 1676 | + foreach ($person->getSpouseFamilies() as $family) { |
|
| 1677 | + $record_list[] = $family; |
|
| 1678 | + } |
|
| 1679 | + foreach ($record_list as $record) { |
|
| 1680 | + if ($record->canShow()) { |
|
| 1681 | + foreach ($record->getFacts() as $fact) { |
|
| 1682 | + if (!$fact->isPendingDeletion()) { |
|
| 1683 | + preg_match_all('/(?:^1|\n\d) OBJE @(' . WT_REGEX_XREF . ')@/', $fact->getGedcom(), $matches); |
|
| 1684 | + foreach ($matches[1] as $match) { |
|
| 1685 | + $media = Media::getInstance($match, $WT_TREE); |
|
| 1686 | + if (!in_array($media, $sort_obje)) { |
|
| 1687 | + $sort_obje[] = $media; |
|
| 1688 | + } |
|
| 1688 | 1689 | } |
| 1689 | 1690 | } |
| 1690 | 1691 | } |
| 1691 | 1692 | } |
| 1692 | 1693 | } |
| 1693 | - } |
|
| 1694 | 1694 | |
| 1695 | - ?> |
|
| 1695 | + ?> |
|
| 1696 | 1696 | <div id="edit_interface-page"> |
| 1697 | 1697 | <h2><?php echo I18N::translate('Re-order media'); ?></h2> |
| 1698 | 1698 | <form name="reorder_form" method="post" action="edit_interface.php"> |
@@ -1700,9 +1700,9 @@ discard block |
||
| 1700 | 1700 | <input type="hidden" name="action" value="reorder_media_update"> |
| 1701 | 1701 | <input type="hidden" name="xref" value="<?php echo $xref; ?>"> |
| 1702 | 1702 | <?php echo Filter::getCsrf(); ?> |
| 1703 | - <ul id="reorder_media_list"> |
|
| 1703 | + <ul id="reorder_media_list"> |
|
| 1704 | 1704 | <?php foreach ($sort_obje as $n => $obje) { ?> |
| 1705 | - <li class="facts_value" style="list-style:none;cursor:move;margin-bottom:2px;" id="li_<?php echo $obje->getXref(); ?>"> |
|
| 1705 | + <li class="facts_value" style="list-style:none;cursor:move;margin-bottom:2px;" id="li_<?php echo $obje->getXref(); ?>"> |
|
| 1706 | 1706 | <table class="pic"> |
| 1707 | 1707 | <tr> |
| 1708 | 1708 | <td> |
@@ -1724,61 +1724,61 @@ discard block |
||
| 1724 | 1724 | </form> |
| 1725 | 1725 | </div> |
| 1726 | 1726 | <?php |
| 1727 | - break; |
|
| 1728 | - |
|
| 1729 | - case 'reorder_media_update': |
|
| 1730 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1731 | - $order1 = Filter::post('order1'); |
|
| 1727 | + break; |
|
| 1732 | 1728 | |
| 1733 | - if (!Filter::checkCsrf()) { |
|
| 1734 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_media_&xref=' . $xref); |
|
| 1729 | + case 'reorder_media_update': |
|
| 1730 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1731 | + $order1 = Filter::post('order1'); |
|
| 1735 | 1732 | |
| 1736 | - return; |
|
| 1737 | - } |
|
| 1733 | + if (!Filter::checkCsrf()) { |
|
| 1734 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_media_&xref=' . $xref); |
|
| 1738 | 1735 | |
| 1739 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1740 | - check_record_access($person); |
|
| 1736 | + return; |
|
| 1737 | + } |
|
| 1741 | 1738 | |
| 1742 | - $controller |
|
| 1743 | - ->setPageTitle(I18N::translate('Re-order media')) |
|
| 1744 | - ->pageHeader(); |
|
| 1739 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 1740 | + check_record_access($person); |
|
| 1745 | 1741 | |
| 1746 | - // Delete any existing _WT_OBJE_SORT records |
|
| 1747 | - $facts = array('0 @' . $person->getXref() . '@ INDI'); |
|
| 1748 | - foreach ($person->getFacts() as $fact) { |
|
| 1749 | - if ($fact->getTag() !== '_WT_OBJE_SORT') { |
|
| 1750 | - $facts[] = $fact->getGedcom(); |
|
| 1742 | + $controller |
|
| 1743 | + ->setPageTitle(I18N::translate('Re-order media')) |
|
| 1744 | + ->pageHeader(); |
|
| 1745 | + |
|
| 1746 | + // Delete any existing _WT_OBJE_SORT records |
|
| 1747 | + $facts = array('0 @' . $person->getXref() . '@ INDI'); |
|
| 1748 | + foreach ($person->getFacts() as $fact) { |
|
| 1749 | + if ($fact->getTag() !== '_WT_OBJE_SORT') { |
|
| 1750 | + $facts[] = $fact->getGedcom(); |
|
| 1751 | + } |
|
| 1751 | 1752 | } |
| 1752 | - } |
|
| 1753 | - if (is_array($order1)) { |
|
| 1754 | - // Add new _WT_OBJE_SORT records |
|
| 1755 | - foreach ($order1 as $xref => $n) { |
|
| 1756 | - $facts[] = '1 _WT_OBJE_SORT @' . $xref . '@'; |
|
| 1753 | + if (is_array($order1)) { |
|
| 1754 | + // Add new _WT_OBJE_SORT records |
|
| 1755 | + foreach ($order1 as $xref => $n) { |
|
| 1756 | + $facts[] = '1 _WT_OBJE_SORT @' . $xref . '@'; |
|
| 1757 | + } |
|
| 1757 | 1758 | } |
| 1758 | - } |
|
| 1759 | 1759 | |
| 1760 | - $person->updateRecord(implode("\n", $facts), false); |
|
| 1760 | + $person->updateRecord(implode("\n", $facts), false); |
|
| 1761 | 1761 | |
| 1762 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1763 | - break; |
|
| 1762 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1763 | + break; |
|
| 1764 | 1764 | |
| 1765 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1766 | -// Change the order of children within a family record |
|
| 1767 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1768 | - case 'reorder_children': |
|
| 1769 | - $xref = Filter::post('xref', WT_REGEX_XREF, Filter::get('xref', WT_REGEX_XREF)); |
|
| 1770 | - $option = Filter::post('option'); |
|
| 1765 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1766 | + // Change the order of children within a family record |
|
| 1767 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1768 | + case 'reorder_children': |
|
| 1769 | + $xref = Filter::post('xref', WT_REGEX_XREF, Filter::get('xref', WT_REGEX_XREF)); |
|
| 1770 | + $option = Filter::post('option'); |
|
| 1771 | 1771 | |
| 1772 | - $family = Family::getInstance($xref, $WT_TREE); |
|
| 1773 | - check_record_access($family); |
|
| 1772 | + $family = Family::getInstance($xref, $WT_TREE); |
|
| 1773 | + check_record_access($family); |
|
| 1774 | 1774 | |
| 1775 | - $controller |
|
| 1776 | - ->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});') |
|
| 1777 | - ->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });') |
|
| 1778 | - ->setPageTitle(I18N::translate('Re-order children')) |
|
| 1779 | - ->pageHeader(); |
|
| 1775 | + $controller |
|
| 1776 | + ->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});') |
|
| 1777 | + ->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });') |
|
| 1778 | + ->setPageTitle(I18N::translate('Re-order children')) |
|
| 1779 | + ->pageHeader(); |
|
| 1780 | 1780 | |
| 1781 | - ?> |
|
| 1781 | + ?> |
|
| 1782 | 1782 | <div id="edit_interface-page"> |
| 1783 | 1783 | <h2><?php echo $controller->getPageTitle(); ?></h2> |
| 1784 | 1784 | <form name="reorder_form" method="post" action="edit_interface.php"> |
@@ -1787,39 +1787,39 @@ discard block |
||
| 1787 | 1787 | <input type="hidden" name="xref" value="<?php echo $xref; ?>"> |
| 1788 | 1788 | <input type="hidden" name="option" value="bybirth"> |
| 1789 | 1789 | <?php echo Filter::getCsrf(); ?> |
| 1790 | - <ul id="reorder_list"> |
|
| 1790 | + <ul id="reorder_list"> |
|
| 1791 | 1791 | <?php |
| 1792 | - // reorder children in modified families |
|
| 1793 | - $ids = array(); |
|
| 1794 | - foreach ($family->getChildren() as $child) { |
|
| 1795 | - $ids[] = $child->getXref(); |
|
| 1796 | - } |
|
| 1797 | - $children = array(); |
|
| 1798 | - foreach ($family->getChildren() as $k => $child) { |
|
| 1799 | - $bdate = $child->getEstimatedBirthDate(); |
|
| 1800 | - if ($bdate->isOK()) { |
|
| 1801 | - $sortkey = $bdate->julianDay(); |
|
| 1802 | - } else { |
|
| 1803 | - $sortkey = 1e8; // birth date missing => sort last |
|
| 1792 | + // reorder children in modified families |
|
| 1793 | + $ids = array(); |
|
| 1794 | + foreach ($family->getChildren() as $child) { |
|
| 1795 | + $ids[] = $child->getXref(); |
|
| 1804 | 1796 | } |
| 1805 | - $children[$child->getXref()] = $sortkey; |
|
| 1806 | - } |
|
| 1807 | - if ($option === 'bybirth') { |
|
| 1808 | - asort($children); |
|
| 1809 | - } |
|
| 1810 | - $i = 0; |
|
| 1811 | - foreach ($children as $id => $child) { |
|
| 1812 | - echo '<li style="cursor:move; margin-bottom:2px; position:relative;"'; |
|
| 1813 | - if (!in_array($id, $ids)) { |
|
| 1814 | - echo ' class="facts_value new"'; |
|
| 1797 | + $children = array(); |
|
| 1798 | + foreach ($family->getChildren() as $k => $child) { |
|
| 1799 | + $bdate = $child->getEstimatedBirthDate(); |
|
| 1800 | + if ($bdate->isOK()) { |
|
| 1801 | + $sortkey = $bdate->julianDay(); |
|
| 1802 | + } else { |
|
| 1803 | + $sortkey = 1e8; // birth date missing => sort last |
|
| 1804 | + } |
|
| 1805 | + $children[$child->getXref()] = $sortkey; |
|
| 1815 | 1806 | } |
| 1816 | - echo ' id="li_', $id, '">'; |
|
| 1817 | - echo Theme::theme()->individualBoxLarge(Individual::getInstance($id, $WT_TREE)); |
|
| 1818 | - echo '<input type="hidden" name="order[', $id, ']" value="', $i, '">'; |
|
| 1819 | - echo '</li>'; |
|
| 1820 | - $i++; |
|
| 1821 | - } |
|
| 1822 | - ?> |
|
| 1807 | + if ($option === 'bybirth') { |
|
| 1808 | + asort($children); |
|
| 1809 | + } |
|
| 1810 | + $i = 0; |
|
| 1811 | + foreach ($children as $id => $child) { |
|
| 1812 | + echo '<li style="cursor:move; margin-bottom:2px; position:relative;"'; |
|
| 1813 | + if (!in_array($id, $ids)) { |
|
| 1814 | + echo ' class="facts_value new"'; |
|
| 1815 | + } |
|
| 1816 | + echo ' id="li_', $id, '">'; |
|
| 1817 | + echo Theme::theme()->individualBoxLarge(Individual::getInstance($id, $WT_TREE)); |
|
| 1818 | + echo '<input type="hidden" name="order[', $id, ']" value="', $i, '">'; |
|
| 1819 | + echo '</li>'; |
|
| 1820 | + $i++; |
|
| 1821 | + } |
|
| 1822 | + ?> |
|
| 1823 | 1823 | </ul> |
| 1824 | 1824 | <p id="save-cancel"> |
| 1825 | 1825 | <input type="submit" class="save" value="<?php echo I18N::translate('save'); ?>"> |
@@ -1829,66 +1829,66 @@ discard block |
||
| 1829 | 1829 | </form> |
| 1830 | 1830 | </div> |
| 1831 | 1831 | <?php |
| 1832 | - break; |
|
| 1832 | + break; |
|
| 1833 | 1833 | |
| 1834 | - case 'reorder_update': |
|
| 1835 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1836 | - $order = Filter::post('order'); |
|
| 1834 | + case 'reorder_update': |
|
| 1835 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 1836 | + $order = Filter::post('order'); |
|
| 1837 | 1837 | |
| 1838 | - if (!Filter::checkCsrf()) { |
|
| 1839 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_children&xref=' . $xref); |
|
| 1838 | + if (!Filter::checkCsrf()) { |
|
| 1839 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_children&xref=' . $xref); |
|
| 1840 | 1840 | |
| 1841 | - return; |
|
| 1842 | - } |
|
| 1841 | + return; |
|
| 1842 | + } |
|
| 1843 | 1843 | |
| 1844 | - $family = Family::getInstance($xref, $WT_TREE); |
|
| 1845 | - check_record_access($family); |
|
| 1844 | + $family = Family::getInstance($xref, $WT_TREE); |
|
| 1845 | + check_record_access($family); |
|
| 1846 | 1846 | |
| 1847 | - $controller |
|
| 1848 | - ->setPageTitle(I18N::translate('Re-order children')) |
|
| 1849 | - ->pageHeader(); |
|
| 1850 | - |
|
| 1851 | - if (is_array($order)) { |
|
| 1852 | - $gedcom = array('0 @' . $family->getXref() . '@ FAM'); |
|
| 1853 | - $facts = $family->getFacts(); |
|
| 1854 | - |
|
| 1855 | - // Move children to the end of the record |
|
| 1856 | - foreach ($order as $child => $num) { |
|
| 1857 | - foreach ($facts as $n => $fact) { |
|
| 1858 | - if ($fact->getValue() === '@' . $child . '@') { |
|
| 1859 | - $facts[] = $fact; |
|
| 1860 | - unset($facts[$n]); |
|
| 1861 | - break; |
|
| 1847 | + $controller |
|
| 1848 | + ->setPageTitle(I18N::translate('Re-order children')) |
|
| 1849 | + ->pageHeader(); |
|
| 1850 | + |
|
| 1851 | + if (is_array($order)) { |
|
| 1852 | + $gedcom = array('0 @' . $family->getXref() . '@ FAM'); |
|
| 1853 | + $facts = $family->getFacts(); |
|
| 1854 | + |
|
| 1855 | + // Move children to the end of the record |
|
| 1856 | + foreach ($order as $child => $num) { |
|
| 1857 | + foreach ($facts as $n => $fact) { |
|
| 1858 | + if ($fact->getValue() === '@' . $child . '@') { |
|
| 1859 | + $facts[] = $fact; |
|
| 1860 | + unset($facts[$n]); |
|
| 1861 | + break; |
|
| 1862 | + } |
|
| 1862 | 1863 | } |
| 1863 | 1864 | } |
| 1864 | - } |
|
| 1865 | - foreach ($facts as $fact) { |
|
| 1866 | - $gedcom[] = $fact->getGedcom(); |
|
| 1867 | - } |
|
| 1865 | + foreach ($facts as $fact) { |
|
| 1866 | + $gedcom[] = $fact->getGedcom(); |
|
| 1867 | + } |
|
| 1868 | 1868 | |
| 1869 | - $family->updateRecord(implode("\n", $gedcom), false); |
|
| 1870 | - } |
|
| 1869 | + $family->updateRecord(implode("\n", $gedcom), false); |
|
| 1870 | + } |
|
| 1871 | 1871 | |
| 1872 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1873 | - break; |
|
| 1872 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 1873 | + break; |
|
| 1874 | 1874 | |
| 1875 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1876 | -// Change the members of a family record |
|
| 1877 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 1878 | - case 'changefamily': |
|
| 1879 | - $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1875 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1876 | + // Change the members of a family record |
|
| 1877 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 1878 | + case 'changefamily': |
|
| 1879 | + $xref = Filter::get('xref', WT_REGEX_XREF); |
|
| 1880 | 1880 | |
| 1881 | - $family = Family::getInstance($xref, $WT_TREE); |
|
| 1882 | - check_record_access($family); |
|
| 1881 | + $family = Family::getInstance($xref, $WT_TREE); |
|
| 1882 | + check_record_access($family); |
|
| 1883 | 1883 | |
| 1884 | - $controller |
|
| 1885 | - ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName()) |
|
| 1886 | - ->pageHeader(); |
|
| 1884 | + $controller |
|
| 1885 | + ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName()) |
|
| 1886 | + ->pageHeader(); |
|
| 1887 | 1887 | |
| 1888 | - $father = $family->getHusband(); |
|
| 1889 | - $mother = $family->getWife(); |
|
| 1890 | - $children = $family->getChildren(); |
|
| 1891 | - ?> |
|
| 1888 | + $father = $family->getHusband(); |
|
| 1889 | + $mother = $family->getWife(); |
|
| 1890 | + $children = $family->getChildren(); |
|
| 1891 | + ?> |
|
| 1892 | 1892 | <div id="edit_interface-page"> |
| 1893 | 1893 | <h2><?php echo $controller->getPageTitle(); ?></h2> |
| 1894 | 1894 | <div id="changefam"> |
@@ -1903,7 +1903,7 @@ discard block |
||
| 1903 | 1903 | <td class="descriptionbox"> |
| 1904 | 1904 | <b> |
| 1905 | 1905 | <?php |
| 1906 | - switch ($father->getSex()) { |
|
| 1906 | + switch ($father->getSex()) { |
|
| 1907 | 1907 | case 'M': |
| 1908 | 1908 | echo I18N::translate('husband'); |
| 1909 | 1909 | break; |
@@ -1913,7 +1913,7 @@ discard block |
||
| 1913 | 1913 | default: |
| 1914 | 1914 | echo I18N::translate('spouse'); |
| 1915 | 1915 | break; |
| 1916 | - } |
|
| 1916 | + } |
|
| 1917 | 1917 | ?> |
| 1918 | 1918 | </b> |
| 1919 | 1919 | <input type="hidden" name="HUSB" value="<?php echo $father->getXref(); ?>"> |
@@ -2042,141 +2042,141 @@ discard block |
||
| 2042 | 2042 | <?php |
| 2043 | 2043 | break; |
| 2044 | 2044 | |
| 2045 | - case 'changefamily_update': |
|
| 2046 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 2047 | - $HUSB = Filter::post('HUSB', WT_REGEX_XREF); |
|
| 2048 | - $WIFE = Filter::post('WIFE', WT_REGEX_XREF); |
|
| 2049 | - $keep_chan = Filter::postBool('keep_chan'); |
|
| 2045 | + case 'changefamily_update': |
|
| 2046 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 2047 | + $HUSB = Filter::post('HUSB', WT_REGEX_XREF); |
|
| 2048 | + $WIFE = Filter::post('WIFE', WT_REGEX_XREF); |
|
| 2049 | + $keep_chan = Filter::postBool('keep_chan'); |
|
| 2050 | 2050 | |
| 2051 | - if (!Filter::checkCsrf()) { |
|
| 2052 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=changefamily&xref=' . $xref); |
|
| 2051 | + if (!Filter::checkCsrf()) { |
|
| 2052 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=changefamily&xref=' . $xref); |
|
| 2053 | 2053 | |
| 2054 | - return; |
|
| 2055 | - } |
|
| 2054 | + return; |
|
| 2055 | + } |
|
| 2056 | 2056 | |
| 2057 | - $CHIL = array(); |
|
| 2058 | - for ($i = 0; isset($_POST['CHIL' . $i]); ++$i) { |
|
| 2059 | - $CHIL[] = Filter::post('CHIL' . $i, WT_REGEX_XREF); |
|
| 2060 | - } |
|
| 2057 | + $CHIL = array(); |
|
| 2058 | + for ($i = 0; isset($_POST['CHIL' . $i]); ++$i) { |
|
| 2059 | + $CHIL[] = Filter::post('CHIL' . $i, WT_REGEX_XREF); |
|
| 2060 | + } |
|
| 2061 | 2061 | |
| 2062 | - $family = Family::getInstance($xref, $WT_TREE); |
|
| 2063 | - check_record_access($family); |
|
| 2062 | + $family = Family::getInstance($xref, $WT_TREE); |
|
| 2063 | + check_record_access($family); |
|
| 2064 | 2064 | |
| 2065 | - $controller |
|
| 2066 | - ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName()) |
|
| 2067 | - ->pageHeader(); |
|
| 2068 | - |
|
| 2069 | - // Current family members |
|
| 2070 | - $old_father = $family->getHusband(); |
|
| 2071 | - $old_mother = $family->getWife(); |
|
| 2072 | - $old_children = $family->getChildren(); |
|
| 2073 | - |
|
| 2074 | - // New family members |
|
| 2075 | - $new_father = Individual::getInstance($HUSB, $WT_TREE); |
|
| 2076 | - $new_mother = Individual::getInstance($WIFE, $WT_TREE); |
|
| 2077 | - $new_children = array(); |
|
| 2078 | - foreach ($CHIL as $child) { |
|
| 2079 | - $new_children[] = Individual::getInstance($child, $WT_TREE); |
|
| 2080 | - } |
|
| 2065 | + $controller |
|
| 2066 | + ->setPageTitle(I18N::translate('Change family members') . ' – ' . $family->getFullName()) |
|
| 2067 | + ->pageHeader(); |
|
| 2068 | + |
|
| 2069 | + // Current family members |
|
| 2070 | + $old_father = $family->getHusband(); |
|
| 2071 | + $old_mother = $family->getWife(); |
|
| 2072 | + $old_children = $family->getChildren(); |
|
| 2073 | + |
|
| 2074 | + // New family members |
|
| 2075 | + $new_father = Individual::getInstance($HUSB, $WT_TREE); |
|
| 2076 | + $new_mother = Individual::getInstance($WIFE, $WT_TREE); |
|
| 2077 | + $new_children = array(); |
|
| 2078 | + foreach ($CHIL as $child) { |
|
| 2079 | + $new_children[] = Individual::getInstance($child, $WT_TREE); |
|
| 2080 | + } |
|
| 2081 | 2081 | |
| 2082 | - if ($old_father !== $new_father) { |
|
| 2083 | - if ($old_father) { |
|
| 2084 | - // Remove old FAMS link |
|
| 2085 | - foreach ($old_father->getFacts('FAMS') as $fact) { |
|
| 2086 | - if ($fact->getTarget() === $family) { |
|
| 2087 | - $old_father->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2082 | + if ($old_father !== $new_father) { |
|
| 2083 | + if ($old_father) { |
|
| 2084 | + // Remove old FAMS link |
|
| 2085 | + foreach ($old_father->getFacts('FAMS') as $fact) { |
|
| 2086 | + if ($fact->getTarget() === $family) { |
|
| 2087 | + $old_father->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2088 | + } |
|
| 2088 | 2089 | } |
| 2089 | - } |
|
| 2090 | - // Remove old HUSB link |
|
| 2091 | - foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
| 2092 | - if ($fact->getTarget() === $old_father) { |
|
| 2093 | - $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2090 | + // Remove old HUSB link |
|
| 2091 | + foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
| 2092 | + if ($fact->getTarget() === $old_father) { |
|
| 2093 | + $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2094 | + } |
|
| 2094 | 2095 | } |
| 2095 | 2096 | } |
| 2097 | + if ($new_father) { |
|
| 2098 | + // Add new FAMS link |
|
| 2099 | + $new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
| 2100 | + // Add new HUSB link |
|
| 2101 | + $family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan); |
|
| 2102 | + } |
|
| 2096 | 2103 | } |
| 2097 | - if ($new_father) { |
|
| 2098 | - // Add new FAMS link |
|
| 2099 | - $new_father->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
| 2100 | - // Add new HUSB link |
|
| 2101 | - $family->createFact('1 HUSB @' . $new_father->getXref() . '@', !$keep_chan); |
|
| 2102 | - } |
|
| 2103 | - } |
|
| 2104 | 2104 | |
| 2105 | - if ($old_mother !== $new_mother) { |
|
| 2106 | - if ($old_mother) { |
|
| 2107 | - // Remove old FAMS link |
|
| 2108 | - foreach ($old_mother->getFacts('FAMS') as $fact) { |
|
| 2109 | - if ($fact->getTarget() === $family) { |
|
| 2110 | - $old_mother->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2105 | + if ($old_mother !== $new_mother) { |
|
| 2106 | + if ($old_mother) { |
|
| 2107 | + // Remove old FAMS link |
|
| 2108 | + foreach ($old_mother->getFacts('FAMS') as $fact) { |
|
| 2109 | + if ($fact->getTarget() === $family) { |
|
| 2110 | + $old_mother->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2111 | + } |
|
| 2111 | 2112 | } |
| 2112 | - } |
|
| 2113 | - // Remove old WIFE link |
|
| 2114 | - foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
| 2115 | - if ($fact->getTarget() === $old_mother) { |
|
| 2116 | - $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2113 | + // Remove old WIFE link |
|
| 2114 | + foreach ($family->getFacts('HUSB|WIFE') as $fact) { |
|
| 2115 | + if ($fact->getTarget() === $old_mother) { |
|
| 2116 | + $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2117 | + } |
|
| 2117 | 2118 | } |
| 2118 | 2119 | } |
| 2120 | + if ($new_mother) { |
|
| 2121 | + // Add new FAMS link |
|
| 2122 | + $new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
| 2123 | + // Add new WIFE link |
|
| 2124 | + $family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan); |
|
| 2125 | + } |
|
| 2119 | 2126 | } |
| 2120 | - if ($new_mother) { |
|
| 2121 | - // Add new FAMS link |
|
| 2122 | - $new_mother->createFact('1 FAMS @' . $family->getXref() . '@', !$keep_chan); |
|
| 2123 | - // Add new WIFE link |
|
| 2124 | - $family->createFact('1 WIFE @' . $new_mother->getXref() . '@', !$keep_chan); |
|
| 2125 | - } |
|
| 2126 | - } |
|
| 2127 | 2127 | |
| 2128 | - foreach ($old_children as $old_child) { |
|
| 2129 | - if ($old_child && !in_array($old_child, $new_children)) { |
|
| 2130 | - // Remove old FAMC link |
|
| 2131 | - foreach ($old_child->getFacts('FAMC') as $fact) { |
|
| 2132 | - if ($fact->getTarget() === $family) { |
|
| 2133 | - $old_child->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2128 | + foreach ($old_children as $old_child) { |
|
| 2129 | + if ($old_child && !in_array($old_child, $new_children)) { |
|
| 2130 | + // Remove old FAMC link |
|
| 2131 | + foreach ($old_child->getFacts('FAMC') as $fact) { |
|
| 2132 | + if ($fact->getTarget() === $family) { |
|
| 2133 | + $old_child->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2134 | + } |
|
| 2134 | 2135 | } |
| 2135 | - } |
|
| 2136 | - // Remove old CHIL link |
|
| 2137 | - foreach ($family->getFacts('CHIL') as $fact) { |
|
| 2138 | - if ($fact->getTarget() === $old_child) { |
|
| 2139 | - $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2136 | + // Remove old CHIL link |
|
| 2137 | + foreach ($family->getFacts('CHIL') as $fact) { |
|
| 2138 | + if ($fact->getTarget() === $old_child) { |
|
| 2139 | + $family->deleteFact($fact->getFactId(), !$keep_chan); |
|
| 2140 | + } |
|
| 2140 | 2141 | } |
| 2141 | 2142 | } |
| 2142 | 2143 | } |
| 2143 | - } |
|
| 2144 | 2144 | |
| 2145 | - foreach ($new_children as $new_child) { |
|
| 2146 | - if ($new_child && !in_array($new_child, $old_children)) { |
|
| 2147 | - // Add new FAMC link |
|
| 2148 | - $new_child->createFact('1 FAMC @' . $family->getXref() . '@', !$keep_chan); |
|
| 2149 | - // Add new CHIL link |
|
| 2150 | - $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
| 2145 | + foreach ($new_children as $new_child) { |
|
| 2146 | + if ($new_child && !in_array($new_child, $old_children)) { |
|
| 2147 | + // Add new FAMC link |
|
| 2148 | + $new_child->createFact('1 FAMC @' . $family->getXref() . '@', !$keep_chan); |
|
| 2149 | + // Add new CHIL link |
|
| 2150 | + $family->createFact('1 CHIL @' . $new_child->getXref() . '@', !$keep_chan); |
|
| 2151 | + } |
|
| 2151 | 2152 | } |
| 2152 | - } |
|
| 2153 | 2153 | |
| 2154 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 2155 | - break; |
|
| 2154 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 2155 | + break; |
|
| 2156 | 2156 | |
| 2157 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 2158 | -// Change the order of FAMS records within an INDI record |
|
| 2159 | -//////////////////////////////////////////////////////////////////////////////// |
|
| 2160 | - case 'reorder_fams': |
|
| 2161 | - $xref = Filter::post('xref', WT_REGEX_XREF, Filter::get('xref', WT_REGEX_XREF)); |
|
| 2162 | - $option = Filter::post('option'); |
|
| 2157 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 2158 | + // Change the order of FAMS records within an INDI record |
|
| 2159 | + //////////////////////////////////////////////////////////////////////////////// |
|
| 2160 | + case 'reorder_fams': |
|
| 2161 | + $xref = Filter::post('xref', WT_REGEX_XREF, Filter::get('xref', WT_REGEX_XREF)); |
|
| 2162 | + $option = Filter::post('option'); |
|
| 2163 | 2163 | |
| 2164 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 2165 | - check_record_access($person); |
|
| 2164 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 2165 | + check_record_access($person); |
|
| 2166 | 2166 | |
| 2167 | - $controller |
|
| 2168 | - ->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});') |
|
| 2169 | - //-- update the order numbers after drag-n-drop sorting is complete |
|
| 2170 | - ->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });') |
|
| 2171 | - ->setPageTitle(I18N::translate('Re-order families')) |
|
| 2172 | - ->pageHeader(); |
|
| 2173 | - |
|
| 2174 | - $fams = $person->getSpouseFamilies(); |
|
| 2175 | - if ($option === 'bymarriage') { |
|
| 2176 | - usort($fams, '\Fisharebest\Webtrees\Family::compareMarrDate'); |
|
| 2177 | - } |
|
| 2167 | + $controller |
|
| 2168 | + ->addInlineJavascript('jQuery("#reorder_list").sortable({forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});') |
|
| 2169 | + //-- update the order numbers after drag-n-drop sorting is complete |
|
| 2170 | + ->addInlineJavascript('jQuery("#reorder_list").bind("sortupdate", function(event, ui) { jQuery("#"+jQuery(this).attr("id")+" input").each( function (index, value) { value.value = index+1; }); });') |
|
| 2171 | + ->setPageTitle(I18N::translate('Re-order families')) |
|
| 2172 | + ->pageHeader(); |
|
| 2173 | + |
|
| 2174 | + $fams = $person->getSpouseFamilies(); |
|
| 2175 | + if ($option === 'bymarriage') { |
|
| 2176 | + usort($fams, '\Fisharebest\Webtrees\Family::compareMarrDate'); |
|
| 2177 | + } |
|
| 2178 | 2178 | |
| 2179 | - ?> |
|
| 2179 | + ?> |
|
| 2180 | 2180 | <div id="edit_interface-page"> |
| 2181 | 2181 | <h2><?php echo $controller->getPageTitle(); ?></h2> |
| 2182 | 2182 | <form name="reorder_form" method="post" action="edit_interface.php"> |
@@ -2185,12 +2185,12 @@ discard block |
||
| 2185 | 2185 | <input type="hidden" name="xref" value="<?php echo $xref; ?>"> |
| 2186 | 2186 | <input type="hidden" name="option" value="bymarriage"> |
| 2187 | 2187 | <?php echo Filter::getCsrf(); ?> |
| 2188 | - <ul id="reorder_list"> |
|
| 2188 | + <ul id="reorder_list"> |
|
| 2189 | 2189 | <?php foreach ($fams as $n => $family) { ?> |
| 2190 | - <li class="facts_value" style="cursor:move;margin-bottom:2px;" id="li_<?php echo $family->getXref(); ?>"> |
|
| 2190 | + <li class="facts_value" style="cursor:move;margin-bottom:2px;" id="li_<?php echo $family->getXref(); ?>"> |
|
| 2191 | 2191 | <div class="name2"><?php echo $family->getFullName(); ?></div> |
| 2192 | 2192 | <?php echo $family->formatFirstMajorFact(WT_EVENTS_MARR, 2); ?> |
| 2193 | - <input type="hidden" name="order[<?php echo $family->getXref(); ?>]" value="<?php echo $n; ?>"> |
|
| 2193 | + <input type="hidden" name="order[<?php echo $family->getXref(); ?>]" value="<?php echo $n; ?>"> |
|
| 2194 | 2194 | </li> |
| 2195 | 2195 | <?php } ?> |
| 2196 | 2196 | </ul> |
@@ -2202,48 +2202,48 @@ discard block |
||
| 2202 | 2202 | </form> |
| 2203 | 2203 | </div> |
| 2204 | 2204 | <?php |
| 2205 | - break; |
|
| 2205 | + break; |
|
| 2206 | 2206 | |
| 2207 | - case 'reorder_fams_update': |
|
| 2208 | - $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 2209 | - $order = Filter::post('order'); |
|
| 2207 | + case 'reorder_fams_update': |
|
| 2208 | + $xref = Filter::post('xref', WT_REGEX_XREF); |
|
| 2209 | + $order = Filter::post('order'); |
|
| 2210 | 2210 | |
| 2211 | - if (!Filter::checkCsrf()) { |
|
| 2212 | - header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_fams&xref=' . $xref); |
|
| 2211 | + if (!Filter::checkCsrf()) { |
|
| 2212 | + header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=reorder_fams&xref=' . $xref); |
|
| 2213 | 2213 | |
| 2214 | - return; |
|
| 2215 | - } |
|
| 2214 | + return; |
|
| 2215 | + } |
|
| 2216 | 2216 | |
| 2217 | - $person = Individual::getInstance($xref, $WT_TREE); |
|
| 2218 | - check_record_access($person); |
|
| 2217 | + $person = Individual::getInstance($xref, $WT_TREE); |
|
| 2218 | + check_record_access($person); |
|
| 2219 | 2219 | |
| 2220 | - $controller |
|
| 2221 | - ->setPageTitle(I18N::translate('Re-order families')) |
|
| 2222 | - ->pageHeader(); |
|
| 2223 | - |
|
| 2224 | - if (is_array($order)) { |
|
| 2225 | - $gedcom = array('0 @' . $person->getXref() . '@ INDI'); |
|
| 2226 | - $facts = $person->getFacts(); |
|
| 2227 | - |
|
| 2228 | - // Move families to the end of the record |
|
| 2229 | - foreach ($order as $family => $num) { |
|
| 2230 | - foreach ($facts as $n => $fact) { |
|
| 2231 | - if ($fact->getValue() === '@' . $family . '@') { |
|
| 2232 | - $facts[] = $fact; |
|
| 2233 | - unset($facts[$n]); |
|
| 2234 | - break; |
|
| 2220 | + $controller |
|
| 2221 | + ->setPageTitle(I18N::translate('Re-order families')) |
|
| 2222 | + ->pageHeader(); |
|
| 2223 | + |
|
| 2224 | + if (is_array($order)) { |
|
| 2225 | + $gedcom = array('0 @' . $person->getXref() . '@ INDI'); |
|
| 2226 | + $facts = $person->getFacts(); |
|
| 2227 | + |
|
| 2228 | + // Move families to the end of the record |
|
| 2229 | + foreach ($order as $family => $num) { |
|
| 2230 | + foreach ($facts as $n => $fact) { |
|
| 2231 | + if ($fact->getValue() === '@' . $family . '@') { |
|
| 2232 | + $facts[] = $fact; |
|
| 2233 | + unset($facts[$n]); |
|
| 2234 | + break; |
|
| 2235 | + } |
|
| 2235 | 2236 | } |
| 2236 | 2237 | } |
| 2237 | - } |
|
| 2238 | - foreach ($facts as $fact) { |
|
| 2239 | - $gedcom[] = $fact->getGedcom(); |
|
| 2240 | - } |
|
| 2238 | + foreach ($facts as $fact) { |
|
| 2239 | + $gedcom[] = $fact->getGedcom(); |
|
| 2240 | + } |
|
| 2241 | 2241 | |
| 2242 | - $person->updateRecord(implode("\n", $gedcom), false); |
|
| 2243 | - } |
|
| 2242 | + $person->updateRecord(implode("\n", $gedcom), false); |
|
| 2243 | + } |
|
| 2244 | 2244 | |
| 2245 | - $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 2246 | - break; |
|
| 2245 | + $controller->addInlineJavascript('closePopupAndReloadParent();'); |
|
| 2246 | + break; |
|
| 2247 | 2247 | } |
| 2248 | 2248 | |
| 2249 | 2249 | /** |