Ignore:
Timestamp:
Jul 10, 2012, 3:39:01 PM (12 years ago)
Author:
mistic100
Message:

-compatiblity with UserCollections
-don't crash for non-admin users (sic)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/include/events.inc.php

    r16400 r16592  
    9696  }
    9797 
     98  if ($page['section'] == 'collections')
     99  {
     100    $url = $_SERVER['REQUEST_URI'];
     101  }
     102  else
     103  {
     104    $url = duplicate_index_url(array(), array('action'));
     105  }
     106 
    98107  // toolbar button
    99   $button = '<li><a href="'. duplicate_index_url(array(), array('action')) .'&amp;action=advdown_set" title="'.l10n('Download all pictures of this selection').'" class="pwg-state-default pwg-button" rel="nofollow">
     108  $button = '<li><a href="'. $url .'&amp;action=advdown_set" title="'.l10n('Download all pictures of this selection').'" class="pwg-state-default pwg-button" rel="nofollow">
    100109                        <span class="pwg-icon" style="background:url(\'' . BATCH_DOWNLOAD_PATH . 'template/zip.png\') center center no-repeat;">&nbsp;</span><span class="pwg-button-text">'.l10n('Advanced Downloader').'</span>
    101110                </a></li>';
    102111  $template->concat('PLUGIN_INDEX_ACTIONS', $button);
     112  $template->concat('COLLECTION_ACTIONS', $button);
    103113}
    104114
     
    178188  conf_update_param('batch_download', serialize($conf['batch_download']));
    179189 
    180   // set old sets as done
     190  // set old sets as done and clean images table
    181191  $query = '
    182 SELECT id
    183   FROM '.BATCH_DOWNLOAD_TSETS.'
     192DELETE i
     193  FROM '.BATCH_DOWNLOAD_TIMAGES.' AS i
     194    INNER JOIN '.BATCH_DOWNLOAD_TSETS.' AS s
     195    ON i.set_id = s.id
     196  WHERE
     197    status != "done" AND
     198    date_creation < DATE_SUB(NOW(), INTERVAL '.$conf['batch_download']['archive_timeout'].' HOUR)
     199;';
     200  pwg_query($query);
     201 
     202  $query = '
     203UPDATE '.BATCH_DOWNLOAD_TSETS.'
     204  SET status = "done"
    184205  WHERE
     206    status != "done" AND
    185207    date_creation < DATE_SUB(NOW(), INTERVAL '.$conf['batch_download']['archive_timeout'].' HOUR)
    186     AND status != "done"
    187 ;';
    188   $sets = array_from_query($query, 'id');
    189  
    190   foreach ($sets as $set_id)
    191   {
    192     $BatchDownloader = new BatchDownloader($set_id);
    193     $BatchDownloader->deleteLastArchive();
    194     $BatchDownloader->clearImages();
    195     $BatchDownloader->updateParam('status', 'done');
    196   }
     208;';
     209  pwg_query($query);
    197210 
    198211  // remove old archives
Note: See TracChangeset for help on using the changeset viewer.