requireAcceptLogin() ->setPageTitle(WT_I18N::translate('Pending changes')) ->pageHeader(); $action =safe_GET('action'); $change_id=safe_GET('change_id'); $index =safe_GET('index'); $ged =safe_GET('ged'); echo WT_JS_START; ?> 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; }

', WT_I18N::translate('Pending 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=WT_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 WT_GedcomRecord($change->gedcom); } $output.=''.$record->getFullName().'
'; $output.=''.WT_I18N::translate('View the changes').' | '; $output.="xref."');\">".WT_I18N::translate('View GEDCOM Record')." | "; $output.="xref."');\">".WT_I18N::translate('Edit raw GEDCOM record').'
'; $output.='
'; $output.=WT_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 .= '
'.WT_I18N::translate('Accept').''.WT_I18N::translate('Type').''.WT_I18N::translate('User').''.WT_I18N::translate('Date').''.WT_I18N::translate('Family tree').''.WT_I18N::translate('Undo').'
'.WT_I18N::translate('Accept').''; if ($change->old_gedcom=='') { $output.=WT_I18N::translate('Append record'); } elseif ($change->new_gedcom=='') { $output.=WT_I18N::translate('Delete record'); } else { $output.=WT_I18N::translate('Replace record'); } echo 'user_name."', '".WT_I18N::translate('Moderate pending changes')."')\" alt=\"".WT_I18N::translate('Send Message')."\">"; $output .= PrintReady($change->real_name); $output .= PrintReady(' ('.$change->user_name.')').''.$change->change_time.''.$change->gedcom_name.''.WT_I18N::translate('Undo').'
'; //-- Now for the global Action bar: $output2 = '
'; // Row 1 column 1: title "Accept all" $output2 .= ''; // Row 1 column 2: title "Undo all" $output2 .= ''; // Row 2 column 1: action "Accept all" $output2 .= ''; // Row 2 column 2: action "Undo all" $output2 .= '
'.WT_I18N::translate('Approve all changes').''.WT_I18N::translate('Undo all changes').'
'; $count = 0; foreach ($changed_gedcoms as $gedcom_name) { if ($count!=0) $output2.='
'; $output2 .= ''.$gedcom_name.' - '.WT_I18N::translate('Approve all changes').''; $count ++; } $output2 .= '
'; $count = 0; foreach ($changed_gedcoms as $gedcom_name) { if ($count!=0) { $output2.='
'; } $output2 .= '$gedcom_name - ".WT_I18N::translate('Undo all changes').''; $count++; } $output2 .= '
'; echo $output2, $output, $output2, '

', '', WT_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 '
';