/
edit_changes.php
193 lines (179 loc) · 7.45 KB
/
edit_changes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
/**
* Interface to review/accept/reject changes made by editing online.
*
* phpGedView: Genealogy Viewer
* Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @package PhpGedView
* @subpackage Edit
* @version $Id: edit_changes.php 6879 2010-01-30 11:35:46Z fisharebest $
*/
define('PGV_SCRIPT_NAME', 'edit_changes.php');
require './config.php';
require PGV_ROOT.'includes/functions/functions_edit.php';
if (!PGV_USER_CAN_ACCEPT) {
header('Location: login.php?url=edit_changes.php');
exit;
}
require $INDEX_DIRECTORY.'pgv_changes.php';
$action=safe_GET('action');
$cid =safe_GET('cid');
$index =safe_GET('index');
$ged =safe_GET('ged');
print_simple_header($pgv_lang['review_changes']);
?>
<script language="JavaScript" type="text/javascript">
<!--
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 = '<?php echo PGV_SCRIPT_NAME; ?>';
}
function show_diff(diffurl) {
window.opener.location = diffurl;
return false;
}
//-->
</script>
<?php
echo '<div class="center"><span class="subheaders">', $pgv_lang['review_changes'], '</span><br /><br />';
switch ($action) {
case 'undo':
if (undo_change($cid, $index)) {
echo '<b>', $pgv_lang['undo_successful'], '</b>';
}
break;
case 'accept':
if (accept_changes($cid)) {
echo '<b>', $pgv_lang['accept_successful'], '</b>';
}
break;
case 'undoall':
//-- alert that we only want to save the file and changes once
$manual_save = true;
foreach ($pgv_changes as $cid=>$changes) {
if ($changes[0]['gedcom']==$ged) {
undo_change($cid, 0);
}
}
write_changes();
$manual_save = false;
echo '<b>', $pgv_lang['undo_successful'], '</b>';
break;
case 'acceptall':
//-- only save the file and changes once
$manual_save = true;
foreach ($pgv_changes as $cid=>$changes) {
if ($changes[0]['gedcom']==$ged) {
accept_changes($cid);
}
}
write_changes();
$manual_save = false;
if ($SYNC_GEDCOM_FILE) {
write_file();
}
echo '<b>', $pgv_lang['accept_successful'], '</b>';
break;
}
if (empty($pgv_changes)) {
echo '<br /><br /><b>', $pgv_lang['no_changes'], '</b>';
} else {
$output = '<br /><br /><table class="list_table"><tr><td class="list_value '.$TEXT_DIRECTION.'">';
$changedgedcoms = array();
foreach ($pgv_changes as $cid=>$changes) {
foreach ($changes as $i=>$change) {
if ($i==0) {
$changedgedcoms[$change['gedcom']] = true;
$GEDCOM=$change['gedcom'];
$record=GedcomRecord::getInstance($change['gid']);
$output.='<b>'.PrintReady($record->getFullName()).'</b> '.getLRM().'('.$record->getXref().')'.getLRM().'<br />';
$output.='<a href="javascript:;" onclick="return show_diff(\''.encode_url($record->getLinkUrl().'&show_changes=yes').'\');">'.$pgv_lang['view_change_diff'].'</a> | ';
$output.="<a href=\"javascript:show_gedcom_record('".$change['gid']."');\">".$pgv_lang['view_gedcom']."</a> | ";
$output.="<a href=\"javascript:;\" onclick=\"return edit_raw('".$change['gid']."');\">".$pgv_lang['edit_raw']."</a><br />";
$output.='<div class="indent">';
$output.=$pgv_lang['changes_occurred'].'<br />';
$output.='<table class="list_table"><tr>';
$output.='<td class="list_label">'.$pgv_lang['accept'].'</td>';
$output.='<td class="list_label">'.$pgv_lang['type'].'</td>';
$output.='<td class="list_label">'.$pgv_lang['username'].'</td>';
$output.='<td class="list_label">'.$pgv_lang['date'].'</td>';
$output.='<td class="list_label">GEDCOM</td>';
$output.='<td class="list_label">'.$pgv_lang['undo'].'</td>';
$output.='</tr>';
}
if ($i==count($changes)-1) {
$output .= "<td class=\"list_value $TEXT_DIRECTION\"><a href=\"".encode_url("edit_changes.php?action=accept&cid={$cid}")."\">".$pgv_lang['accept']."</a></td>";
} else {
$output .= "<td class=\"list_value $TEXT_DIRECTION\"> </td>";
}
$output .= "<td class=\"list_value $TEXT_DIRECTION\"><b>".$pgv_lang[$change['type']]."</b></td>";
$output .= "<td class=\"list_value $TEXT_DIRECTION\"><a href=\"javascript:;\" onclick=\"return reply('".$change['user']."', '".$pgv_lang['review_changes']."')\" alt=\"".$pgv_lang['message']."\">";
if ($user_id=get_user_id($change['user'])) {
$output.=PrintReady(getUserFullName($user_id));
}
$output .= PrintReady(" (".$change['user'].")")."</a></td>";
$output .= "<td class=\"list_value $TEXT_DIRECTION\">".format_timestamp($change['time'])."</td>";
$output .= "<td class=\"list_value $TEXT_DIRECTION\">".$change['gedcom']."</td>";
if ($i==count($changes)-1) {
$output .= "<td class=\"list_value $TEXT_DIRECTION\"><a href=\"".encode_url("edit_changes.php?action=undo&cid={$cid}&index={$i}")."\">".$pgv_lang['undo']."</a></td>";
} else {
$output .= "<td class=\"list_value $TEXT_DIRECTION\"> </td>";
}
$output.='</tr>';
if ($i==count($changes)-1) {
$output.='</table></div><br />';
}
}
}
$output .= "</td></tr></table>";
//-- Now for the global Action bar:
$output2 = "<br /><table class=\"list_table\">";
// Row 1 column 1: title "Accept all"
$output2 .= "<tr><td class=\"list_label\">".$pgv_lang['accept_all']."</td>";
// Row 1 column 2: separator
$output2 .= "<td class=\"list_label width25\"> </td>";
// Row 1 column 3: title "Undo all"
$output2 .= "<td class=\"list_label\">".$pgv_lang['undo_all']."</td></tr>";
// Row 2 column 1: action "Accept all"
$output2 .= "<tr><td class=\"list_value\">";
$count = 0;
foreach ($changedgedcoms as $ged=>$value) {
if ($count!=0) $output2.="<br /><br />";
$output2 .= "<a href=\"".encode_url("edit_changes.php?action=acceptall&ged={$ged}")."\">$ged - ".$pgv_lang['accept_all']."</a>";
$count ++;
}
$output2 .= "</td>";
// Row 2 column 2: separator
$output2 .= "<td class=\"list_value width25\"> </td>";
// Row 2 column 3: action "Undo all"
$output2 .= "<td class=\"list_value\">";
$count = 0;
foreach ($changedgedcoms as $ged=>$value) {
if ($count!=0) $output2.="<br /><br />";
$output2 .= "<a href=\"".encode_url("edit_changes.php?action=undoall&ged={$ged}")."\" onclick=\"return confirm('".$pgv_lang['undo_all_confirm']."');\">$ged - ".$pgv_lang['undo_all']."</a>";
$count ++;
}
$output2 .= '</td></tr></table>';
echo '<center>', $pgv_lang['accept_gedcom'], '<br />', $output2, $output, $output2, '</center>';
}
echo '</div>';
echo "<br /><br /><center><a href=\"javascript:;\" onclick=\"if (window.opener.showchanges) window.opener.showchanges(); window.close();\">", $pgv_lang['close_window'], '</a><br /></center>';
print_simple_footer();
?>