fixes #1735 new API method pwg.images.setCategory to associate/dissociate/move a list of images

This commit is contained in:
plegall
2023-10-11 16:58:14 +02:00
parent 71164f80d6
commit 14e8ba664b
5 changed files with 112 additions and 24 deletions
+2 -23
View File
@@ -207,31 +207,10 @@ DELETE
else if ('dissociate' == $action)
{
// physical links must not be broken, so we must first retrieve image_id
// which create virtual links with the category to "dissociate from".
$query = '
SELECT id
FROM '.IMAGE_CATEGORY_TABLE.'
INNER JOIN '.IMAGES_TABLE.' ON image_id = id
WHERE category_id = '.$_POST['dissociate'].'
AND id IN ('.implode(',', $collection).')
AND (
category_id != storage_category_id
OR storage_category_id IS NULL
)
;';
$dissociables = array_from_query($query, 'id');
$nb_dissociated = dissociate_images_from_category($collection, $_POST['dissociate']);
if (!empty($dissociables))
if ($nb_dissociated > 0)
{
$query = '
DELETE
FROM '.IMAGE_CATEGORY_TABLE.'
WHERE category_id = '.$_POST['dissociate'].'
AND image_id IN ('.implode(',', $dissociables).')
';
pwg_query($query);
$_SESSION['page_infos'] = array(
l10n('Information data registered in database')
);