Index: extensions/BatchDownloader/include/BatchDownloader.class.php
===================================================================
--- extensions/BatchDownloader/include/BatchDownloader.class.php	(revision 16400)
+++ extensions/BatchDownloader/include/BatchDownloader.class.php	(revision 16592)
@@ -39,4 +39,5 @@
       $query = '
 SELECT
+    user_id,
     date_creation,
     type,
@@ -58,4 +59,5 @@
         $this->data['set_id'] = $set_id;
         list(
+          $this->data['user_id'],
           $this->data['date_creation'],
           $this->data['type'], 
@@ -68,5 +70,5 @@
           ) = pwg_db_fetch_row($result);
         
-        // make sur all pictures of the set exists
+        // make sur all pictures of the set exist
         $query = '
 DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.'
@@ -606,11 +608,18 @@
       }
       
-      // selection
-      // case 'selection':
-      // {
-        // $set['NAME'] = '';
-        // $set['COMMENT'] = '';
-        // break;
-      // }
+      // collection
+      case 'collection':
+      {
+        try
+        {
+          $UserCollection = new UserCollection($this->data['type_id']);
+          $set['NAME'] = l10n('Collection').': <a href="'.USER_COLLEC_PUBLIC.'view/'.$UserCollection->getParam('col_id').'">'.$UserCollection->getParam('name').'</a>';
+        }
+        catch (Exception $e)
+        {
+          $set['NAME'] = l10n('Collection').': #'.$this->data['type_id'].' (deleted)';
+        }
+        break;
+      }
     }
     
Index: extensions/BatchDownloader/include/download.inc.php
===================================================================
--- extensions/BatchDownloader/include/download.inc.php	(revision 16400)
+++ extensions/BatchDownloader/include/download.inc.php	(revision 16592)
@@ -63,4 +63,5 @@
   /* edition page */
   case 'view':
+  {
     $self_url = BATCH_DOWNLOAD_PUBLIC . 'view&amp;set_id='.$_GET['set_id'];
     
@@ -106,5 +107,6 @@
     include(PHPWG_ROOT_PATH . 'include/category_default.inc.php');
     
-    break;    
+    break;
+  }
 }
 
@@ -116,5 +118,5 @@
   $search = '<span class="thumbName">';
   
-  $add = '<a href="{$U_VIEW}&amp;remove={$thumbnail.id}">
+  $add = '<a href="{$U_VIEW}&amp;remove={$thumbnail.id}" rel="nofollow">
 <img src="{$BATCH_DOWNLOAD_PATH}template/image_delete.png" title="{\'Remove from download set\'|@translate}">
 </a>&nbsp;';
Index: extensions/BatchDownloader/include/events.inc.php
===================================================================
--- extensions/BatchDownloader/include/events.inc.php	(revision 16400)
+++ extensions/BatchDownloader/include/events.inc.php	(revision 16592)
@@ -96,9 +96,19 @@
   }
   
+  if ($page['section'] == 'collections')
+  {
+    $url = $_SERVER['REQUEST_URI'];
+  }
+  else
+  {
+    $url = duplicate_index_url(array(), array('action'));
+  }
+  
   // toolbar button
-  $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">
+  $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">
 			<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>
 		</a></li>';
   $template->concat('PLUGIN_INDEX_ACTIONS', $button);
+  $template->concat('COLLECTION_ACTIONS', $button);
 }
 
@@ -178,21 +188,24 @@
   conf_update_param('batch_download', serialize($conf['batch_download']));
   
-  // set old sets as done
+  // set old sets as done and clean images table
   $query = '
-SELECT id 
-  FROM '.BATCH_DOWNLOAD_TSETS.'
+DELETE i
+  FROM '.BATCH_DOWNLOAD_TIMAGES.' AS i
+    INNER JOIN '.BATCH_DOWNLOAD_TSETS.' AS s
+    ON i.set_id = s.id
+  WHERE
+    status != "done" AND
+    date_creation < DATE_SUB(NOW(), INTERVAL '.$conf['batch_download']['archive_timeout'].' HOUR)
+;';
+  pwg_query($query);
+  
+  $query = '
+UPDATE '.BATCH_DOWNLOAD_TSETS.'
+  SET status = "done"
   WHERE 
+    status != "done" AND
     date_creation < DATE_SUB(NOW(), INTERVAL '.$conf['batch_download']['archive_timeout'].' HOUR)
-    AND status != "done"
-;';
-  $sets = array_from_query($query, 'id');
-  
-  foreach ($sets as $set_id)
-  {
-    $BatchDownloader = new BatchDownloader($set_id);
-    $BatchDownloader->deleteLastArchive();
-    $BatchDownloader->clearImages();
-    $BatchDownloader->updateParam('status', 'done');
-  }
+;';
+  pwg_query($query);
   
   // remove old archives
Index: extensions/BatchDownloader/include/functions.inc.php
===================================================================
--- extensions/BatchDownloader/include/functions.inc.php	(revision 16400)
+++ extensions/BatchDownloader/include/functions.inc.php	(revision 16592)
@@ -44,4 +44,11 @@
       $batch_type = 'search';
       $batch_id = $page['search'];
+      break;
+    case 'collections':
+      if (in_array(@$page['sub_section'], array('view','edit')))
+      {
+        $batch_type = 'collection';
+        $batch_id = $page['col_id'];
+      }
       break;
     case 'favorites':
Index: extensions/BatchDownloader/main.inc.php
===================================================================
--- extensions/BatchDownloader/main.inc.php	(revision 16400)
+++ extensions/BatchDownloader/main.inc.php	(revision 16592)
@@ -20,4 +20,5 @@
 define('BATCH_DOWNLOAD_PUBLIC',  make_index_url(array('section' => 'download')) . '/');
 
+
 if (class_exists('ZipArchive'))
 {
@@ -29,5 +30,5 @@
   add_event_handler('loc_end_index', 'batch_download_clean');
 
-  add_event_handler('loc_begin_index', 'batch_download_index_button');
+  add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
 
   add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
@@ -38,4 +39,5 @@
   require(BATCH_DOWNLOAD_PATH . 'include/events.inc.php');
 }
+
 
 add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu');
