Ignore:
Timestamp:
Dec 31, 2010, 1:34:01 PM (10 years ago)
Author:
plg
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager.php

    r8403 r8404  
    5555  if (isset($_POST['filter_prefilter_use']))
    5656  {
    57     $prefilters = array('caddie', 'last import', 'with no album', 'with no tag', 'with no virtual album');
     57    $prefilters = array('caddie', 'last import', 'with no album', 'with no tag', 'with no virtual album', 'duplicates');
    5858    if (in_array($_POST['filter_prefilter'], $prefilters))
    5959    {
     
    174174      $filter_sets,
    175175      array_diff($all_elements, $linked_to_virtual)
     176      );
     177  }
     178
     179  if ('duplicates' == $_SESSION['bulk_manager_filter']['prefilter'])
     180  {
     181    // we could use the group_concat MySQL function to retrieve the list of
     182    // image_ids but it would not be compatible with PostgreSQL, so let's
     183    // perform 2 queries instead. We hope there are not too many duplicates.
     184   
     185    $query = '
     186SELECT file
     187  FROM '.IMAGES_TABLE.'
     188  GROUP BY file
     189  HAVING COUNT(*) > 1
     190;';
     191    $duplicate_files = array_from_query($query, 'file');
     192   
     193    $query = '
     194SELECT id
     195  FROM '.IMAGES_TABLE.'
     196  WHERE file IN (\''.implode("','", $duplicate_files).'\')
     197;';
     198
     199    array_push(
     200      $filter_sets,
     201      array_from_query($query, 'id')
    176202      );
    177203  }
Note: See TracChangeset for help on using the changeset viewer.