function show_gedcom_record(xref) { var recwin = window.open("gedrecord.php?fromfile=1&pid="+xref, "_blank", "top=50, left=50, width=600, height=400, scrollbars=1, scrollable=1, resizable=1"); } function showchanges() { window.location = ''; } function show_diff(diffurl) { window.opener.location = diffurl; return false; } ', i18n::translate('Review GEDCOM changes'), '

'; switch ($action) { case 'undo': $gedcom_id=WT_DB::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); $xref =WT_DB::prepare("SELECT xref FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); // Undo a change, and subsequent changes to the same record WT_DB::prepare( "UPDATE `##change`". " SET status = 'rejected'". " WHERE status = 'pending'". " AND gedcom_id = ?". " AND xref = ?". " AND change_id >= ?" )->execute(array($gedcom_id, $xref, $change_id)); break; case 'accept': $gedcom_id=WT_DB::prepare("SELECT gedcom_id FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); $xref =WT_DB::prepare("SELECT xref FROM `##change` WHERE change_id=?")->execute(array($change_id))->fetchOne(); // Accept a change, and all previous changes to the same record $changes=WT_DB::prepare( "SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom". " FROM `##change` c". " JOIN `##gedcom` g USING (gedcom_id)". " WHERE c.status = 'pending'". " AND gedcom_id = ?". " AND xref = ?". " AND change_id <= ?". " ORDER BY change_id" )->execute(array($gedcom_id, $xref, $change_id))->fetchAll(); foreach ($changes as $change) { 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 `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id)); AddToLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database", 'edit'); } break; case 'undoall': WT_DB::prepare( "UPDATE `##change`". " SET status='rejected'". " WHERE status='pending' AND gedcom_id=?" )->execute(array(get_id_from_gedcom($ged))); break; case 'acceptall': $changes=WT_DB::prepare( "SELECT change_id, gedcom_id, gedcom_name, xref, old_gedcom, new_gedcom". " FROM `##change` c". " JOIN `##gedcom` g USING (gedcom_id)". " WHERE c.status='pending' AND gedcom_id=?". " ORDER BY change_id" )->execute(array(get_id_from_gedcom($ged)))->fetchAll(); foreach ($changes as $change) { 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 `##change` SET status='accepted' WHERE change_id=?")->execute(array($change->change_id)); AddToLog("Accepted change {$change->change_id} for {$change->xref} / {$change->gedcom_name} into database", 'edit'); } break; } $changed_gedcoms=WT_DB::prepare( "SELECT g.gedcom_name". " FROM `##change` c". " JOIN `##gedcom` g USING (gedcom_id)". " WHERE c.status='pending'". " GROUP BY g.gedcom_name" )->fetchOneColumn(); if ($changed_gedcoms) { $changes=WT_DB::prepare( "SELECT c.*, u.user_name, u.real_name, g.gedcom_name, IF(new_gedcom='', old_gedcom, new_gedcom) AS gedcom". " FROM `##change` c". " JOIN `##user` u USING (user_id)". " JOIN `##gedcom` g USING (gedcom_id)". " WHERE c.status='pending'". " ORDER BY gedcom_id, c.xref, c.change_id" )->fetchAll(); $output = '

'; $prev_xref=null; $prev_gedcom_id=null; foreach ($changes as $change) { if ($change->xref!=$prev_xref || $change->gedcom_id!=$prev_gedcom_id) { if ($prev_xref) { $output.='
'; } $prev_xref =$change->xref; $prev_gedcom_id=$change->gedcom_id; $output.=''; $GEDCOM=$change->gedcom_name; $record=GedcomRecord::getInstance($change->xref); if (!$record) { // When a record has been both added and deleted, then // neither the original nor latest version will exist. // This prevents us from displaying it... // This generates a record of some sorts from the last-but-one // version of the record. $record=new GedcomRecord($change->gedcom); } $output.=''.PrintReady($record->getFullName()).' '.getLRM().'('.$record->getXref().')'.getLRM().'
'; $output.=''.i18n::translate('View Change Diff').' | '; $output.="xref."');\">".i18n::translate('View GEDCOM Record')." | "; $output.="xref."');\">".i18n::translate('Edit raw GEDCOM record').'
'; $output.='
'; $output.=i18n::translate('The following changes were made to this record:').'
'; $output.=''; $output.=''; $output.=''; $output.=''; $output.=''; $output.=''; $output.=''; $output.=''; } $output .= ''; $output .= ''; $output .= ""; $output .= ""; $output .= ""; $output .= ""; $output.=''; } $output .= '
'.i18n::translate('Accept').''.i18n::translate('Type').''.i18n::translate('User name').''.i18n::translate('Date').'GEDCOM'.i18n::translate('Undo').'
change_id}").'">'.i18n::translate('Accept').''; if ($change->old_gedcom=='') { $output.=i18n::translate('Append record'); } elseif ($change->new_gedcom=='') { $output.=i18n::translate('Delete record'); } else { $output.=i18n::translate('Replace record'); } echo 'user_name."', '".i18n::translate('Review GEDCOM Changes')."')\" alt=\"".i18n::translate('Send Message')."\">"; $output .= PrintReady($change->real_name); $output .= PrintReady(" (".$change->user_name.")")."".$change->change_time."".$change->gedcom_name."change_id}")."\">".i18n::translate('Undo')."
'; //-- Now for the global Action bar: $output2 = '
'; // Row 1 column 1: title "Accept all" $output2 .= ''; // Row 1 column 2: separator $output2 .= ''; // Row 1 column 3: title "Undo all" $output2 .= ''; // Row 2 column 1: action "Accept all" $output2 .= ''; // Row 2 column 2: separator $output2 .= ''; // Row 2 column 3: action "Undo all" $output2 .= '
'.i18n::translate('Accept all changes').' '.i18n::translate('Undo all changes').'
'; $count = 0; foreach ($changed_gedcoms as $gedcom_name) { if ($count!=0) $output2.='
'; $output2 .= '$gedcom_name - ".i18n::translate('Accept all changes').''; $count ++; } $output2 .= '
 '; $count = 0; foreach ($changed_gedcoms as $gedcom_name) { if ($count!=0) { $output2.='
'; } $output2 .= '$gedcom_name - ".i18n::translate('Undo all changes').''; $count++; } $output2 .= '
'; echo i18n::translate('Decide for each change to either accept or reject it.

To accept all changes at once, click "Accept all changes" in the box below.
To get more information about a change,
click "View change diff" to see the differences,
or click "View GEDCOM record" to see the new data in GEDCOM format.'), '
', $output2, $output, $output2, '

', '', i18n::translate('Close Window'), ''; } else { // No pending changes - refresh the parent window and close this one echo WT_JS_START, 'if (window.opener.showchanges) window.opener.showchanges();', 'window.close();', WT_JS_END; } echo '
'; print_simple_footer();