Skip to content

Commit

Permalink
feature 2089: add the "duplicates" feature to the new Batch Manager and
Browse files Browse the repository at this point in the history
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
  • Loading branch information
plegall committed Dec 31, 2010
1 parent aa30ee7 commit a9445d2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
28 changes: 27 additions & 1 deletion admin/batch_manager.php
Expand Up @@ -54,7 +54,7 @@

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'];
Expand Down Expand Up @@ -175,6 +175,32 @@
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']))
Expand Down
7 changes: 7 additions & 0 deletions admin/batch_manager_global.php
Expand Up @@ -527,6 +527,13 @@
$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;
Expand Down
8 changes: 0 additions & 8 deletions admin/maintenance.php
Expand Up @@ -150,14 +150,6 @@

$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',
Expand Down
2 changes: 1 addition & 1 deletion admin/themes/default/template/batch_manager_global.tpl
Expand Up @@ -356,8 +356,8 @@ a.removeFilter:hover {background: url(admin/themes/default/icon/remove_filter_ho
{if $ENABLE_SYNCHRONIZATION}
<option value="with no virtual album" {if $filter.prefilter eq 'with no virtual album'}selected="selected"{/if}>with no virtual album</option>
{/if}
<option value="duplicates" {if $filter.prefilter eq 'duplicates'}selected="selected"{/if}>duplicates</option>
<!-- <option value="with no album">with no album</option> -->
<!-- <option value="with no virtual album">with no virtual album</option> -->
<!-- <option value="with no tag">with no tag</option> -->
</select>
</li>
Expand Down

0 comments on commit a9445d2

Please sign in to comment.