mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-05 09:22:21 +02:00
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
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -10,7 +10,7 @@ use Getopt::Long;
|
||||
my %opt = ();
|
||||
GetOptions(
|
||||
\%opt,
|
||||
qw/action=s file=s thumbnail=s category_id=i name=s rank=i/
|
||||
qw/action=s file=s thumbnail=s category_id=i name=s rank=s/
|
||||
);
|
||||
|
||||
our $ua = LWP::UserAgent->new;
|
||||
@@ -61,7 +61,7 @@ if ($opt{action} eq 'pwg.images.add') {
|
||||
thumbnail_content => $thumbnail_content,
|
||||
category_id => $opt{category_id},
|
||||
name => $opt{name},
|
||||
rank => defined($opt{rank}) ? $opt{rank} : 1,
|
||||
rank => defined($opt{rank}) ? $opt{rank} : 'auto',
|
||||
};
|
||||
|
||||
my $response = $ua->post(
|
||||
|
||||
Reference in New Issue
Block a user