Changeset 23292


Ignore:
Timestamp:
Jun 17, 2013, 8:08:42 PM (11 years ago)
Author:
mistic100
Message:

fix batch deletion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/admin/sets.php

    r23280 r23292  
    55if (isset($_GET['delete']))
    66{
    7   $BatchDownloader = new BatchDownloader($_GET['delete']);
    8   $BatchDownloader->delete();
    9   unset($BatchDownloader);
     7  $set = new BatchDownloader($_GET['delete']);
     8  $set->delete();
     9  unset($set);
    1010}
    1111if (isset($_GET['cancel']))
    1212{
    13   $BatchDownloader = new BatchDownloader($_GET['cancel']); 
    14   $BatchDownloader->updateParam('total_size', $BatchDownloader->getEstimatedTotalSize());
    15   $BatchDownloader->updateParam('status', 'done');
    16   $BatchDownloader->deleteLastArchive();
    17   $BatchDownloader->clearImages();
    18   unset($BatchDownloader);
     13  $set = new BatchDownloader($_GET['cancel']); 
     14  $set->updateParam('total_size', $set->getEstimatedTotalSize());
     15  $set->updateParam('nb_zip', $set->getEstimatedArchiveNumber());
     16  $set->updateParam('status', 'done');
     17  $set->deleteLastArchive();
     18  $set->clearImages();
     19  unset($set);
    1920}
    2021if (isset($_POST['delete_done']))
    2122{
    2223  $query = '
    23 DELETE s, i
    24   FROM '.BATCH_DOWNLOAD_TSETS.' AS s
    25     LEFT JOIN '.BATCH_DOWNLOAD_TIMAGES.' AS i
    26     ON i.set_id = s.id
     24SELECT id
     25  FROM '.BATCH_DOWNLOAD_TSETS.'
    2726  WHERE
    2827    status = "done" AND
    2928    date_creation < DATE_SUB(NOW(), INTERVAL 1 HOUR)
    3029;';
    31   pwg_query($query);
     30 
     31  $sets = array_from_query($query, 'id');
     32 
     33  foreach ($sets as $set_id)
     34  {
     35    $set = new BatchDownloader($set_id);
     36    $set->delete();
     37    unset($set);
     38  }
    3239}
    3340
Note: See TracChangeset for help on using the changeset viewer.