. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; use Fisharebest\Webtrees\Controller\PageController; define('WT_SCRIPT_NAME', 'admin_trees_duplicates.php'); require './includes/session.php'; $controller = new PageController; $controller ->restrictAccess(Auth::isManager($WT_TREE)) ->setPageTitle(I18N::translate('Find duplicates') . ' — ' . $WT_TREE->getTitleHtml()) ->pageHeader(); $repositories = Database::prepare( "SELECT GROUP_CONCAT(n_id) AS xrefs " . " FROM `##other`" . " JOIN `##name` ON o_id = n_id AND o_file = n_file" . " WHERE o_file = :tree_id AND o_type = 'REPO'" . " GROUP BY n_full" . " HAVING COUNT(n_id) > 1" )->execute(array( 'tree_id' => $WT_TREE->getTreeId(), ))->fetchAll(); $repositories = array_map( function (\stdClass $x) use ($WT_TREE) { $tmp = explode(',', $x->xrefs); return array_map(function ($y) use ($WT_TREE) { return Repository::getInstance($y, $WT_TREE); }, $tmp); }, $repositories ); $sources = Database::prepare( "SELECT GROUP_CONCAT(n_id) AS xrefs " . " FROM `##sources`" . " JOIN `##name` ON s_id = n_id AND s_file = n_file" . " WHERE s_file = :tree_id" . " GROUP BY n_full" . " HAVING COUNT(n_id) > 1" )->execute(array( 'tree_id' => $WT_TREE->getTreeId(), ))->fetchAll(); $sources = array_map( function (\stdClass $x) use ($WT_TREE) { $tmp = explode(',', $x->xrefs); return array_map(function ($y) use ($WT_TREE) { return Source::getInstance($y, $WT_TREE); }, $tmp); }, $sources ); $individuals = Database::prepare( "SELECT DISTINCT GROUP_CONCAT(d_gid ORDER BY d_gid) AS xrefs" . " FROM `##dates` AS d" . " JOIN `##name` ON d_file = n_file AND d_gid = n_id" . " WHERE d_file = :tree_id AND d_fact IN ('BIRT', 'CHR', 'BAPM', 'DEAT', 'BURI')" . " GROUP BY d_day, d_month, d_year, d_type, d_fact, n_type, n_full" . " HAVING COUNT(DISTINCT d_gid) > 1" )->execute(array( 'tree_id' => $WT_TREE->getTreeId(), ))->fetchAll(); $individuals = array_map( function (\stdClass $x) use ($WT_TREE) { $tmp = explode(',', $x->xrefs); return array_map(function ($y) use ($WT_TREE) { return Individual::getInstance($y, $WT_TREE); }, $tmp); }, $individuals ); $families = Database::prepare( "SELECT GROUP_CONCAT(f_id) AS xrefs " . " FROM `##families`" . " WHERE f_file = :tree_id" . " GROUP BY LEAST(f_husb, f_wife), GREATEST(f_husb, f_wife)" . " HAVING COUNT(f_id) > 1" )->execute(array( 'tree_id' => $WT_TREE->getTreeId(), ))->fetchAll(); $families = array_map( function (\stdClass $x) use ($WT_TREE) { $tmp = explode(',', $x->xrefs); return array_map(function ($y) use ($WT_TREE) { return Family::getInstance($y, $WT_TREE); }, $tmp); }, $families ); $media = Database::prepare( "SELECT GROUP_CONCAT(m_id) AS xrefs " . " FROM `##media`" . " WHERE m_file = :tree_id" . " GROUP BY m_titl" . " HAVING COUNT(m_id) > 1" )->execute(array( 'tree_id' => $WT_TREE->getTreeId(), ))->fetchAll(); $media = array_map( function (\stdClass $x) use ($WT_TREE) { $tmp = explode(',', $x->xrefs); return array_map(function ($y) use ($WT_TREE) { return Media::getInstance($y, $WT_TREE); }, $tmp); }, $media ); $all_duplicates = array( I18N::translate('Repositories') => $repositories, I18N::translate('Sources') => $sources, I18N::translate('Individuals') => $individuals, I18N::translate('Families') => $families, I18N::translate('Media objects') => $media, ); ?>

getPageTitle(); ?>

$duplicate_list): ?>