aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2012-07-25 10:18:22 +0000
committerplegall <plg@piwigo.org>2012-07-25 10:18:22 +0000
commit261a3862915d8e3d9f12aaa033d64061da50201d (patch)
tree5ada7a1212e50ceb67459fd52b4a385594dc689a /admin/include
parent6b8f0a49f945a5588388398d2218901e1d12b7aa (diff)
bug 2627 fixed: photos added with the web form or pwg.images.addSimple now have
a correct image_category.rank. git-svn-id: http://piwigo.org/svn/branches/2.4@17001 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include')
-rw-r--r--admin/include/functions.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 85295e472..93453715b 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1507,16 +1507,40 @@ DELETE
;';
pwg_query($query);
+ $query = '
+SELECT
+ category_id,
+ MAX(rank) AS max_rank
+ FROM '.IMAGE_CATEGORY_TABLE.'
+ WHERE rank IS NOT NULL
+ AND category_id IN ('.implode(',', $categories).')
+ GROUP BY category_id
+;';
+
+ $current_rank_of = simple_hash_from_query(
+ $query,
+ 'category_id',
+ 'max_rank'
+ );
+
$inserts = array();
foreach ($categories as $category_id)
{
+ if (!isset($current_rank_of[$category_id]))
+ {
+ $current_rank_of[$category_id] = 0;
+ }
+
foreach ($images as $image_id)
{
+ $rank = ++$current_rank_of[$category_id];
+
array_push(
$inserts,
array(
'image_id' => $image_id,
'category_id' => $category_id,
+ 'rank' => $rank,
)
);
}
@@ -2341,6 +2365,7 @@ function clear_derivative_cache_rec($path, $pattern)
function delete_element_derivatives($infos, $type='all')
{
+file_put_contents('/tmp/pwg24ws.log', "\n==== ".date('c')."\n".__FUNCTION__.' : '.var_export($infos, true)."\n", FILE_APPEND);
$path = $infos['path'];
if (!empty($infos['representative_ext']))
{