From a9445d297540abff2125393b520509b0f2387132 Mon Sep 17 00:00:00 2001 From: plegall Date: Fri, 31 Dec 2010 12:34:01 +0000 Subject: feature 2089: add the "duplicates" feature to the new Batch Manager and simplify the algorithm. The duplicates do not rely on physical albums, just on duplicate filenames. git-svn-id: http://piwigo.org/svn/trunk@8404 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/batch_manager.php | 28 +++++++++++++++++++++- admin/batch_manager_global.php | 7 ++++++ admin/maintenance.php | 8 ------- .../default/template/batch_manager_global.tpl | 2 +- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/admin/batch_manager.php b/admin/batch_manager.php index e9a82966e..c055544ae 100644 --- a/admin/batch_manager.php +++ b/admin/batch_manager.php @@ -54,7 +54,7 @@ if (isset($_POST['submitFilter'])) if (isset($_POST['filter_prefilter_use'])) { - $prefilters = array('caddie', 'last import', 'with no album', 'with no tag', 'with no virtual album'); + $prefilters = array('caddie', 'last import', 'with no album', 'with no tag', 'with no virtual album', 'duplicates'); if (in_array($_POST['filter_prefilter'], $prefilters)) { $_SESSION['bulk_manager_filter']['prefilter'] = $_POST['filter_prefilter']; @@ -175,6 +175,32 @@ SELECT id array_diff($all_elements, $linked_to_virtual) ); } + + if ('duplicates' == $_SESSION['bulk_manager_filter']['prefilter']) + { + // we could use the group_concat MySQL function to retrieve the list of + // image_ids but it would not be compatible with PostgreSQL, so let's + // perform 2 queries instead. We hope there are not too many duplicates. + + $query = ' +SELECT file + FROM '.IMAGES_TABLE.' + GROUP BY file + HAVING COUNT(*) > 1 +;'; + $duplicate_files = array_from_query($query, 'file'); + + $query = ' +SELECT id + FROM '.IMAGES_TABLE.' + WHERE file IN (\''.implode("','", $duplicate_files).'\') +;'; + + array_push( + $filter_sets, + array_from_query($query, 'id') + ); + } } if (isset($_SESSION['bulk_manager_filter']['category'])) diff --git a/admin/batch_manager_global.php b/admin/batch_manager_global.php index d6b793f39..c374e888d 100644 --- a/admin/batch_manager_global.php +++ b/admin/batch_manager_global.php @@ -527,6 +527,13 @@ if (count($page['cat_elements_id']) > 0) $is_category = true; } + if (isset($_SESSION['bulk_manager_filter']['prefilter']) + and 'duplicates' == $_SESSION['bulk_manager_filter']['prefilter']) + { + $conf['order_by'] = ' ORDER BY file, id'; + } + + $query = ' SELECT id,path,tn_ext,file,filesize,level,name FROM '.IMAGES_TABLE; diff --git a/admin/maintenance.php b/admin/maintenance.php index 0f8f23aaa..6e39eb0e2 100644 --- a/admin/maintenance.php +++ b/admin/maintenance.php @@ -150,14 +150,6 @@ $template->assign( $advanced_features = array(); -array_push( - $advanced_features, - array( - 'CAPTION' => l10n('Files with same name in more than one physical album'), - 'URL' => get_root_url().'admin.php?page=element_set&cat=duplicates' - ) - ); - //$advanced_features is array of array composed of CAPTION & URL $advanced_features = trigger_event( 'get_admin_advanced_features_links', diff --git a/admin/themes/default/template/batch_manager_global.tpl b/admin/themes/default/template/batch_manager_global.tpl index a663089d4..ea88b9a9a 100644 --- a/admin/themes/default/template/batch_manager_global.tpl +++ b/admin/themes/default/template/batch_manager_global.tpl @@ -356,8 +356,8 @@ a.removeFilter:hover {background: url(admin/themes/default/icon/remove_filter_ho {if $ENABLE_SYNCHRONIZATION} {/if} + - -- cgit v1.2.3