diff options
| -rw-r--r-- | admin_trees_manage.php | 93 | ||||
| -rw-r--r-- | admin_trees_merge.php | 174 | ||||
| -rw-r--r-- | admin_trees_renumber.php | 2 | ||||
| -rw-r--r-- | themes/_administration/css-1.5.4/style.css | 4 | ||||
| -rw-r--r-- | themes/_administration/header.php | 1 |
5 files changed, 147 insertions, 127 deletions
diff --git a/admin_trees_manage.php b/admin_trees_manage.php index ec3feb310b..1953dbfc9f 100644 --- a/admin_trees_manage.php +++ b/admin_trees_manage.php @@ -80,19 +80,21 @@ case 'delete': if (WT_Filter::checkCsrf() && $gedcom_id) { WT_Tree::delete($gedcom_id); } - header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.WT_SCRIPT_NAME); + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME); break; case 'setdefault': if (WT_Filter::checkCsrf()) { WT_Site::setPreference('DEFAULT_GEDCOM', WT_Filter::post('default_ged')); } - break; + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME); + exit; case 'new_tree': $ged_name=basename(WT_Filter::post('ged_name')); if (WT_Filter::checkCsrf() && $ged_name) { WT_Tree::create($ged_name); } - break; + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME); + exit; case 'replace_upload': $gedcom_id = WT_Filter::postInteger('gedcom_id'); // Make sure the gedcom still exists @@ -103,7 +105,7 @@ case 'replace_upload': } } } - header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.WT_SCRIPT_NAME.'?keep_media'.$gedcom_id.'='.WT_Filter::postBool('keep_media'.$gedcom_id)); + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME . '?keep_media' . $gedcom_id . '=' . WT_Filter::postBool('keep_media' . $gedcom_id)); exit; case 'replace_import': $gedcom_id = WT_Filter::postInteger('gedcom_id'); @@ -112,7 +114,7 @@ case 'replace_import': $ged_name = basename(WT_Filter::post('ged_name')); import_gedcom_file($gedcom_id, WT_DATA_DIR.$ged_name, $ged_name); } - header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.WT_SCRIPT_NAME.'?keep_media'.$gedcom_id.'='.WT_Filter::postBool('keep_media'.$gedcom_id)); + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME . '?keep_media' . $gedcom_id . '=' . WT_Filter::postBool('keep_media' . $gedcom_id)); exit; } @@ -238,41 +240,52 @@ foreach (WT_Tree::GetAll() as $tree) { '</td></tr></table></td></tr></table><br>'; } } +?> -// Options for creating new gedcoms and setting defaults -if (Auth::isAdmin()) { - echo '<table class="gedcom_table2"><tr>'; - if (count(WT_Tree::GetAll())>1) { - echo '<th>', WT_I18N::translate('Default family tree'), help_link('default_gedcom'), '</th>'; - } - echo '<th>', WT_I18N::translate('Create a new family tree'), help_link('add_new_gedcom'), '</th></tr><tr>'; - if (count(WT_Tree::GetAll())>1) { - echo - '<td><form name="defaultform" method="post" action="', WT_SCRIPT_NAME, '">', - '<input type="hidden" name="action" value="setdefault">', - WT_Filter::getCsrf(), - select_edit_control('default_ged', WT_Tree::getNameList(), '', WT_Site::getPreference('DEFAULT_GEDCOM'), 'onchange="document.defaultform.submit();"'), - '</form></td>'; - } +<?php if (Auth::isAdmin()): ?> + <table class="gedcom_table2"> + <tr> + <?php if (count(WT_Tree::GetAll())>1): ?> + <th> + <?php echo WT_I18N::translate('Default family tree'), help_link('default_gedcom'); ?> + </th> + <?php endif; ?> + <th> + <?php echo WT_I18N::translate('Create a new family tree'), help_link('add_new_gedcom'); ?> + </th> + </tr> + <tr> + <?php if (count(WT_Tree::GetAll())>1): ?> + <td> + <form method="post"> + <input type="hidden" name="action" value="setdefault"> + <?php echo WT_Filter::getCsrf(); ?> + <?php echo select_edit_control('default_ged', WT_Tree::getNameList(), '', WT_Site::getPreference('DEFAULT_GEDCOM'), 'onchange="document.defaultform.submit();"'); ?> + <input type="submit" value="<?php echo WT_I18N::translate('save'); ?>"> + </form> + </td> + <?php endif; ?> + <td class="button"> + <form method="post"> + <?php echo WT_Filter::getCsrf(); ?> + <input type="hidden" name="action" value="new_tree"> + <input name="ged_name"> + <input type="submit" value="<?php echo WT_I18N::translate('save'); ?>"> + </form> + </td> + </tr> + </table> +<?php endif; ?> +<br> +<?php +// display link to PGV-WT transfer wizard on first visit to this page, before any GEDCOM is loaded +if (count(WT_Tree::GetAll())==0 && count(User::all())==1) { echo - '<td class="button">', - '<form name="createform" method="post" action="', WT_SCRIPT_NAME, '">', - WT_Filter::getCsrf(), - '<input type="hidden" name="action" value="new_tree">', - '<input name="ged_name">', - ' <input type="submit" value="', WT_I18N::translate('save') , '">', - '</form>', - '</td>', - '</tr></table><br>'; - - // display link to PGV-WT transfer wizard on first visit to this page, before any GEDCOM is loaded - if (count(WT_Tree::GetAll())==0 && count(User::all())==1) { - echo - '<div class="center">', - '<a style="color:green; font-weight:bold;" href="admin_pgv_to_wt.php">', - WT_I18N::translate('Click here for PhpGedView to <b>webtrees</b> transfer wizard'), - '</a>', - help_link('PGV_WIZARD'), - '</div>'; - } + '<div class="center">', + '<a style="color:green; font-weight:bold;" href="admin_pgv_to_wt.php">', + WT_I18N::translate('Click here for PhpGedView to <b>webtrees</b> transfer wizard'), + '</a>', + help_link('PGV_WIZARD'), + '</div>'; } + diff --git a/admin_trees_merge.php b/admin_trees_merge.php index 29c6b29cc5..967712659d 100644 --- a/admin_trees_merge.php +++ b/admin_trees_merge.php @@ -32,9 +32,10 @@ $controller echo '<h2>', $controller->getPageTitle(), '</h2>'; -$ged2_id = WT_Filter::post('ged2_id'); +$tree1_id = WT_Filter::post('tree1_id'); +$tree2_id = WT_Filter::post('tree2_id'); -if ($ged2_id && $ged2_id != WT_GED_ID ) { +if ($tree1_id && $tree2_id != $tree1_id) { // Every XREF used by both trees $xrefs = WT_DB::prepare( "SELECT xref, type FROM (" . @@ -61,22 +62,36 @@ if ($ged2_id && $ged2_id != WT_GED_ID ) { " SELECT o_id AS xref FROM `##other` WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" . ") AS other_trees USING (xref)" )->execute(array( - WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, - $ged2_id, $ged2_id, $ged2_id, $ged2_id, $ged2_id, $ged2_id + $tree1_id, $tree1_id, $tree1_id, $tree1_id, $tree1_id, + $tree2_id, $tree2_id, $tree2_id, $tree2_id, $tree2_id, $tree2_id ))->fetchAssoc(); if ($xrefs) { + $tree1 = WT_Tree::get($tree1_id); + $tree2 = WT_Tree::get($tree2_id); echo - '<p class="error">', - WT_I18N::plural( - 'The two family trees have %1$s record which uses the same “XREF”.', - 'The two family trees have %1$s records which uses the same “XREF”.', - count($xrefs), count($xrefs) - ), - '</p>', - '<p class="error">', - WT_I18N::translate('You must renumber the records in one of the trees before you can merge them.'), - '</p>'; + '<p>', WT_I18N::translate('In a family tree, each record has an internal reference number (called an “XREF”) such as “F123” or “R14”.') ,'</p>', + '<p>', + WT_I18N::plural( + /* I18N: An XREF is the identification number used in GEDCOM files. */ + 'The two family trees have %1$s record which use the same “XREF”.', + 'The two family trees have %1$s records which use the same “XREF”.', + count($xrefs), count($xrefs) + ), + '</p>', + '<p>', + WT_I18N::translate('You must renumber the records in one of the trees before you can merge them.'), + '</p>', + '<p>', + '<a class="current" href="admin_trees_renumber.php?ged=', $tree1->tree_name_html, '">', + WT_I18N::translate('Renumber family tree'), ' — ', $tree1->tree_title_html, + '</a>', + '</p>', + '<p>', + '<a class="current" href="admin_trees_renumber.php?ged=', $tree2->tree_name_html, '">', + WT_I18N::translate('Renumber family tree'), ' — ', $tree2->tree_title_html, + '</a>', + '</p>'; } else { WT_DB::exec("START TRANSACTION"); WT_DB::exec( @@ -106,75 +121,70 @@ if ($ged2_id && $ged2_id != WT_GED_ID ) { " `##link` WRITE," . " `##link` AS link2 READ" ); - try { - WT_DB::prepare( - "INSERT INTO `##individuals` (i_id, i_file, i_rin, i_sex, i_gedcom)" . - " SELECT i_id, ?, i_rin, i_sex, i_gedcom FROM `##individuals` AS individuals2 WHERE i_file = ?" - )->execute(array($ged2_id, WT_GED_ID)); - WT_DB::prepare( - "INSERT INTO `##families` (f_id, f_file, f_husb, f_wife, f_gedcom, f_numchil)" . - " SELECT f_id, ?, f_husb, f_wife, f_gedcom, f_numchil FROM `##families` AS families2 WHERE f_file = ?" - )->execute(array($ged2_id, WT_GED_ID)); - WT_DB::prepare( - "INSERT INTO `##sources` (s_id, s_file, s_name, s_gedcom)" . - " SELECT s_id, ?, s_name, s_gedcom FROM `##sources` AS sources2 WHERE s_file = ?" - )->execute(array($ged2_id, WT_GED_ID)); - WT_DB::prepare( - "INSERT INTO `##media` (m_id, m_ext, m_type, m_titl, m_filename, m_file, m_gedcom)" . - " SELECT m_id, m_ext, m_type, m_titl, m_filename, ?, m_gedcom FROM `##media` AS media2 WHERE m_file = ?" - )->execute(array($ged2_id, WT_GED_ID)); - WT_DB::prepare( - "INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom)" . - " SELECT o_id, ?, o_type, o_gedcom FROM `##other` AS other2 WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" - )->execute(array($ged2_id, WT_GED_ID)); - WT_DB::prepare( - "INSERT INTO `##name` (n_file, n_id, n_num, n_type, n_sort, n_full, n_surname, n_surn, n_givn, n_soundex_givn_std, n_soundex_surn_std, n_soundex_givn_dm, n_soundex_surn_dm)" . - " SELECT ?, n_id, n_num, n_type, n_sort, n_full, n_surname, n_surn, n_givn, n_soundex_givn_std, n_soundex_surn_std, n_soundex_givn_dm, n_soundex_surn_dm FROM `##name` AS name2 WHERE n_file = ?" - )->execute(array($ged2_id, WT_GED_ID)); - WT_DB::prepare( - "INSERT INTO `##placelinks` (pl_p_id, pl_gid, pl_file)" . - " SELECT pl_p_id, pl_gid, ? FROM `##placelinks` AS placelinks2 WHERE pl_file = ?" - )->execute(array($ged2_id, WT_GED_ID)); - WT_DB::prepare( - "INSERT INTO `##dates` (d_day, d_month, d_mon, d_year, d_julianday1, d_julianday2, d_fact, d_gid, d_file, d_type)" . - " SELECT d_day, d_month, d_mon, d_year, d_julianday1, d_julianday2, d_fact, d_gid, ?, d_type FROM `##dates` AS dates2 WHERE d_file = ?" - )->execute(array($ged2_id, WT_GED_ID)); - WT_DB::prepare( - "INSERT INTO `##default_resn` (gedcom_id, xref, tag_type, resn, comment, updated)" . - " SELECT ?, xref, tag_type, resn, comment, updated FROM `##default_resn` AS default_resn2 WHERE gedcom_id = ?" - )->execute(array($ged2_id, WT_GED_ID)); - WT_DB::prepare( - "INSERT INTO `##link` (l_file, l_from, l_type, l_to)" . - " SELECT ?, l_from, l_type, l_to FROM `##link` AS link2 WHERE l_file = ?" - )->execute(array($ged2_id, WT_GED_ID)); - // This table may contain old (deleted) references, which could clash. IGNORE these. - WT_DB::prepare( - "INSERT IGNORE INTO `##change` (change_time, status, gedcom_id, xref, old_gedcom, new_gedcom, user_id)" . - " SELECT change_time, status, ?, xref, old_gedcom, new_gedcom, user_id FROM `##change` AS change2 WHERE gedcom_id = ?" - )->execute(array($ged2_id, WT_GED_ID)); - // This table may contain old (deleted) references, which could clash. IGNORE these. - WT_DB::prepare( - "INSERT IGNORE INTO `##hit_counter` (gedcom_id, page_name, page_parameter, page_count)" . - " SELECT ?, page_name, page_parameter, page_count FROM `##hit_counter` AS hit_counter2 WHERE gedcom_id = ? AND page_name <> 'index.php'" - )->execute(array($ged2_id, WT_GED_ID)); - echo '<p>', WT_I18N::translate('The family trees were merged successfully.'), '</p>'; - } catch (Exception $ex) { - WT_DB::exec("ROLLBACK"); - echo '<p>', WT_I18N::translate('Oops! An unexpected database error occurred.'), '</p>'; - echo '<pre>', $ex, '</pre>'; - } + WT_DB::prepare( + "INSERT INTO `##individuals` (i_id, i_file, i_rin, i_sex, i_gedcom)" . + " SELECT i_id, ?, i_rin, i_sex, i_gedcom FROM `##individuals` AS individuals2 WHERE i_file = ?" + )->execute(array($tree2_id, $tree1_id)); + WT_DB::prepare( + "INSERT INTO `##families` (f_id, f_file, f_husb, f_wife, f_gedcom, f_numchil)" . + " SELECT f_id, ?, f_husb, f_wife, f_gedcom, f_numchil FROM `##families` AS families2 WHERE f_file = ?" + )->execute(array($tree2_id, $tree1_id)); + WT_DB::prepare( + "INSERT INTO `##sources` (s_id, s_file, s_name, s_gedcom)" . + " SELECT s_id, ?, s_name, s_gedcom FROM `##sources` AS sources2 WHERE s_file = ?" + )->execute(array($tree2_id, $tree1_id)); + WT_DB::prepare( + "INSERT INTO `##media` (m_id, m_ext, m_type, m_titl, m_filename, m_file, m_gedcom)" . + " SELECT m_id, m_ext, m_type, m_titl, m_filename, ?, m_gedcom FROM `##media` AS media2 WHERE m_file = ?" + )->execute(array($tree2_id, $tree1_id)); + WT_DB::prepare( + "INSERT INTO `##other` (o_id, o_file, o_type, o_gedcom)" . + " SELECT o_id, ?, o_type, o_gedcom FROM `##other` AS other2 WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" + )->execute(array($tree2_id, $tree1_id)); + WT_DB::prepare( + "INSERT INTO `##name` (n_file, n_id, n_num, n_type, n_sort, n_full, n_surname, n_surn, n_givn, n_soundex_givn_std, n_soundex_surn_std, n_soundex_givn_dm, n_soundex_surn_dm)" . + " SELECT ?, n_id, n_num, n_type, n_sort, n_full, n_surname, n_surn, n_givn, n_soundex_givn_std, n_soundex_surn_std, n_soundex_givn_dm, n_soundex_surn_dm FROM `##name` AS name2 WHERE n_file = ?" + )->execute(array($tree2_id, $tree1_id)); + WT_DB::prepare( + "INSERT INTO `##placelinks` (pl_p_id, pl_gid, pl_file)" . + " SELECT pl_p_id, pl_gid, ? FROM `##placelinks` AS placelinks2 WHERE pl_file = ?" + )->execute(array($tree2_id, $tree1_id)); + WT_DB::prepare( + "INSERT INTO `##dates` (d_day, d_month, d_mon, d_year, d_julianday1, d_julianday2, d_fact, d_gid, d_file, d_type)" . + " SELECT d_day, d_month, d_mon, d_year, d_julianday1, d_julianday2, d_fact, d_gid, ?, d_type FROM `##dates` AS dates2 WHERE d_file = ?" + )->execute(array($tree2_id, $tree1_id)); + WT_DB::prepare( + "INSERT INTO `##default_resn` (gedcom_id, xref, tag_type, resn, comment, updated)" . + " SELECT ?, xref, tag_type, resn, comment, updated FROM `##default_resn` AS default_resn2 WHERE gedcom_id = ?" + )->execute(array($tree2_id, $tree1_id)); + WT_DB::prepare( + "INSERT INTO `##link` (l_file, l_from, l_type, l_to)" . + " SELECT ?, l_from, l_type, l_to FROM `##link` AS link2 WHERE l_file = ?" + )->execute(array($tree2_id, $tree1_id)); + // This table may contain old (deleted) references, which could clash. IGNORE these. + WT_DB::prepare( + "INSERT IGNORE INTO `##change` (change_time, status, gedcom_id, xref, old_gedcom, new_gedcom, user_id)" . + " SELECT change_time, status, ?, xref, old_gedcom, new_gedcom, user_id FROM `##change` AS change2 WHERE gedcom_id = ?" + )->execute(array($tree2_id, $tree1_id)); + // This table may contain old (deleted) references, which could clash. IGNORE these. + WT_DB::prepare( + "INSERT IGNORE INTO `##hit_counter` (gedcom_id, page_name, page_parameter, page_count)" . + " SELECT ?, page_name, page_parameter, page_count FROM `##hit_counter` AS hit_counter2 WHERE gedcom_id = ? AND page_name <> 'index.php'" + )->execute(array($tree2_id, $tree1_id)); WT_DB::exec("UNLOCK TABLES"); WT_DB::exec("COMMIT"); + echo '<p>', WT_I18N::translate('The family trees were merged successfully.'), '</p>'; } -} - -echo '<form method="POST" action="', WT_SCRIPT_NAME, '">'; -echo '<input type="hidden" name="go" value="1">'; -echo '<p>', WT_I18N::translate( -/* I18N: Copy all the records from [family tree 1] into [family tree 2] */ 'Copy all the records from %1$s into %2$s.', - WT_Filter::escapeHtml($WT_TREE->tree_title), - select_edit_control('ged2_id', WT_Tree::getIdList(), null, $ged2_id) -), '</p>'; +} else { + echo '<form method="post">'; + echo '<input type="hidden" name="go" value="1">'; + echo '<p>', WT_I18N::translate(/* I18N: Copy all the records from [family tree 1] into [family tree 2] */ + 'Copy all the records from %1$s into %2$s.', + select_edit_control('tree1_id', WT_Tree::getIdList(), '', null), + select_edit_control('tree2_id', WT_Tree::getIdList(), '', null) + ), + '</p>'; -echo '<input type="submit" value="', WT_I18N::translate('continue'), '">'; -echo '</form>'; + echo '<input type="submit" value="', WT_I18N::translate('continue'), '">'; + echo '</form>'; +} diff --git a/admin_trees_renumber.php b/admin_trees_renumber.php index 03f1d98246..b3bf93c7fd 100644 --- a/admin_trees_renumber.php +++ b/admin_trees_renumber.php @@ -26,7 +26,7 @@ require './includes/session.php'; $controller = new WT_Controller_Page(); $controller ->restrictAccess(Auth::isManager()) - ->setPageTitle(WT_I18N::translate('Renumber family tree')) + ->setPageTitle(WT_I18N::translate(/* I18N: Renumber the records in a family tree */ 'Renumber family tree')) ->pageHeader(); // Every XREF used by this tree and also used by some other tree diff --git a/themes/_administration/css-1.5.4/style.css b/themes/_administration/css-1.5.4/style.css index ecf7ec9bff..1c68e72c50 100644 --- a/themes/_administration/css-1.5.4/style.css +++ b/themes/_administration/css-1.5.4/style.css @@ -1909,10 +1909,6 @@ table#story_table { margin-top: 20px; } -#admin_content form { - padding: 10px 0; -} - /* Autocomplete styles */ .ui-autocomplete-input { background-color: #eee8aa; diff --git a/themes/_administration/header.php b/themes/_administration/header.php index b20c9eedb7..4be94314b1 100644 --- a/themes/_administration/header.php +++ b/themes/_administration/header.php @@ -119,6 +119,7 @@ foreach (WT_Tree::getAll() as $tree) { } echo '<li><a ', (WT_SCRIPT_NAME=='admin_site_merge.php' ? 'class="current" ' : ''), 'href="admin_site_merge.php">', WT_I18N::translate('Merge records'), '</a></li>', + '<li><a ', (WT_SCRIPT_NAME=='admin_trees_merge.php' ? 'class="current" ' : ''), 'href="admin_trees_merge.php">', WT_I18N::translate('Merge family trees'), '</a></li>', '<li><a ', (WT_SCRIPT_NAME=='admin_site_other.php' ? 'class="current" ' : ''), 'href="admin_site_other.php">', WT_I18N::translate('Add unlinked records'), '</a></li>', '<li><a ', (WT_SCRIPT_NAME=='admin_trees_places.php' ? 'class="current" ' : ''), 'href="admin_trees_places.php">', WT_I18N::translate('Update place names'), '</a></li>', '<li><a ', (WT_SCRIPT_NAME=='admin_trees_check.php' ? 'class="current" ' : ''), 'href="admin_trees_check.php">', WT_I18N::translate('Check for errors'), '</a></li>', |
