Ignore:
Timestamp:
Jul 13, 2012, 12:12:21 PM (12 years ago)
Author:
mistic100
Message:

-separate "archive_comment" in a new config parameter
-confirmation message before start download

File:
1 edited

Legend:

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

    r16626 r16689  
    2020   
    2121    $this->conf = $conf['batch_download'];
     22    $this->conf['archive_acomment'] = $conf['batch_download_comment'];
    2223    $this->data = array(
    23       'set_id' => 0,
     24      'id' => 0,
    2425      'user_id' => $user['id'],
    2526      'date_creation' => '0000-00-00 00:00:00',
     
    3940      $query = '
    4041SELECT
     42    id,
    4143    user_id,
    4244    date_creation,
     
    5759      if (pwg_db_num_rows($result))
    5860      {
    59         $this->data['set_id'] = $set_id;
    60         list(
    61           $this->data['user_id'],
    62           $this->data['date_creation'],
    63           $this->data['type'],
    64           $this->data['type_id'],
    65           $this->data['nb_zip'],
    66           $this->data['last_zip'],
    67           $this->data['nb_images'],
    68           $this->data['total_size'],
    69           $this->data['status']
    70           ) = pwg_db_fetch_row($result);
     61        $this->data = array_merge(
     62          $this->data,
     63          pwg_db_fetch_assoc($result)
     64          );
    7165       
    7266        // make sur all pictures of the set exist
     
    8478    zip
    8579  FROM '.BATCH_DOWNLOAD_TIMAGES.'
    86   WHERE set_id = '.$this->data['set_id'].'
     80  WHERE set_id = '.$this->data['id'].'
    8781;';
    8882        $this->images = simple_hash_from_query($query, 'image_id', 'zip');
     
    129123;';
    130124      pwg_query($query);
    131       $this->data['set_id'] = pwg_db_insert_id();
     125      $this->data['id'] = pwg_db_insert_id();
    132126     
    133127      $date = pwg_query('SELECT FROM_UNIXTIME(NOW());');
     
    153147  {
    154148    $this->data[$name] = $value;
    155     pwg_query('UPDATE '.BATCH_DOWNLOAD_TSETS.' SET '.$name.' = "'.$value.'" WHERE id = '.$this->data['set_id'].';');
     149    pwg_query('UPDATE '.BATCH_DOWNLOAD_TSETS.' SET '.$name.' = "'.$value.'" WHERE id = '.$this->data['id'].';');
    156150  }
    157151 
     
    201195DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.'
    202196  WHERE
    203     set_id = '.$this->data['set_id'].'
     197    set_id = '.$this->data['id'].'
    204198    AND image_id IN('.implode(',', $image_ids).')
    205199;';
     
    225219     
    226220      $this->images[ $image_id ] = 0;
    227       array_push($inserts, array('set_id'=>$this->data['set_id'], 'image_id'=>$image_id, 'zip'=>0));
     221      array_push($inserts, array('set_id'=>$this->data['id'], 'image_id'=>$image_id, 'zip'=>0));
    228222    }
    229223   
     
    246240    $query = '
    247241DELETE FROM '.BATCH_DOWNLOAD_TIMAGES.'
    248   WHERE set_id = '.$this->data['set_id'].'
     242  WHERE set_id = '.$this->data['id'].'
    249243;';
    250244    pwg_query($query);
     
    348342      if (!empty($this->conf['archive_comment']))
    349343      {
    350         $comment.= "\n\n".$this->conf['archive_comment'];
     344        $comment.= "\n\n".wordwrap(remove_accents($this->conf['archive_comment']), 60);
    351345      }
    352346      $zip->setArchiveComment($comment);
     
    359353  SET zip = '.$this->data['last_zip'].'
    360354  WHERE
    361     set_id = '.$this->data['set_id'].'
     355    set_id = '.$this->data['id'].'
    362356    AND image_id IN('.implode(',', $images_added).')
    363357;';
     
    442436      else if ($i == $this->data['last_zip']+1)
    443437      {
    444           $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['set_id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"'
     438          $out.= '<a href="'.add_url_params($url, array('set_id'=>$this->data['id'],'zip'=>$i)).'" rel="nofollow" style="font-weight:bold;"'
    445439            .($i!=1 ? 'onClick="return confirm(\'Starting download Archive #'.$i.' will destroy Archive #'.($i-1).', be sure you finish the download. Continue ?\');"' : null).
    446440            '><img src="'.BATCH_DOWNLOAD_PATH.'template/drive_go.png"> Archive #'.$i.' (ready)</a>';
     
    477471          get_username($this->data['user_id']) .'_'.
    478472          $this->data['type'] .'-'. $this->data['type_id'] .'_'.
    479           $this->data['user_id'] . $this->data['set_id'] .
     473          $this->data['user_id'] . $this->data['id'] .
    480474          ($this->data['nb_zip']!=1 ? '_part'. $i : null).
    481475          '.zip';
Note: See TracChangeset for help on using the changeset viewer.