Changeset 765


Ignore:
Timestamp:
Apr 20, 2005, 9:09:50 PM (19 years ago)
Author:
plg
Message:
  • bug 96 : informations given by uploaders were never used during database synchronisation. A new block has been added to retrieve "waiting" table informations and transfer them to "images" table.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/branch-1_4/admin/update.php

    r723 r765  
    454454  echo get_elapsed_time($start_files, get_moment());
    455455  echo ' -->'."\n";
     456
     457  // retrieving informations given by uploaders
     458  if (!$simulate)
     459  {
     460    $query = '
     461SELECT id,file,storage_category_id,infos
     462  FROM '.WAITING_TABLE.'
     463  WHERE storage_category_id IN (
     464'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
     465    AND validated = \'true\'
     466;';
     467    $result = pwg_query($query);
     468 
     469    $datas = array();
     470    $fields =
     471      array(
     472        'primary' => array('id'),
     473        'update'  => array('date_creation', 'author', 'name', 'comment')
     474        );
     475
     476    $waiting_to_delete = array();
     477   
     478    while ($row = mysql_fetch_array($result))
     479    {
     480      $data = array();
     481     
     482      $query = '
     483SELECT id
     484  FROM '.IMAGES_TABLE.'
     485  WHERE storage_category_id = \''.$row['storage_category_id'].'\'
     486    AND file = \''.$row['file'].'\'
     487;';
     488      list($data['id']) = mysql_fetch_array(pwg_query($query));
     489
     490      foreach ($fields['update'] as $field)
     491      {
     492        $data[$field] = getAttribute($row['infos'], $field);
     493      }
     494     
     495      array_push($datas, $data);
     496      array_push($waiting_to_delete, $row['id']);
     497    }
     498
     499    if (count($datas) > 0)
     500    {
     501      mass_updates(IMAGES_TABLE, $fields, $datas);
     502
     503      // delete now useless waiting elements
     504      $query = '
     505DELETE
     506  FROM '.WAITING_TABLE.'
     507  WHERE id IN ('.implode(',', $waiting_to_delete).')
     508;';
     509      pwg_query($query);
     510    }
     511  }
    456512}
    457513// +-----------------------------------------------------------------------+
Note: See TracChangeset for help on using the changeset viewer.