diff options
Diffstat (limited to 'includes/functions')
| -rw-r--r-- | includes/functions/functions_edit.php | 10 | ||||
| -rw-r--r-- | includes/functions/functions_import.php | 10 |
2 files changed, 13 insertions, 7 deletions
diff --git a/includes/functions/functions_edit.php b/includes/functions/functions_edit.php index 1f82bcaffc..fbb2bb28b0 100644 --- a/includes/functions/functions_edit.php +++ b/includes/functions/functions_edit.php @@ -293,21 +293,21 @@ function append_gedrec($gedrec, $ged_id) { } //-- this function will delete the gedcom record with -//-- the given $gid -function delete_gedrec($gid, $ged_id) { +//-- the given $xref +function delete_gedrec($xref, $ged_id) { global $TBLPREFIX; WT_DB::prepare( "INSERT INTO {$TBLPREFIX}change (gedcom_id, xref, old_gedcom, new_gedcom, user_id) VALUES (?, ?, ?, ?, ?)" )->execute(array( $ged_id, - $gid, - find_gedcom_record($gid, $ged_id, true), + $xref, + find_gedcom_record($xref, $ged_id, true), '', WT_USER_ID )); - AddToChangeLog("Deleting gedcom record $gid"); + AddToChangeLog("Deleting gedcom record $xref"); if (WT_USER_AUTO_ACCEPT) { accept_all_changes($xref, WT_GED_ID); diff --git a/includes/functions/functions_import.php b/includes/functions/functions_import.php index 6358ab8c16..a064bc6afa 100644 --- a/includes/functions/functions_import.php +++ b/includes/functions/functions_import.php @@ -1243,14 +1243,20 @@ function accept_all_changes($xref, $ged_id) { global $TBLPREFIX; $changes=WT_DB::prepare( - "SELECT change_id, gedcom_name, new_gedcom". + "SELECT change_id, gedcom_name, old_gedcom, new_gedcom". " FROM {$TBLPREFIX}change c". " JOIN {$TBLPREFIX}gedcom g USING (gedcom_id)". " WHERE c.status='pending' AND xref=? AND gedcom_id=?". " ORDER BY change_id" )->execute(array($xref, $ged_id))->fetchAll(); foreach ($changes as $change) { - update_record($change->new_gedcom, $ged_id, empty($change->new_gedcom)); + if (empty($change->new_gedcom)) { + // delete + update_record($change->old_gedcom, $ged_id, true); + } else { + // add/update + update_record($change->new_gedcom, $ged_id, false); + } WT_DB::prepare( "UPDATE {$TBLPREFIX}change". " SET status='accepted'". |
