mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
fixes #349, API set ranks of all album photos at once
on pwg.images.setRank, ability to provide a list of image_id (and no rank). This way you can set the order of all photos of a given album, at once.
This commit is contained in:
@@ -2848,4 +2848,33 @@ SELECT
|
||||
;';
|
||||
|
||||
return query2array($query, null, 'id');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* save the rank depending on given images order
|
||||
*
|
||||
* The list of ordered images id is supposed to be in the same parent
|
||||
* category
|
||||
*
|
||||
* @param int category_id
|
||||
* @param int[] images
|
||||
* @return void
|
||||
*/
|
||||
function save_images_order($category_id, $images)
|
||||
{
|
||||
$current_rank = 0;
|
||||
$datas = array();
|
||||
foreach ($images as $id)
|
||||
{
|
||||
$datas[] = array(
|
||||
'category_id' => $category_id,
|
||||
'image_id' => $id,
|
||||
'rank' => ++$current_rank,
|
||||
);
|
||||
}
|
||||
$fields = array(
|
||||
'primary' => array('image_id', 'category_id'),
|
||||
'update' => array('rank')
|
||||
);
|
||||
mass_updates(IMAGE_CATEGORY_TABLE, $fields, $datas);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user