Changeset 17001 for branches/2.4


Ignore:
Timestamp:
Jul 25, 2012, 12:18:22 PM (12 years ago)
Author:
plg
Message:

bug 2627 fixed: photos added with the web form or pwg.images.addSimple now have
a correct image_category.rank.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/admin/include/functions.php

    r16168 r17001  
    15081508  pwg_query($query);
    15091509
     1510  $query = '
     1511SELECT
     1512    category_id,
     1513    MAX(rank) AS max_rank
     1514  FROM '.IMAGE_CATEGORY_TABLE.'
     1515  WHERE rank IS NOT NULL
     1516    AND category_id IN ('.implode(',', $categories).')
     1517  GROUP BY category_id
     1518;';
     1519
     1520  $current_rank_of = simple_hash_from_query(
     1521    $query,
     1522    'category_id',
     1523    'max_rank'
     1524    );
     1525
    15101526  $inserts = array();
    15111527  foreach ($categories as $category_id)
    15121528  {
     1529    if (!isset($current_rank_of[$category_id]))
     1530    {
     1531      $current_rank_of[$category_id] = 0;
     1532    }
     1533
    15131534    foreach ($images as $image_id)
    15141535    {
     1536      $rank = ++$current_rank_of[$category_id];
     1537
    15151538      array_push(
    15161539        $inserts,
     
    15181541          'image_id' => $image_id,
    15191542          'category_id' => $category_id,
     1543          'rank' => $rank,
    15201544          )
    15211545        );
     
    23422366function delete_element_derivatives($infos, $type='all')
    23432367{
     2368file_put_contents('/tmp/pwg24ws.log', "\n==== ".date('c')."\n".__FUNCTION__.' : '.var_export($infos, true)."\n", FILE_APPEND);
    23442369  $path = $infos['path'];
    23452370  if (!empty($infos['representative_ext']))
Note: See TracChangeset for help on using the changeset viewer.