diff options
author | plegall <plg@piwigo.org> | 2008-09-19 22:59:41 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2008-09-19 22:59:41 +0000 |
commit | d55107e3e3511e4b2c52b56aaa1d6f7c6fd46b27 (patch) | |
tree | 1c061e4d920a47e304255bbc7c05b337f526cecb /include/ws_functions.inc.php | |
parent | 67ffcee5040fcb20775332ae18f8da4668410c84 (diff) |
improvement: instead of sending the images_max_rank of each category in
pwg.categories.getList so that you can correctly set the rank in
pwg.images.add, the rank is calculated automatically in pwg.images.add so
that the image is added at the end of the category.
git-svn-id: http://piwigo.org/svn/trunk@2553 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/ws_functions.inc.php')
-rw-r--r-- | include/ws_functions.inc.php | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 5d12bd5f2..4440b15ac 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -364,20 +364,6 @@ function ws_categories_getList($params, &$service) { global $user,$conf; - $query = ' -SELECT - category_id, - MAX(rank) AS max_rank - FROM '.IMAGE_CATEGORY_TABLE.' - WHERE rank IS NOT NULL - GROUP BY category_id -;'; - $max_image_rank_of = simple_hash_from_query( - $query, - 'category_id', - 'max_rank' - ); - $where = array(); if (!$params['recursive']) @@ -429,11 +415,6 @@ SELECT id, name, permalink, uppercats, global_rank, { $row[$key] = (int)$row[$key]; } - - if (isset($max_image_rank_of[ $row['id'] ])) - { - $row['images_max_rank'] = $max_image_rank_of[ $row['id'] ]; - } array_push($cats, $row); } @@ -450,7 +431,6 @@ SELECT id, name, permalink, uppercats, global_rank, 'nb_categories', 'date_last', 'max_date_last', - 'images_max_rank', ) ) ); @@ -862,6 +842,7 @@ function ws_images_add($params, &$service) // $fh_log = fopen('/tmp/php.log', 'w'); // fwrite($fh_log, time()."\n"); + // fwrite($fh_log, 'input rank :'.$params['rank']."\n"); // fwrite($fh_log, 'input: '.$params['file_sum']."\n"); // fwrite($fh_log, 'input: '.$params['thumbnail_sum']."\n"); @@ -958,8 +939,25 @@ function ws_images_add($params, &$service) $insert = array( 'category_id' => $params['category_id'], 'image_id' => $image_id, - 'rank' => $params['rank'], ); + + if ('auto' == $params['rank']) + { + $query = ' +SELECT + MAX(rank) AS max_rank + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE rank IS NOT NULL + AND category_id = '.$params['category_id'].' +;'; + $row = mysql_fetch_assoc(pwg_query($query)); + $insert['rank'] = isset($row['max_rank']) ? $row['max_rank']+1 : 1; + } + else if (is_numeric($params['rank'])) + { + $insert['rank'] = (int)$params['rank']; + } + mass_inserts( IMAGE_CATEGORY_TABLE, array_keys($insert), |