1 | <?php |
||
2 | /** |
||
3 | * webtrees: online genealogy |
||
4 | * Copyright (C) 2019 webtrees development team |
||
5 | * This program is free software: you can redistribute it and/or modify |
||
6 | * it under the terms of the GNU General Public License as published by |
||
7 | * the Free Software Foundation, either version 3 of the License, or |
||
8 | * (at your option) any later version. |
||
9 | * This program is distributed in the hope that it will be useful, |
||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
12 | * GNU General Public License for more details. |
||
13 | * You should have received a copy of the GNU General Public License |
||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
15 | */ |
||
16 | namespace Fisharebest\Webtrees; |
||
17 | |||
18 | use Fisharebest\Webtrees\Controller\PageController; |
||
19 | use PDO; |
||
20 | use PDOException; |
||
21 | |||
22 | /** |
||
23 | * Defined in session.php |
||
24 | * |
||
25 | * @global Tree $WT_TREE |
||
26 | */ |
||
27 | global $WT_TREE; |
||
28 | |||
29 | define('WT_SCRIPT_NAME', 'admin_pgv_to_wt.php'); |
||
30 | require './includes/session.php'; |
||
31 | |||
32 | // We can only import into an empty system, so deny access if we have already created a gedcom or added users. |
||
33 | if ($WT_TREE || count(User::all()) > 1) { |
||
34 | header('Location: ' . WT_BASE_URL); |
||
35 | |||
36 | return; |
||
37 | } |
||
38 | |||
39 | $controller = new PageController; |
||
40 | $controller |
||
41 | ->restrictAccess(Auth::isAdmin()) |
||
42 | ->setPageTitle(I18N::translate('PhpGedView to webtrees transfer wizard')); |
||
43 | |||
44 | $error = false; |
||
45 | $PGV_PATH = Filter::post('PGV_PATH'); |
||
46 | |||
47 | // We read these variables from PhpGedView's config.php, and set them here in case any are missing. |
||
48 | $INDEX_DIRECTORY = ''; |
||
49 | $DBHOST = ''; |
||
50 | $DBNAME = ''; |
||
51 | $TBLPREFIX = ''; |
||
52 | $PGV_SCHEMA_VERSION = ''; |
||
53 | $USE_REGISTRATION_MODULE = ''; |
||
54 | $ALLOW_USER_THEMES = ''; |
||
55 | $ALLOW_CHANGE_GEDCOM = ''; |
||
56 | $PGV_SESSION_TIME = ''; |
||
57 | $PGV_SMTP_ACTIVE = ''; |
||
58 | $PGV_SMTP_HOST = ''; |
||
59 | $PGV_SMTP_HELO = ''; |
||
60 | $PGV_SMTP_PORT = ''; |
||
61 | $PGV_SMTP_AUTH = ''; |
||
62 | $PGV_SMTP_AUTH_USER = ''; |
||
63 | $PGV_SMTP_AUTH_PASS = ''; |
||
64 | $PGV_SMTP_SSL = ''; |
||
65 | $PGV_SMTP_FROM_NAME = ''; |
||
66 | |||
67 | if ($PGV_PATH) { |
||
68 | if (!is_dir($PGV_PATH) || !is_readable($PGV_PATH . '/config.php')) { |
||
69 | FlashMessages::addMessage('The specified folder does not contain an installation of PhpGedView.', 'danger'); |
||
70 | $PGV_PATH = null; |
||
71 | } else { |
||
72 | // Load the configuration settings |
||
73 | $config_php = file_get_contents($PGV_PATH . '/config.php'); |
||
74 | // The easiest way to do this is to exec() the file - but not lines containing require or PHP tags |
||
75 | $config_php = preg_replace( |
||
76 | array( |
||
77 | '/^\s*(include|require).*/m', |
||
78 | '/.*<\?php.*/', |
||
79 | '/.*\?>.*/', |
||
80 | ), '', $config_php |
||
81 | ); |
||
82 | eval($config_php); |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
83 | // $INDEX_DIRECTORY can be either absolute or relative to the PhpGedView root. |
||
84 | if (preg_match('/^(\/|\\|[A-Z]:)/', $INDEX_DIRECTORY)) { |
||
85 | $INDEX_DIRECTORY = realpath($INDEX_DIRECTORY) . DIRECTORY_SEPARATOR; |
||
86 | } else { |
||
87 | $INDEX_DIRECTORY = realpath($PGV_PATH . '/' . $INDEX_DIRECTORY) . DIRECTORY_SEPARATOR; |
||
88 | } |
||
89 | $wt_config = parse_ini_file(WT_ROOT . 'data/config.ini.php'); |
||
90 | if ($DBHOST != $wt_config['dbhost']) { |
||
91 | FlashMessages::addMessage(I18N::translate('PhpGedView must use the same database as webtrees.', 'danger')); |
||
92 | $PGV_PATH = null; |
||
93 | unset($wt_config); |
||
94 | } else { |
||
95 | unset($wt_config); |
||
96 | try { |
||
97 | $PGV_SCHEMA_VERSION = Database::prepare( |
||
98 | "SELECT site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting` WHERE site_setting_name='PGV_SCHEMA_VERSION'" |
||
99 | )->fetchOne(); |
||
100 | if ($PGV_SCHEMA_VERSION < 10) { |
||
101 | FlashMessages::addMessage(I18N::translate('The version of %s is too old.', 'PhpGedView'), 'danger'); |
||
102 | $PGV_PATH = null; |
||
103 | } elseif ($PGV_SCHEMA_VERSION > 14) { |
||
104 | FlashMessages::addMessage(I18N::translate('The version of %s is too new.', 'PhpGedView'), 'danger'); |
||
105 | $PGV_PATH = null; |
||
106 | } |
||
107 | } catch (PDOException $ex) { |
||
108 | FlashMessages::addMessage( |
||
109 | /* I18N: %s is a database name/identifier */ |
||
110 | I18N::translate('webtrees cannot connect to the PhpGedView database: %s.', $DBNAME . '@' . $DBHOST) . |
||
111 | '<br>' . |
||
112 | /* I18N: %s is an error message */ |
||
113 | I18N::translate('MySQL gave the error: %s', $ex->getMessage()), 'danger' |
||
114 | ); |
||
115 | $PGV_PATH = null; |
||
116 | } |
||
117 | } |
||
118 | } |
||
119 | } |
||
120 | |||
121 | if ($PGV_PATH) { |
||
122 | // The account we are using is about to be deleted. |
||
123 | Session::forget('wt_user'); |
||
124 | } |
||
125 | |||
126 | $controller->pageHeader(); |
||
127 | |||
128 | ?> |
||
129 | <ol class="breadcrumb small"> |
||
130 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
||
131 | <li><a href="admin_trees_manage.php"><?php echo I18N::translate('Manage family trees'); ?></a></li> |
||
132 | <li class="active"><?php echo $controller->getPageTitle(); ?></li> |
||
133 | </ol> |
||
134 | |||
135 | <h1><?php echo $controller->getPageTitle(); ?></h1> |
||
136 | |||
137 | <?php |
||
138 | |||
139 | if (!$PGV_PATH) { |
||
140 | // Look for PhpGedView in some nearby directories |
||
141 | $pgv_dirs = array(); |
||
142 | $dir = opendir(realpath('..')); |
||
143 | while (($subdir = readdir($dir)) !== false) { |
||
144 | // Exclude '..' as ascending too many levels can trigger open_basedir_restriction errors. |
||
145 | if ($subdir !== '..' && is_dir('../' . $subdir) && file_exists('../' . $subdir . '/config.php')) { |
||
146 | $pgv_dirs[] = '../' . $subdir; |
||
147 | } |
||
148 | } |
||
149 | closedir($dir); |
||
150 | |||
151 | if (count($pgv_dirs) > 1) { |
||
152 | $html = I18N::translate('PhpGedView might be installed in one of these folders:'); |
||
153 | foreach ($pgv_dirs as $pgv_dir) { |
||
154 | $html .= '<div onclick="jQuery(\'#PGV_PATH\').val(\'' . Filter::escapeHtml($pgv_dir) . '\')">' . Filter::escapeHtml($pgv_dir) . '</div>'; |
||
155 | } |
||
156 | |||
157 | echo Theme::theme()->htmlAlert($html, 'info', true); |
||
158 | } |
||
159 | ?> |
||
160 | |||
161 | <form class="form-horizontal" method="post"> |
||
162 | <div class="form-group"> |
||
163 | <label class="control-label col-sm-3" for="PGV_PATH"> |
||
164 | <?php echo I18N::translate('Where is your PhpGedView installation?'); ?> |
||
165 | </label> |
||
166 | <div class="col-sm-9"> |
||
167 | <input |
||
168 | type="text" |
||
169 | class="form-control" |
||
170 | dir="ltr" |
||
171 | id="PGV_PATH" |
||
172 | name="PGV_PATH" |
||
173 | size="40" |
||
174 | placeholder="<?php echo I18N::translate('Installation folder'); ?>" |
||
175 | value="<?php echo count($pgv_dirs) === 1 ? Filter::escapeHtml($pgv_dirs[0]) : ''; ?>" |
||
176 | required |
||
177 | > |
||
178 | </div> |
||
179 | </div> |
||
180 | |||
181 | <div class="form-group"> |
||
182 | <div class="col-sm-offset-3 col-sm-9"> |
||
183 | <button type="submit" class="btn btn-primary"> |
||
184 | <?php echo I18N::translate('continue'); ?> |
||
185 | </button> |
||
186 | </div> |
||
187 | </div> |
||
188 | </form> |
||
189 | <?php |
||
190 | |||
191 | return; |
||
192 | } |
||
193 | |||
194 | // Run in a transaction |
||
195 | Database::beginTransaction(); |
||
196 | |||
197 | // Delete the existing user accounts, and any information associated with it |
||
198 | Database::exec("UPDATE `##log` SET user_id=NULL"); |
||
199 | Database::exec("DELETE FROM `##change`"); |
||
200 | Database::exec("DELETE `##block_setting` FROM `##block_setting` JOIN `##block` USING (block_id) WHERE user_id>0 OR gedcom_id>0"); |
||
201 | Database::exec("DELETE FROM `##block` WHERE user_id>0 OR gedcom_id>0"); |
||
202 | Database::exec("DELETE FROM `##message`"); |
||
203 | Database::exec("DELETE FROM `##user_gedcom_setting` WHERE user_id>0"); |
||
204 | Database::exec("DELETE FROM `##user_setting` WHERE user_id>0"); |
||
205 | Database::exec("DELETE FROM `##user` WHERE user_id>0"); |
||
206 | |||
207 | //////////////////////////////////////////////////////////////////////////////// |
||
208 | |||
209 | echo '<p>', $INDEX_DIRECTORY, 'config.php => wt_site_setting…</p>'; |
||
210 | |||
211 | Site::setPreference('USE_REGISTRATION_MODULE', $USE_REGISTRATION_MODULE); |
||
212 | Site::setPreference('ALLOW_USER_THEMES', $ALLOW_USER_THEMES); |
||
213 | Site::setPreference('ALLOW_CHANGE_GEDCOM', $ALLOW_CHANGE_GEDCOM); |
||
214 | Site::setPreference('SESSION_TIME', $PGV_SESSION_TIME); |
||
215 | Site::setPreference('SMTP_ACTIVE', $PGV_SMTP_ACTIVE ? 'external' : 'internal'); |
||
216 | Site::setPreference('SMTP_HOST', $PGV_SMTP_HOST); |
||
217 | Site::setPreference('SMTP_HELO', $PGV_SMTP_HELO); |
||
218 | Site::setPreference('SMTP_PORT', $PGV_SMTP_PORT); |
||
219 | Site::setPreference('SMTP_AUTH', $PGV_SMTP_AUTH); |
||
220 | Site::setPreference('SMTP_AUTH_USER', $PGV_SMTP_AUTH_USER); |
||
221 | Site::setPreference('SMTP_AUTH_PASS', $PGV_SMTP_AUTH_PASS); |
||
222 | Site::setPreference('SMTP_SSL', $PGV_SMTP_SSL); |
||
223 | Site::setPreference('SMTP_FROM_NAME', $PGV_SMTP_FROM_NAME); |
||
224 | |||
225 | //////////////////////////////////////////////////////////////////////////////// |
||
226 | |||
227 | echo '<p>pgv_site_setting => wt_site_setting…</p>'; |
||
228 | |||
229 | Database::prepare( |
||
230 | "REPLACE INTO `##site_setting` (setting_name, setting_value)" . |
||
231 | " SELECT site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`" . |
||
232 | " WHERE site_setting_name IN ('DEFAULT_GEDCOM', 'LAST_CHANGE_EMAIL')" |
||
233 | )->execute(); |
||
234 | |||
235 | //////////////////////////////////////////////////////////////////////////////// |
||
236 | |||
237 | if ($PGV_SCHEMA_VERSION >= 12) { |
||
238 | echo '<p>pgv_gedcom => wt_gedcom…</p>'; |
||
239 | |||
240 | Database::prepare( |
||
241 | "INSERT INTO `##gedcom` (gedcom_id, gedcom_name)" . |
||
242 | " SELECT gedcom_id, gedcom_name FROM `{$DBNAME}`.`{$TBLPREFIX}gedcom`" |
||
243 | )->execute(); |
||
244 | |||
245 | echo '<p>pgv_gedcom_setting => wt_gedcom_setting…</p>'; |
||
246 | |||
247 | Database::prepare( |
||
248 | "INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value)" . |
||
249 | " SELECT gedcom_id, setting_name," . |
||
250 | " CASE setting_name" . |
||
251 | " WHEN 'THEME_DIR' THEN" . |
||
252 | " CASE setting_value" . |
||
253 | " WHEN '' THEN ''" . |
||
254 | " WHEN 'themes/cloudy/' THEN 'clouds'" . |
||
255 | " WHEN 'themes/minimal/' THEN 'minimal'" . |
||
256 | " WHEN 'themes/simplyblue/' THEN 'colors'" . |
||
257 | " WHEN 'themes/simplygreen/' THEN 'colors'" . |
||
258 | " WHEN 'themes/simplyred/' THEN 'colors'" . |
||
259 | " WHEN 'themes/xenea/' THEN 'xenea'" . |
||
260 | " ELSE 'themes/webtrees/'" . // ocean, simplyred/blue/green, standard, wood |
||
261 | " END" . |
||
262 | " WHEN 'LANGUAGE' THEN" . |
||
263 | " CASE setting_value" . |
||
264 | " WHEN 'arabic' THEN 'ar'" . |
||
265 | " WHEN 'catalan' THEN 'ca'" . |
||
266 | " WHEN 'chinese' THEN 'zh_CN'" . |
||
267 | " WHEN 'croatian' THEN 'hr'" . |
||
268 | " WHEN 'danish' THEN 'da'" . |
||
269 | " WHEN 'dutch' THEN 'nl'" . |
||
270 | " WHEN 'english' THEN 'en_US'" . |
||
271 | " WHEN 'english-uk' THEN 'en_GB'" . // PhpGedView once had the config for this, but no language files |
||
272 | " WHEN 'estonian' THEN 'et'" . |
||
273 | " WHEN 'finnish' THEN 'fi'" . |
||
274 | " WHEN 'french' THEN 'fr'" . |
||
275 | " WHEN 'german' THEN 'de'" . |
||
276 | " WHEN 'greek' THEN 'el'" . |
||
277 | " WHEN 'hebrew' THEN 'he'" . |
||
278 | " WHEN 'hungarian' THEN 'hu'" . |
||
279 | " WHEN 'indonesian' THEN 'id'" . |
||
280 | " WHEN 'italian' THEN 'it'" . |
||
281 | " WHEN 'lithuanian' THEN 'lt'" . |
||
282 | " WHEN 'norwegian' THEN 'nn'" . |
||
283 | " WHEN 'polish' THEN 'pl'" . |
||
284 | " WHEN 'portuguese' THEN 'pt'" . |
||
285 | " WHEN 'romainian' THEN 'ro'" . |
||
286 | " WHEN 'russian' THEN 'ru'" . |
||
287 | " WHEN 'serbian-la' THEN 'sr@Latn'" . |
||
288 | " WHEN 'slovak' THEN 'sk'" . |
||
289 | " WHEN 'slovenian' THEN 'sl'" . |
||
290 | " WHEN 'spanish' THEN 'es'" . |
||
291 | " WHEN 'spanish-ar' THEN 'es'" . // webtrees does not yet have this variant |
||
292 | " WHEN 'swedish' THEN 'sv'" . |
||
293 | " WHEN 'turkish' THEN 'tr'" . |
||
294 | " WHEN 'vietnamese' THEN 'vi'" . |
||
295 | " ELSE 'en_US'" . |
||
296 | " END" . |
||
297 | " ELSE setting_value" . |
||
298 | " END" . |
||
299 | " FROM `{$DBNAME}`.`{$TBLPREFIX}gedcom_setting`" . |
||
300 | " WHERE setting_name NOT IN ('HOME_SITE_TEXT', 'HOME_SITE_URL')" |
||
301 | )->execute(); |
||
302 | |||
303 | echo '<p>pgv_user => wt_user…</p>'; |
||
304 | |||
305 | try { |
||
306 | // "INSERT IGNORE" is needed to allow for PhpGedView users with duplicate emails. Only the first will be imported. |
||
307 | Database::prepare( |
||
308 | "INSERT IGNORE INTO `##user` (user_id, user_name, real_name, email, password)" . |
||
309 | " SELECT user_id, user_name, CONCAT_WS(' ', us1.setting_value, us2.setting_value), us3.setting_value, password FROM `{$DBNAME}`.`{$TBLPREFIX}user`" . |
||
310 | " LEFT JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us1 USING (user_id)" . |
||
311 | " LEFT JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us2 USING (user_id)" . |
||
312 | " JOIN `{$DBNAME}`.`{$TBLPREFIX}user_setting` us3 USING (user_id)" . |
||
313 | " WHERE us1.setting_name='firstname'" . |
||
314 | " AND us2.setting_name='lastname'" . |
||
315 | " AND us3.setting_name='email'" |
||
316 | )->execute(); |
||
317 | } catch (PDOException $ex) { |
||
318 | // Ignore duplicates |
||
319 | } |
||
320 | |||
321 | echo '<p>pgv_user_setting => wt_user_setting…</p>'; |
||
322 | |||
323 | Database::prepare( |
||
324 | "INSERT INTO `##user_setting` (user_id, setting_name, setting_value)" . |
||
325 | " SELECT user_id, setting_name," . |
||
326 | " CASE setting_name" . |
||
327 | " WHEN 'language' THEN " . |
||
328 | " CASE setting_value" . |
||
329 | " WHEN 'arabic' THEN 'ar'" . |
||
330 | " WHEN 'catalan' THEN 'ca'" . |
||
331 | " WHEN 'chinese' THEN 'zh_CN'" . |
||
332 | " WHEN 'croatian' THEN 'hr'" . |
||
333 | " WHEN 'danish' THEN 'da'" . |
||
334 | " WHEN 'dutch' THEN 'nl'" . |
||
335 | " WHEN 'english' THEN 'en_US'" . |
||
336 | " WHEN 'english-uk' THEN 'en_GB'" . // PhpGedView once had the config for this, but no language files |
||
337 | " WHEN 'estonian' THEN 'et'" . |
||
338 | " WHEN 'finnish' THEN 'fi'" . |
||
339 | " WHEN 'french' THEN 'fr'" . |
||
340 | " WHEN 'german' THEN 'de'" . |
||
341 | " WHEN 'greek' THEN 'el'" . |
||
342 | " WHEN 'hebrew' THEN 'he'" . |
||
343 | " WHEN 'hungarian' THEN 'hu'" . |
||
344 | " WHEN 'indonesian' THEN 'id'" . |
||
345 | " WHEN 'italian' THEN 'it'" . |
||
346 | " WHEN 'lithuanian' THEN 'lt'" . |
||
347 | " WHEN 'norwegian' THEN 'nn'" . |
||
348 | " WHEN 'polish' THEN 'pl'" . |
||
349 | " WHEN 'portuguese' THEN 'pt'" . |
||
350 | " WHEN 'romainian' THEN 'ro'" . |
||
351 | " WHEN 'russian' THEN 'ru'" . |
||
352 | " WHEN 'serbian-la' THEN 'sr@Latn'" . |
||
353 | " WHEN 'slovak' THEN 'sk'" . |
||
354 | " WHEN 'slovenian' THEN 'sl'" . |
||
355 | " WHEN 'spanish' THEN 'es'" . |
||
356 | " WHEN 'spanish-ar' THEN 'es'" . // webtrees does not yet have this variant |
||
357 | " WHEN 'swedish' THEN 'sv'" . |
||
358 | " WHEN 'turkish' THEN 'tr'" . |
||
359 | " WHEN 'vietnamese' THEN 'vi'" . |
||
360 | " ELSE 'en_US'" . |
||
361 | " END" . |
||
362 | " WHEN 'theme' THEN" . |
||
363 | " CASE setting_value" . |
||
364 | " WHEN '' THEN ''" . |
||
365 | " WHEN 'themes/cloudy/' THEN 'clouds'" . |
||
366 | " WHEN 'themes/minimal/' THEN 'minimal'" . |
||
367 | " WHEN 'themes/simplyblue/' THEN 'colors'" . |
||
368 | " WHEN 'themes/simplygreen/' THEN 'colors'" . |
||
369 | " WHEN 'themes/simplyred/' THEN 'colors'" . |
||
370 | " WHEN 'themes/xenea/' THEN 'xenea'" . |
||
371 | " ELSE 'themes/webtrees/'" . // ocean, simplyred/blue/green, standard, wood |
||
372 | " END" . |
||
373 | " ELSE" . |
||
374 | " CASE" . |
||
375 | " WHEN setting_value IN ('Y', 'yes') THEN 1 WHEN setting_value IN ('N', 'no') THEN 0 ELSE setting_value END" . |
||
376 | " END" . |
||
377 | " FROM `{$DBNAME}`.`{$TBLPREFIX}user_setting`" . |
||
378 | " JOIN `##user` USING (user_id)" . |
||
379 | " WHERE setting_name NOT IN ('email', 'firstname', 'lastname', 'loggedin')" |
||
380 | )->execute(); |
||
381 | |||
382 | echo '<p>pgv_user_gedcom_setting => wt_user_gedcom_setting…</p>'; |
||
383 | |||
384 | Database::prepare( |
||
385 | "INSERT INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value)" . |
||
386 | " SELECT user_id, gedcom_id, setting_name, setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}user_gedcom_setting`" . |
||
387 | " JOIN `##user` USING (user_id)" |
||
388 | )->execute(); |
||
389 | } else { |
||
390 | // Copied from PhpGedView's db_schema_11_12 |
||
391 | if (file_exists($INDEX_DIRECTORY . 'gedcoms.php')) { |
||
392 | require_once $INDEX_DIRECTORY . 'gedcoms.php'; |
||
393 | echo '<p>', $INDEX_DIRECTORY . 'gedcoms.php', ' => wt_gedcom…</p>'; |
||
394 | |||
395 | if (isset($GEDCOMS) && is_array($GEDCOMS)) { |
||
396 | foreach ($GEDCOMS as $array) { |
||
397 | try { |
||
398 | Database::prepare("INSERT INTO `##gedcom` (gedcom_id, gedcom_name) VALUES (?,?)") |
||
399 | ->execute(array($array['id'], $array['gedcom'])); |
||
400 | } catch (PDOException $ex) { |
||
401 | // Ignore duplicates |
||
402 | } |
||
403 | // insert gedcom |
||
404 | foreach ($array as $key => $value) { |
||
405 | if ($key != 'id' && $key != 'gedcom' && $key != 'commonsurnames') { |
||
406 | try { |
||
407 | Database::prepare("INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES (?,?, ?)") |
||
408 | ->execute(array($array['id'], $key, $value)); |
||
409 | } catch (PDOException $ex) { |
||
410 | // Ignore duplicates |
||
411 | } |
||
412 | } |
||
413 | } |
||
414 | } |
||
415 | } |
||
416 | } |
||
417 | |||
418 | // Migrate the data from pgv_users into pgv_user/pgv_user_setting/pgv_user_gedcom_setting |
||
419 | echo '<p>pgv_users => wt_user…</p>'; |
||
420 | |||
421 | try { |
||
422 | // "INSERT IGNORE" is needed to allow for PhpGedView users with duplicate emails. Only the first will be imported. |
||
423 | Database::prepare( |
||
424 | "INSERT IGNORE INTO `##user` (user_name, real_name, email, password)" . |
||
425 | " SELECT u_username, CONCAT_WS(' ', u_firstname, u_lastname), u_email, u_password FROM `{$DBNAME}`.`{$TBLPREFIX}users`" |
||
426 | )->execute(); |
||
427 | } catch (PDOException $ex) { |
||
428 | // This could only fail if; |
||
429 | // a) we've already done it (upgrade) |
||
430 | // b) it doesn't exist (new install) |
||
431 | } |
||
432 | echo '<p>pgv_users => wt_user_setting…</p>'; |
||
433 | |||
434 | try { |
||
435 | Database::prepare( |
||
436 | "INSERT INTO `##user_setting` (user_id, setting_name, setting_value)" . |
||
437 | " SELECT user_id, 'canadmin', " . |
||
438 | " CASE WHEN u_canadmin IN ('Y', 'yes') THEN 1 WHEN u_canadmin IN ('N', 'no') THEN 0 ELSE u_canadmin END" . |
||
439 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
440 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
441 | " UNION ALL" . |
||
442 | " SELECT user_id, 'verified', " . |
||
443 | " CASE WHEN u_verified IN ('Y', 'yes') THEN 1 WHEN u_verified IN ('N', 'no') THEN 0 ELSE u_verified END" . |
||
444 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
445 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
446 | " UNION ALL" . |
||
447 | " SELECT user_id, 'verified_by_admin', " . |
||
448 | " CASE WHEN u_verified_by_admin IN ('Y', 'yes') THEN 1 WHEN u_verified_by_admin IN ('N', 'no') THEN 0 ELSE u_verified_by_admin END" . |
||
449 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
450 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
451 | " UNION ALL" . |
||
452 | " SELECT user_id, 'language', " . |
||
453 | " CASE u_language" . |
||
454 | " WHEN 'catalan' THEN 'ca'" . |
||
455 | " WHEN 'danish' THEN 'da'" . |
||
456 | " WHEN 'dutch' THEN 'nl'" . |
||
457 | " WHEN 'english' THEN 'en_US'" . |
||
458 | " WHEN 'english-uk' THEN 'en_GB'" . // PhpGedView had the config for en_GB, but no language files |
||
459 | " WHEN 'estonian' THEN 'et'" . |
||
460 | " WHEN 'finnish' THEN 'fi'" . |
||
461 | " WHEN 'french' THEN 'fr'" . |
||
462 | " WHEN 'german' THEN 'de'" . |
||
463 | " WHEN 'hebrew' THEN 'he'" . |
||
464 | " WHEN 'hungarian' THEN 'hu'" . |
||
465 | " WHEN 'italian' THEN 'it'" . |
||
466 | " WHEN 'norwegian' THEN 'nn'" . |
||
467 | " WHEN 'polish' THEN 'pl'" . |
||
468 | " WHEN 'portuguese' THEN 'pt'" . |
||
469 | " WHEN 'russian' THEN 'ru'" . |
||
470 | " WHEN 'slovak' THEN 'sk'" . |
||
471 | " WHEN 'slovenian' THEN 'sl'" . |
||
472 | " WHEN 'spanish' THEN 'es'" . |
||
473 | " WHEN 'swedish' THEN 'sv'" . |
||
474 | " WHEN 'turkish' THEN 'tr'" . |
||
475 | " ELSE 'en_US'" . // PhpGedView supports other languages that webtrees does not (yet) |
||
476 | " END" . |
||
477 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
478 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
479 | " UNION ALL" . |
||
480 | " SELECT user_id, 'reg_timestamp', u_reg_timestamp" . |
||
481 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
482 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
483 | " UNION ALL" . |
||
484 | " SELECT user_id, 'reg_hashcode', u_reg_hashcode" . |
||
485 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
486 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
487 | " UNION ALL" . |
||
488 | " SELECT user_id, 'theme', " . |
||
489 | " CASE u_theme" . |
||
490 | " WHEN '' THEN ''" . |
||
491 | " WHEN 'themes/cloudy/' THEN 'clouds'" . |
||
492 | " WHEN 'themes/minimal/' THEN 'minimal'" . |
||
493 | " WHEN 'themes/simplyblue/' THEN 'colors'" . |
||
494 | " WHEN 'themes/simplygreen/' THEN 'colors'" . |
||
495 | " WHEN 'themes/simplyred/' THEN 'colors'" . |
||
496 | " WHEN 'themes/xenea/' THEN 'xenea'" . |
||
497 | " ELSE 'themes/webtrees/'" . // ocean, simplyred/blue/green, standard, wood |
||
498 | " END" . |
||
499 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
500 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
501 | " UNION ALL" . |
||
502 | " SELECT user_id, 'sessiontime', u_sessiontime" . |
||
503 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
504 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
505 | " UNION ALL" . |
||
506 | " SELECT user_id, 'contactmethod', u_contactmethod" . |
||
507 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
508 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
509 | " UNION ALL" . |
||
510 | " SELECT user_id, 'visibleonline', " . |
||
511 | " CASE WHEN u_visibleonline IN ('Y', 'yes') THEN 1 WHEN u_visibleonline IN ('N', 'no') THEN 0 ELSE u_visibleonline END" . |
||
512 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
513 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
514 | " UNION ALL" . |
||
515 | " SELECT user_id, 'comment', u_comment" . |
||
516 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
517 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
518 | " UNION ALL" . |
||
519 | " SELECT user_id, 'relationship_privacy', " . |
||
520 | " CASE WHEN u_relationship_privacy IN ('Y', 'yes') THEN 1 WHEN u_relationship_privacy IN ('N', 'no') THEN 0 ELSE u_relationship_privacy END" . |
||
521 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
522 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
523 | " UNION ALL" . |
||
524 | " SELECT user_id, 'max_relation_path', u_max_relation_path" . |
||
525 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
526 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" . |
||
527 | " UNION ALL" . |
||
528 | " SELECT user_id, 'auto_accept', " . |
||
529 | " CASE WHEN u_auto_accept IN ('Y', 'yes') THEN 1 WHEN u_auto_accept IN ('N', 'no') THEN 0 ELSE u_auto_accept END" . |
||
530 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
531 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" |
||
532 | )->execute(); |
||
533 | } catch (PDOException $ex) { |
||
534 | // This could only fail if; |
||
535 | // a) we've already done it (upgrade) |
||
536 | // b) it doesn't exist (new install) |
||
537 | } |
||
538 | // Some PhpGedView installations store the u_reg_timestamp in the format "2010-03-07 21:41:07" |
||
539 | Database::prepare( |
||
540 | "UPDATE `##user_setting` SET setting_value=UNIX_TIMESTAMP(setting_value) WHERE setting_name='reg_timestamp' AND setting_value LIKE '____-__-__ __:__:__'" |
||
541 | )->execute(); |
||
542 | // Some PhpGedView installations have empty/invalid values for reg_timestamp |
||
543 | Database::prepare( |
||
544 | "UPDATE `##user_setting` SET setting_value=CAST(setting_value AS UNSIGNED) WHERE setting_name='reg_timestamp'" |
||
545 | )->execute(); |
||
546 | echo '<p>pgv_users => wt_user_gedcom_setting…</p>'; |
||
547 | |||
548 | $user_gedcom_settings = |
||
549 | Database::prepare( |
||
550 | "SELECT user_id, u_gedcomid, u_rootid, u_canedit" . |
||
551 | " FROM `{$DBNAME}`.`{$TBLPREFIX}users`" . |
||
552 | " JOIN `##user` ON (user_name=CONVERT(u_username USING utf8) COLLATE utf8_unicode_ci)" |
||
553 | )->fetchAll(); |
||
554 | foreach ($user_gedcom_settings as $setting) { |
||
555 | try { |
||
556 | $array = unserialize($setting->u_gedcomid); |
||
557 | foreach ($array as $gedcom => $value) { |
||
558 | $tree = Tree::findByName($gedcom); |
||
559 | if ($tree !== null) { |
||
560 | Database::prepare( |
||
561 | "INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)" |
||
562 | )->execute(array($setting->user_id, $tree->getTreeId(), 'gedcomid', $value)); |
||
563 | } |
||
564 | } |
||
565 | } catch (\ErrorException $ex) { |
||
566 | // Invalid serialized data? |
||
567 | } |
||
568 | |||
569 | try { |
||
570 | $array = unserialize($setting->u_rootid); |
||
571 | foreach ($array as $gedcom => $value) { |
||
572 | $tree = Tree::findByName($gedcom); |
||
573 | if ($tree !== null) { |
||
574 | Database::prepare( |
||
575 | "INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)" |
||
576 | )->execute(array($setting->user_id, $tree->getTreeId(), 'rootid', $value)); |
||
577 | } |
||
578 | } |
||
579 | } catch (\ErrorException $ex) { |
||
580 | // Invalid serialized data? |
||
581 | } |
||
582 | |||
583 | try { |
||
584 | $array = unserialize($setting->u_canedit); |
||
585 | foreach ($array as $gedcom => $value) { |
||
586 | $tree = Tree::findByName($gedcom); |
||
587 | if ($tree !== null) { |
||
588 | Database::prepare( |
||
589 | "INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)" |
||
590 | )->execute(array($setting->user_id, $tree->getTreeId(), 'canedit', $value)); |
||
591 | } |
||
592 | } |
||
593 | } catch (\ErrorException $ex) { |
||
594 | // Invalid serialized data? |
||
595 | } |
||
596 | } |
||
597 | } |
||
598 | |||
599 | define('PGV_PHPGEDVIEW', true); |
||
600 | define('PGV_PRIV_PUBLIC', Auth::PRIV_PRIVATE); |
||
601 | define('PGV_PRIV_USER', Auth::PRIV_USER); |
||
602 | define('PGV_PRIV_NONE', Auth::PRIV_NONE); |
||
603 | define('PGV_PRIV_HIDE', Auth::PRIV_HIDE); |
||
604 | $PRIV_PUBLIC = Auth::PRIV_PRIVATE; |
||
605 | $PRIV_USER = Auth::PRIV_USER; |
||
606 | $PRIV_NONE = Auth::PRIV_NONE; |
||
607 | $PRIV_HIDE = Auth::PRIV_HIDE; |
||
608 | |||
609 | // Old versions of PhpGedView used a $GEDCOMS[] array. |
||
610 | // New versions used a database. |
||
611 | $GEDCOMS = Database::prepare( |
||
612 | "SELECT" . |
||
613 | " gedcom_id AS id," . |
||
614 | " gedcom_name AS gedcom," . |
||
615 | " gs1.setting_value AS config," . |
||
616 | " gs2.setting_value AS privacy" . |
||
617 | " FROM `##gedcom`" . |
||
618 | " JOIN `##gedcom_setting` AS gs1 USING (gedcom_id)" . |
||
619 | " JOIN `##gedcom_setting` AS gs2 USING (gedcom_id)" . |
||
620 | " WHERE gedcom_id>0" . |
||
621 | " AND gs1.setting_name='config'" . |
||
622 | " AND gs2.setting_name='privacy'" |
||
623 | )->fetchAll(PDO::FETCH_ASSOC); |
||
624 | |||
625 | foreach ($GEDCOMS as $GEDCOM => $GED_DATA) { |
||
626 | // We read these variables from PhpGedView's index/*_conf.php, and set them here in case any are missing. |
||
627 | $ADVANCED_NAME_FACTS = ''; |
||
628 | $ADVANCED_PLAC_FACTS = ''; |
||
629 | $ALLOW_THEME_DROPDOWN = ''; |
||
630 | $CALENDAR_FORMAT = ''; |
||
631 | $CHART_BOX_TAGS = ''; |
||
632 | $CONTACT_EMAIL = ''; |
||
633 | $DEFAULT_PEDIGREE_GENERATIONS = ''; |
||
634 | $EXPAND_NOTES = ''; |
||
635 | $EXPAND_RELATIVES_EVENTS = ''; |
||
636 | $EXPAND_SOURCES = ''; |
||
637 | $FAM_FACTS_ADD = ''; |
||
638 | $FAM_FACTS_QUICK = ''; |
||
639 | $FAM_FACTS_UNIQUE = ''; |
||
640 | $FAM_ID_PREFIX = ''; |
||
641 | $FULL_SOURCES = ''; |
||
642 | $GEDCOM_ID_PREFIX = ''; |
||
643 | $GENERATE_UIDS = ''; |
||
644 | $HIDE_GEDCOM_ERRORS = ''; |
||
645 | $HIDE_LIVE_PEOPLE = ''; |
||
646 | $INDI_FACTS_ADD = ''; |
||
647 | $INDI_FACTS_QUICK = ''; |
||
648 | $INDI_FACTS_UNIQUE = ''; |
||
649 | $LANGUAGE = ''; |
||
650 | $MAX_ALIVE_AGE = ''; |
||
651 | $MAX_DESCENDANCY_GENERATIONS = ''; |
||
652 | $MAX_PEDIGREE_GENERATIONS = ''; |
||
653 | $MAX_RELATION_PATH_LENGTH = ''; |
||
654 | $MEDIA_ID_PREFIX = ''; |
||
655 | $META_DESCRIPTION = ''; |
||
656 | $META_TITLE = ''; |
||
657 | $MULTI_MEDIA = ''; |
||
658 | $NOTE_FACTS_ADD = ''; |
||
659 | $NOTE_FACTS_QUICK = ''; |
||
660 | $NOTE_FACTS_UNIQUE = ''; |
||
661 | $NO_UPDATE_CHAN = ''; |
||
662 | $PEDIGREE_FULL_DETAILS = ''; |
||
663 | $PEDIGREE_LAYOUT = ''; |
||
664 | $PEDIGREE_ROOT_ID = ''; |
||
665 | $PEDIGREE_SHOW_GENDER = ''; |
||
666 | $PREFER_LEVEL2_SOURCES = ''; |
||
667 | $QUICK_REQUIRED_FACTS = ''; |
||
668 | $QUICK_REQUIRED_FAMFACTS = ''; |
||
669 | $REPO_FACTS_ADD = ''; |
||
670 | $REPO_FACTS_QUICK = ''; |
||
671 | $REPO_FACTS_UNIQUE = ''; |
||
672 | $REPO_ID_PREFIX = ''; |
||
673 | $REQUIRE_AUTHENTICATION = ''; |
||
674 | $SAVE_WATERMARK_IMAGE = ''; |
||
675 | $SAVE_WATERMARK_THUMB = ''; |
||
676 | $SHOW_AGE_DIFF = ''; |
||
677 | $SHOW_COUNTER = ''; |
||
678 | $SHOW_DEAD_PEOPLE = ''; |
||
679 | $SHOW_EST_LIST_DATES = ''; |
||
680 | $SHOW_FACT_ICONS = ''; |
||
681 | $SHOW_GEDCOM_RECORD = ''; |
||
682 | $SHOW_HIGHLIGHT_IMAGES = ''; |
||
683 | $SHOW_LDS_AT_GLANCE = ''; |
||
684 | $SHOW_LEVEL2_NOTES = ''; |
||
685 | $SHOW_LIST_PLACES = ''; |
||
686 | $SHOW_LIVING_NAMES = ''; |
||
687 | $SHOW_MEDIA_DOWNLOAD = ''; |
||
688 | $SHOW_PARENTS_AGE = ''; |
||
689 | $SHOW_PEDIGREE_PLACES = ''; |
||
690 | $SHOW_PRIVATE_RELATIONSHIPS = ''; |
||
691 | $SHOW_RELATIVES_EVENTS = ''; |
||
692 | $SOURCE_ID_PREFIX = ''; |
||
693 | $SOUR_FACTS_ADD = ''; |
||
694 | $SOUR_FACTS_QUICK = ''; |
||
695 | $SOUR_FACTS_UNIQUE = ''; |
||
696 | $SUBLIST_TRIGGER_I = ''; |
||
697 | $SURNAME_LIST_STYLE = ''; |
||
698 | $SURNAME_TRADITION = ''; |
||
699 | $THEME_DIR = ''; |
||
700 | $THUMBNAIL_WIDTH = ''; |
||
701 | $USE_RELATIONSHIP_PRIVACY = ''; |
||
702 | $USE_RIN = ''; |
||
703 | $WATERMARK_THUMB = ''; |
||
704 | $WEBMASTER_EMAIL = ''; |
||
705 | $WORD_WRAPPED_NOTES = ''; |
||
706 | |||
707 | $config = str_replace(array('$INDEX_DIRECTORY', '${INDEX_DIRECTORY}'), $INDEX_DIRECTORY, $GED_DATA['config']); |
||
708 | if (substr($config, 0, 1) === '.') { |
||
709 | $config = $PGV_PATH . '/' . $config; |
||
710 | } |
||
711 | if (is_readable($config)) { |
||
712 | echo '<p>Reading configuration file ', $config, '</p>'; |
||
713 | require $config; |
||
714 | } else { |
||
715 | echo '<p>Error - could not read configuration file ', $config, '</p>'; |
||
716 | } |
||
717 | |||
718 | $stmt_default_resn = Database::prepare("INSERT INTO `##default_resn` (gedcom_id, xref, tag_type, resn) VALUES (?, ?, ?, CASE ? WHEN -1 THEN 'hidden' WHEN 0 THEN 'confidential' WHEN 1 THEN 'privacy' ELSE 'none' END)"); |
||
719 | $stmt_gedcom_setting = Database::prepare("INSERT INTO `##gedcom_setting` (gedcom_id, setting_name, setting_value) VALUES (?,?,?)"); |
||
720 | |||
721 | $privacy = str_replace(array('$INDEX_DIRECTORY', '${INDEX_DIRECTORY}'), $INDEX_DIRECTORY, $GED_DATA['privacy']); |
||
722 | if (substr($config, 0, 1) == '.') { |
||
723 | $privacy = $PGV_PATH . '/' . $privacy; |
||
724 | } |
||
725 | if (is_readable($privacy)) { |
||
726 | // initialise this, in case it is missing from the file |
||
727 | $person_privacy = array(); |
||
728 | $person_facts = array(); |
||
729 | $global_facts = array(); |
||
730 | |||
731 | echo '<p>Reading privacy file ', $privacy, '</p>'; |
||
732 | require $privacy; |
||
733 | |||
734 | foreach ($global_facts as $key => $value) { |
||
735 | if (isset($value['details'])) { |
||
736 | $stmt_default_resn->execute(array($GED_DATA['id'], null, $key, $value['details'])); |
||
737 | } |
||
738 | } |
||
739 | |||
740 | foreach ($person_privacy as $key => $value) { |
||
741 | $stmt_default_resn->execute(array($GED_DATA['id'], $key, null, $value)); |
||
742 | } |
||
743 | |||
744 | foreach ($person_facts as $key1 => $array) { |
||
745 | foreach ($array as $key2 => $value) { |
||
746 | if (isset($value['details'])) { |
||
747 | $stmt_default_resn->execute(array($GED_DATA['id'], $key1, $key2, $value['details'])); |
||
748 | } |
||
749 | } |
||
750 | } |
||
751 | } else { |
||
752 | echo '<p>Could not read privacy file ', $privacy, '</p>'; |
||
753 | } |
||
754 | |||
755 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'ADVANCED_NAME_FACTS', $ADVANCED_NAME_FACTS)); |
||
756 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'ADVANCED_PLAC_FACTS', $ADVANCED_PLAC_FACTS)); |
||
757 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'ALLOW_THEME_DROPDOWN', $ALLOW_THEME_DROPDOWN)); |
||
758 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'CALENDAR_FORMAT', $CALENDAR_FORMAT)); |
||
759 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'CHART_BOX_TAGS', $CHART_BOX_TAGS)); |
||
760 | $user = User::findByIdentifier($CONTACT_EMAIL); |
||
761 | if ($user) { |
||
762 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'CONTACT_USER_ID', $user->getUserId())); |
||
763 | } |
||
764 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'DEFAULT_PEDIGREE_GENERATIONS', $DEFAULT_PEDIGREE_GENERATIONS)); |
||
765 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'EXPAND_NOTES', $EXPAND_NOTES)); |
||
766 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'EXPAND_SOURCES', $EXPAND_SOURCES)); |
||
767 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_FACTS_ADD', $FAM_FACTS_ADD)); |
||
768 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_FACTS_QUICK', $FAM_FACTS_QUICK)); |
||
769 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_FACTS_UNIQUE', $FAM_FACTS_UNIQUE)); |
||
770 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FAM_ID_PREFIX', $FAM_ID_PREFIX)); |
||
771 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'FULL_SOURCES', $FULL_SOURCES)); |
||
772 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'GEDCOM_ID_PREFIX', $GEDCOM_ID_PREFIX)); |
||
773 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'GENERATE_UIDS', $GENERATE_UIDS)); |
||
774 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'HIDE_GEDCOM_ERRORS', $HIDE_GEDCOM_ERRORS)); |
||
775 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'HIDE_LIVE_PEOPLE', $HIDE_LIVE_PEOPLE)); |
||
776 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'INDI_FACTS_ADD', $INDI_FACTS_ADD)); |
||
777 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'INDI_FACTS_QUICK', $INDI_FACTS_QUICK)); |
||
778 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'INDI_FACTS_UNIQUE', $INDI_FACTS_UNIQUE)); |
||
779 | switch ($LANGUAGE) { |
||
780 | case 'catalan': |
||
781 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'ca')); |
||
782 | break; |
||
783 | case 'english-uk': |
||
784 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'en-GB')); |
||
785 | break; |
||
786 | case 'polish': |
||
787 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'pl')); |
||
788 | break; |
||
789 | case 'italian': |
||
790 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'it')); |
||
791 | break; |
||
792 | case 'spanish': |
||
793 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'es')); |
||
794 | break; |
||
795 | case 'finnish': |
||
796 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'fi')); |
||
797 | break; |
||
798 | case 'french': |
||
799 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'fr')); |
||
800 | break; |
||
801 | case 'german': |
||
802 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'de')); |
||
803 | break; |
||
804 | case 'danish': |
||
805 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'da')); |
||
806 | break; |
||
807 | case 'portuguese': |
||
808 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'pt')); |
||
809 | break; |
||
810 | case 'hebrew': |
||
811 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'he')); |
||
812 | break; |
||
813 | case 'estonian': |
||
814 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'et')); |
||
815 | break; |
||
816 | case 'turkish': |
||
817 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'tr')); |
||
818 | break; |
||
819 | case 'dutch': |
||
820 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'nl')); |
||
821 | break; |
||
822 | case 'slovak': |
||
823 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'sk')); |
||
824 | break; |
||
825 | case 'norwegian': |
||
826 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'nn')); |
||
827 | break; |
||
828 | case 'slovenian': |
||
829 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'sl')); |
||
830 | break; |
||
831 | case 'hungarian': |
||
832 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'hu')); |
||
833 | break; |
||
834 | case 'swedish': |
||
835 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'sv')); |
||
836 | break; |
||
837 | case 'russian': |
||
838 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'ru')); |
||
839 | break; |
||
840 | default: |
||
841 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'LANGUAGE', 'en-US')); |
||
842 | break; |
||
843 | } |
||
844 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_ALIVE_AGE', $MAX_ALIVE_AGE)); |
||
845 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_DESCENDANCY_GENERATIONS', $MAX_DESCENDANCY_GENERATIONS)); |
||
846 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_PEDIGREE_GENERATIONS', $MAX_PEDIGREE_GENERATIONS)); |
||
847 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MAX_RELATION_PATH_LENGTH', $MAX_RELATION_PATH_LENGTH)); |
||
848 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MEDIA_DIRECTORY', 'media/')); |
||
849 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MEDIA_ID_PREFIX', $MEDIA_ID_PREFIX)); |
||
850 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'META_DESCRIPTION', $META_DESCRIPTION)); |
||
851 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'META_TITLE', $META_TITLE)); |
||
852 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'MEDIA_UPLOAD', $MULTI_MEDIA)); // see schema v12-13 |
||
853 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_FACTS_ADD', $NOTE_FACTS_ADD)); |
||
854 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_FACTS_QUICK', $NOTE_FACTS_QUICK)); |
||
855 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_FACTS_UNIQUE', $NOTE_FACTS_UNIQUE)); |
||
856 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NOTE_ID_PREFIX', 'N')); |
||
857 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'NO_UPDATE_CHAN', $NO_UPDATE_CHAN)); |
||
858 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_FULL_DETAILS', $PEDIGREE_FULL_DETAILS)); |
||
859 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_LAYOUT', $PEDIGREE_LAYOUT)); |
||
860 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_ROOT_ID', $PEDIGREE_ROOT_ID)); |
||
861 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PEDIGREE_SHOW_GENDER', $PEDIGREE_SHOW_GENDER)); |
||
862 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'PREFER_LEVEL2_SOURCES', $PREFER_LEVEL2_SOURCES)); |
||
863 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'QUICK_REQUIRED_FACTS', $QUICK_REQUIRED_FACTS)); |
||
864 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'QUICK_REQUIRED_FAMFACTS', $QUICK_REQUIRED_FAMFACTS)); |
||
865 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_FACTS_ADD', $REPO_FACTS_ADD)); |
||
866 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_FACTS_QUICK', $REPO_FACTS_QUICK)); |
||
867 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_FACTS_UNIQUE', $REPO_FACTS_UNIQUE)); |
||
868 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REPO_ID_PREFIX', $REPO_ID_PREFIX)); |
||
869 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'REQUIRE_AUTHENTICATION', $REQUIRE_AUTHENTICATION)); |
||
870 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SAVE_WATERMARK_IMAGE', $SAVE_WATERMARK_IMAGE)); |
||
871 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SAVE_WATERMARK_THUMB', $SAVE_WATERMARK_THUMB)); |
||
872 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_COUNTER', $SHOW_COUNTER)); |
||
873 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_DEAD_PEOPLE', $SHOW_DEAD_PEOPLE)); |
||
874 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_EST_LIST_DATES', $SHOW_EST_LIST_DATES)); |
||
875 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_FACT_ICONS', $SHOW_FACT_ICONS)); |
||
876 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_GEDCOM_RECORD', $SHOW_GEDCOM_RECORD)); |
||
877 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_HIGHLIGHT_IMAGES', $SHOW_HIGHLIGHT_IMAGES)); |
||
878 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LDS_AT_GLANCE', $SHOW_LDS_AT_GLANCE)); |
||
879 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LIST_PLACES', $SHOW_LIST_PLACES)); |
||
880 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_LIVING_NAMES', $SHOW_LIVING_NAMES)); |
||
881 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_MEDIA_DOWNLOAD', $SHOW_MEDIA_DOWNLOAD)); |
||
882 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_PARENTS_AGE', $SHOW_PARENTS_AGE)); |
||
883 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_PEDIGREE_PLACES', $SHOW_PEDIGREE_PLACES)); |
||
884 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_PRIVATE_RELATIONSHIPS', $SHOW_PRIVATE_RELATIONSHIPS)); |
||
885 | |||
886 | // Update these - see db_schema_5_6.php |
||
887 | $SHOW_RELATIVES_EVENTS = preg_replace('/_(BIRT|MARR|DEAT)_(COUS|MSIB|FSIB|GGCH|NEPH|GGPA)/', '', $SHOW_RELATIVES_EVENTS); |
||
888 | $SHOW_RELATIVES_EVENTS = preg_replace('/_FAMC_(RESI_EMIG)/', '', $SHOW_RELATIVES_EVENTS); |
||
889 | $SHOW_RELATIVES_EVENTS = preg_replace('/_MARR_(MOTH|FATH|FAMC)/', '_MARR_PARE', $SHOW_RELATIVES_EVENTS); |
||
890 | $SHOW_RELATIVES_EVENTS = preg_replace('/_DEAT_(MOTH|FATH)/', '_DEAT_PARE', $SHOW_RELATIVES_EVENTS); |
||
891 | preg_match_all('/[_A-Z]+/', $SHOW_RELATIVES_EVENTS, $match); |
||
892 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SHOW_RELATIVES_EVENTS', implode(',', array_unique($match[0])))); |
||
893 | |||
894 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOURCE_ID_PREFIX', $SOURCE_ID_PREFIX)); |
||
895 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOUR_FACTS_ADD', $SOUR_FACTS_ADD)); |
||
896 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOUR_FACTS_QUICK', $SOUR_FACTS_QUICK)); |
||
897 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SOUR_FACTS_UNIQUE', $SOUR_FACTS_UNIQUE)); |
||
898 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SUBLIST_TRIGGER_I', $SUBLIST_TRIGGER_I)); |
||
899 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SURNAME_LIST_STYLE', $SURNAME_LIST_STYLE)); |
||
900 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'SURNAME_TRADITION', $SURNAME_TRADITION)); |
||
901 | switch ($THEME_DIR) { |
||
902 | case '': |
||
903 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', '')); |
||
904 | break; |
||
905 | case 'themes/cloudy/': |
||
906 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'clouds')); |
||
907 | break; |
||
908 | case 'themes/minimal/': |
||
909 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'minimal')); |
||
910 | break; |
||
911 | case 'themes/simplyblue/': |
||
912 | case 'themes/simplygreen/': |
||
913 | case 'themes/simplyred/': |
||
914 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'colors')); |
||
915 | break; |
||
916 | case 'themes/xenea/': |
||
917 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'xenea')); |
||
918 | break; |
||
919 | default: |
||
920 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THEME_DIR', 'webtrees')); |
||
921 | break; |
||
922 | } |
||
923 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'THUMBNAIL_WIDTH', $THUMBNAIL_WIDTH)); |
||
924 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'USE_RELATIONSHIP_PRIVACY', $USE_RELATIONSHIP_PRIVACY)); |
||
925 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WATERMARK_THUMB', $WATERMARK_THUMB)); |
||
926 | $user = User::findByIdentifier($WEBMASTER_EMAIL); |
||
927 | if ($user) { |
||
928 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WEBMASTER_USER_ID', $user->getUserId())); |
||
929 | } |
||
930 | $stmt_gedcom_setting->execute(array($GED_DATA['id'], 'WORD_WRAPPED_NOTES', $WORD_WRAPPED_NOTES)); |
||
931 | } |
||
932 | Database::prepare("DELETE FROM `##gedcom_setting` WHERE setting_name IN ('config', 'privacy', 'path', 'pgv_ver', 'imported')")->execute(); |
||
933 | |||
934 | // webtrees 1.0.5 combines user and gedcom settings for relationship privacy |
||
935 | // into a combined user-gedcom setting, for more granular control |
||
936 | Database::exec( |
||
937 | "INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value)" . |
||
938 | " SELECT u.user_id, g.gedcom_id, 'RELATIONSHIP_PATH_LENGTH', LEAST(us1.setting_value, gs1.setting_value)" . |
||
939 | " FROM `##user` u" . |
||
940 | " CROSS JOIN `##gedcom` g" . |
||
941 | " LEFT JOIN `##user_setting` us1 ON (u.user_id =us1.user_id AND us1.setting_name='max_relation_path')" . |
||
942 | " LEFT JOIN `##user_setting` us2 ON (u.user_id =us2.user_id AND us2.setting_name='relationship_privacy')" . |
||
943 | " LEFT JOIN `##gedcom_setting` gs1 ON (g.gedcom_id=gs1.gedcom_id AND gs1.setting_name='MAX_RELATION_PATH_LENGTH')" . |
||
944 | " LEFT JOIN `##gedcom_setting` gs2 ON (g.gedcom_id=gs2.gedcom_id AND gs2.setting_name='USE_RELATIONSHIP_PRIVACY')" . |
||
945 | " WHERE us2.setting_value AND gs2.setting_value" |
||
946 | ); |
||
947 | |||
948 | Database::exec( |
||
949 | "DELETE FROM `##gedcom_setting` WHERE setting_name IN ('MAX_RELATION_PATH_LENGTH', 'USE_RELATIONSHIP_PRIVACY')" |
||
950 | ); |
||
951 | |||
952 | Database::exec( |
||
953 | "DELETE FROM `##user_setting` WHERE setting_name IN ('relationship_privacy', 'max_relation_path_length')" |
||
954 | ); |
||
955 | |||
956 | //////////////////////////////////////////////////////////////////////////////// |
||
957 | // The PhpGedView blocks don't migrate easily. |
||
958 | // Just give everybody and every tree default blocks |
||
959 | //////////////////////////////////////////////////////////////////////////////// |
||
960 | |||
961 | Database::prepare( |
||
962 | "INSERT INTO `##block` (user_id, location, block_order, module_name)" . |
||
963 | " SELECT `##user`.user_id, location, block_order, module_name" . |
||
964 | " FROM `##block`" . |
||
965 | " JOIN `##user`" . |
||
966 | " WHERE `##block`.user_id = -1" . |
||
967 | " AND `##user`.user_id > 0" |
||
968 | )->execute(); |
||
969 | |||
970 | Database::prepare( |
||
971 | "INSERT INTO `##block` (gedcom_id, location, block_order, module_name)" . |
||
972 | " SELECT `##gedcom`.gedcom_id, location, block_order, module_name" . |
||
973 | " FROM `##block`" . |
||
974 | " JOIN `##gedcom`" . |
||
975 | " WHERE `##block`.gedcom_id = -1" . |
||
976 | " AND `##gedcom`.gedcom_id > 0" |
||
977 | )->execute(); |
||
978 | |||
979 | //////////////////////////////////////////////////////////////////////////////// |
||
980 | // Hit counter |
||
981 | //////////////////////////////////////////////////////////////////////////////// |
||
982 | // |
||
983 | if ($PGV_SCHEMA_VERSION >= 13) { |
||
984 | echo '<p>pgv_hit_counter => wt_hit_counter…</p>'; |
||
985 | |||
986 | Database::prepare( |
||
987 | "REPLACE INTO `##hit_counter` (gedcom_id, page_name, page_parameter, page_count)" . |
||
988 | " SELECT gedcom_id, page_name, page_parameter, page_count FROM `{$DBNAME}`.`{$TBLPREFIX}hit_counter`" |
||
989 | )->execute(); |
||
990 | } else { |
||
991 | // Copied from PhpGedView's db_schema_12_13 |
||
992 | $statement = Database::prepare("INSERT IGNORE INTO `##hit_counter` (gedcom_id, page_name, page_parameter, page_count) VALUES (?, ?, ?, ?)"); |
||
993 | |||
994 | foreach ($GEDCOMS as $GEDCOM => $GED_DATA) { |
||
995 | $file = $INDEX_DIRECTORY . '/' . $GED_DATA['gedcom'] . 'pgv_counters.txt'; |
||
996 | echo '<p>', $file, ' => wt_hit_counter…</p>'; |
||
997 | |||
998 | if (file_exists($file)) { |
||
999 | foreach (file($file) as $line) { |
||
1000 | if (preg_match('/(@([A-Za-z0-9:_-]+)@ )?(\d+)/', $line, $match)) { |
||
1001 | if ($match[2]) { |
||
1002 | $page_name = 'individual.php'; |
||
1003 | $page_parameter = $match[2]; |
||
1004 | } else { |
||
1005 | $page_name = 'index.php'; |
||
1006 | $page_parameter = 'gedcom:' . $GED_DATA['id']; |
||
1007 | } |
||
1008 | try { |
||
1009 | $statement->execute(array($GED_DATA['id'], $page_name, $page_parameter, $match[3])); |
||
1010 | } catch (PDOException $ex) { |
||
1011 | // Primary key violation? Ignore? |
||
1012 | } |
||
1013 | } |
||
1014 | } |
||
1015 | } |
||
1016 | } |
||
1017 | } |
||
1018 | |||
1019 | //////////////////////////////////////////////////////////////////////////////// |
||
1020 | |||
1021 | foreach ($GEDCOMS as $GED_DATA) { |
||
0 ignored issues
–
show
|
|||
1022 | Module::setDefaultAccess($GED_DATA['id']); |
||
1023 | } |
||
1024 | |||
1025 | echo '<p>pgv_site_setting => wt_module_setting…</p>'; |
||
1026 | |||
1027 | Database::prepare( |
||
1028 | "REPLACE INTO `##module_setting` (module_name, setting_name, setting_value)" . |
||
1029 | " SELECT 'googlemap', site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`" . |
||
1030 | " WHERE site_setting_name LIKE 'GM_%'" |
||
1031 | )->execute(); |
||
1032 | Database::prepare( |
||
1033 | "REPLACE INTO `##module_setting` (module_name, setting_name, setting_value)" . |
||
1034 | " SELECT 'lightbox', site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`" . |
||
1035 | " WHERE site_setting_name LIKE 'LB_%'" |
||
1036 | )->execute(); |
||
1037 | |||
1038 | //////////////////////////////////////////////////////////////////////////////// |
||
1039 | |||
1040 | echo '<p>pgv_favorites => wt_favorite…</p>'; |
||
1041 | |||
1042 | try { |
||
1043 | Database::prepare( |
||
1044 | "REPLACE INTO `##favorite` (favorite_id, user_id, gedcom_id, xref, favorite_type, url, title, note)" . |
||
1045 | " SELECT fv_id, u.user_id, g.gedcom_id, fv_gid, fv_type, fv_url, fv_title, fv_note" . |
||
1046 | " FROM `{$DBNAME}`.`{$TBLPREFIX}favorites` f" . |
||
1047 | " LEFT JOIN `##gedcom` g ON (f.fv_username=g.gedcom_name)" . |
||
1048 | " LEFT JOIN `##user` u ON (f.fv_username=u.user_name)" |
||
1049 | )->execute(); |
||
1050 | } catch (PDOException $ex) { |
||
1051 | // This table will only exist if the favorites module is installed in WT |
||
1052 | } |
||
1053 | |||
1054 | //////////////////////////////////////////////////////////////////////////////// |
||
1055 | |||
1056 | echo '<p>pgv_news => wt_news…</p>'; |
||
1057 | |||
1058 | try { |
||
1059 | Database::prepare( |
||
1060 | "REPLACE INTO `##news` (news_id, user_id, gedcom_id, subject, body, updated)" . |
||
1061 | " SELECT n_id, u.user_id, g.gedcom_id, n_title, n_text, FROM_UNIXTIME(n_date)" . |
||
1062 | " FROM `{$DBNAME}`.`{$TBLPREFIX}news` n" . |
||
1063 | " LEFT JOIN `##gedcom` g ON (n.n_username=g.gedcom_name)" . |
||
1064 | " LEFT JOIN `##user` u ON (n.n_username=u.user_name)" |
||
1065 | )->execute(); |
||
1066 | } catch (PDOException $ex) { |
||
1067 | // This table will only exist if the news/blog module is installed in WT |
||
1068 | } |
||
1069 | |||
1070 | //////////////////////////////////////////////////////////////////////////////// |
||
1071 | |||
1072 | echo '<p>pgv_nextid => wt_next_id…</p>'; |
||
1073 | |||
1074 | Database::prepare( |
||
1075 | "REPLACE INTO `##next_id` (gedcom_id, record_type, next_id)" . |
||
1076 | " SELECT ni_gedfile, ni_type, ni_id" . |
||
1077 | " FROM `{$DBNAME}`.`{$TBLPREFIX}nextid`" . |
||
1078 | " JOIN `##gedcom` ON (ni_gedfile = gedcom_id)" . |
||
1079 | " WHERE ni_type IN ('INDI', 'FAM', 'SOUR', 'REPO', 'OBJE', 'NOTE')" |
||
1080 | )->execute(); |
||
1081 | |||
1082 | //////////////////////////////////////////////////////////////////////////////// |
||
1083 | |||
1084 | echo '<p>pgv_messages => wt_message…</p>'; |
||
1085 | |||
1086 | Database::prepare( |
||
1087 | "REPLACE INTO `##message` (message_id, sender, ip_address, user_id, subject, body, created)" . |
||
1088 | " SELECT m_id, m_from, '127.0.0.1', user_id, m_subject, m_body, (CASE " . |
||
1089 | " WHEN CHAR_LENGTH(m_created) = 20 THEN STR_TO_DATE(m_created, '%M %d %Y %H:%i:%s') " . |
||
1090 | " WHEN CHAR_LENGTH(m_created) = 0 THEN NULL " . |
||
1091 | " ELSE STR_TO_DATE(LEFT(m_created,25),'%a, %d %M %Y %H:%i:%s')" . |
||
1092 | " END)" . |
||
1093 | " FROM `{$DBNAME}`.`{$TBLPREFIX}messages`" . |
||
1094 | " JOIN `##user` ON (CONVERT(m_to USING utf8) COLLATE utf8_unicode_ci=user_name)" |
||
1095 | )->execute(); |
||
1096 | |||
1097 | //////////////////////////////////////////////////////////////////////////////// |
||
1098 | |||
1099 | try { |
||
1100 | echo '<p>pgv_placelocation => wt_placelocation…</p>'; |
||
1101 | |||
1102 | Database::prepare( |
||
1103 | "REPLACE INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom, pl_icon)" . |
||
1104 | " SELECT pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom, pl_icon FROM `{$DBNAME}`.`{$TBLPREFIX}placelocation`" |
||
1105 | )->execute(); |
||
1106 | } catch (PDOException $ex) { |
||
1107 | // This table will only exist if the gm module is installed in PhpGedView/WT |
||
1108 | } |
||
1109 | |||
1110 | //////////////////////////////////////////////////////////////////////////////// |
||
1111 | |||
1112 | echo '<p>Genealogy records…</p>'; |
||
1113 | |||
1114 | Database::prepare( |
||
1115 | "INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data, imported)" . |
||
1116 | " SELECT o_file, o_gedcom, 0 FROM `{$DBNAME}`.`{$TBLPREFIX}other`" . |
||
1117 | " JOIN `##gedcom` ON (o_file = gedcom_id)" . |
||
1118 | " ORDER BY o_type!='HEAD'" // Must load HEAD record first |
||
1119 | )->execute(); |
||
1120 | |||
1121 | Database::prepare( |
||
1122 | "INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data, imported)" . |
||
1123 | " SELECT i_file, i_gedcom, 0 FROM `{$DBNAME}`.`{$TBLPREFIX}individuals`" . |
||
1124 | " JOIN `##gedcom` ON (i_file = gedcom_id)" |
||
1125 | )->execute(); |
||
1126 | |||
1127 | Database::prepare( |
||
1128 | "INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data, imported)" . |
||
1129 | " SELECT f_file, f_gedcom, 0 FROM `{$DBNAME}`.`{$TBLPREFIX}families`" . |
||
1130 | " JOIN `##gedcom` ON (f_file = gedcom_id)" |
||
1131 | )->execute(); |
||
1132 | |||
1133 | Database::prepare( |
||
1134 | "INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data, imported)" . |
||
1135 | " SELECT s_file, s_gedcom, 0 FROM `{$DBNAME}`.`{$TBLPREFIX}sources`" . |
||
1136 | " JOIN `##gedcom` ON (s_file = gedcom_id)" |
||
1137 | )->execute(); |
||
1138 | |||
1139 | Database::prepare( |
||
1140 | "INSERT INTO `##gedcom_chunk` (gedcom_id, chunk_data, imported)" . |
||
1141 | " SELECT m_gedfile, m_gedrec, 0 FROM `{$DBNAME}`.`{$TBLPREFIX}media`" . |
||
1142 | " JOIN `##gedcom` ON (m_gedfile = gedcom_id)" |
||
1143 | )->execute(); |
||
1144 | |||
1145 | Database::prepare( |
||
1146 | "UPDATE `##gedcom_setting` SET setting_value='0' WHERE setting_name='imported'" |
||
1147 | )->execute(); |
||
1148 | |||
1149 | //////////////////////////////////////////////////////////////////////////////// |
||
1150 | |||
1151 | Database::commit(); |
||
1152 | |||
1153 | echo '<hr>'; |
||
1154 | echo '<p>', I18N::translate('You need to sign in again, using your PhpGedView username and password.'), '</p>'; |
||
1155 | echo '<a href="index.php"><button class="btn btn-primary">', I18N::translate('continue'), '</button></a>'; |
||
1156 |