Changeset 16592


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)

Location:
extensions/BatchDownloader
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/BatchDownloader/include/BatchDownloader.class.php

    r16400 r16592  
    3939      $query = '
    4040SELECT
     41    user_id,
    4142    date_creation,
    4243    type,
     
    5859        $this->data['set_id'] = $set_id;
    5960        list(
     61          $this->data['user_id'],
    6062          $this->data['date_creation'],
    6163          $this->data['type'],
     
    6870          ) = pwg_db_fetch_row($result);
    6971       
    70         // make sur all pictures of the set exists
     72        // make sur all pictures of the set exist
    7173        $query = '
    7274DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.'
     
    606608      }
    607609     
    608       // selection
    609       // case 'selection':
    610       // {
    611         // $set['NAME'] = '';
    612         // $set['COMMENT'] = '';
    613         // break;
    614       // }
     610      // collection
     611      case 'collection':
     612      {
     613        try
     614        {
     615          $UserCollection = new UserCollection($this->data['type_id']);
     616          $set['NAME'] = l10n('Collection').': <a href="'.USER_COLLEC_PUBLIC.'view/'.$UserCollection->getParam('col_id').'">'.$UserCollection->getParam('name').'</a>';
     617        }
     618        catch (Exception $e)
     619        {
     620          $set['NAME'] = l10n('Collection').': #'.$this->data['type_id'].' (deleted)';
     621        }
     622        break;
     623      }
    615624    }
    616625   
  • extensions/BatchDownloader/include/download.inc.php

    r16400 r16592  
    6363  /* edition page */
    6464  case 'view':
     65  {
    6566    $self_url = BATCH_DOWNLOAD_PUBLIC . 'view&amp;set_id='.$_GET['set_id'];
    6667   
     
    106107    include(PHPWG_ROOT_PATH . 'include/category_default.inc.php');
    107108   
    108     break;   
     109    break;
     110  }
    109111}
    110112
     
    116118  $search = '<span class="thumbName">';
    117119 
    118   $add = '<a href="{$U_VIEW}&amp;remove={$thumbnail.id}">
     120  $add = '<a href="{$U_VIEW}&amp;remove={$thumbnail.id}" rel="nofollow">
    119121<img src="{$BATCH_DOWNLOAD_PATH}template/image_delete.png" title="{\'Remove from download set\'|@translate}">
    120122</a>&nbsp;';
  • 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
  • extensions/BatchDownloader/include/functions.inc.php

    r16400 r16592  
    4444      $batch_type = 'search';
    4545      $batch_id = $page['search'];
     46      break;
     47    case 'collections':
     48      if (in_array(@$page['sub_section'], array('view','edit')))
     49      {
     50        $batch_type = 'collection';
     51        $batch_id = $page['col_id'];
     52      }
    4653      break;
    4754    case 'favorites':
  • extensions/BatchDownloader/main.inc.php

    r16379 r16592  
    2020define('BATCH_DOWNLOAD_PUBLIC',  make_index_url(array('section' => 'download')) . '/');
    2121
     22
    2223if (class_exists('ZipArchive'))
    2324{
     
    2930  add_event_handler('loc_end_index', 'batch_download_clean');
    3031
    31   add_event_handler('loc_begin_index', 'batch_download_index_button');
     32  add_event_handler('loc_end_index', 'batch_download_index_button', EVENT_HANDLER_PRIORITY_NEUTRAL+10);
    3233
    3334  add_event_handler('blockmanager_register_blocks', 'batch_download_add_menublock');
     
    3839  require(BATCH_DOWNLOAD_PATH . 'include/events.inc.php');
    3940}
     41
    4042
    4143add_event_handler('get_admin_plugin_menu_links', 'batch_download_admin_menu');
Note: See TracChangeset for help on using the changeset viewer.