diff options
Diffstat (limited to 'admin')
-rw-r--r-- | admin/element_set_global.php | 12 | ||||
-rw-r--r-- | admin/include/functions.php | 14 |
2 files changed, 14 insertions, 12 deletions
diff --git a/admin/element_set_global.php b/admin/element_set_global.php index 05f4158b7..7bc8afe50 100644 --- a/admin/element_set_global.php +++ b/admin/element_set_global.php @@ -91,21 +91,9 @@ SELECT if (count($deletables) > 0) { - // what will be the categories to update? (to avoid orphan on - // representative_picture_id) - $query = ' -SELECT - category_id - FROM '.IMAGE_CATEGORY_TABLE.' - WHERE image_id IN ('.implode(',', $deletables).') -;'; - $categories_to_update = array_from_query($query, 'category_id'); - $physical_deletion = true; delete_elements($deletables, $physical_deletion); - update_category($categories_to_update); - array_push( $page['infos'], sprintf( diff --git a/admin/include/functions.php b/admin/include/functions.php index 018fd5021..c186e1ed8 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -234,6 +234,20 @@ DELETE FROM '.IMAGES_TABLE.' ;'; pwg_query($query); + // are the photo used as category representant? + $query = ' +SELECT + id + FROM '.CATEGORIES_TABLE.' + WHERE representative_picture_id IN ( +'.wordwrap(implode(', ', $ids), 80, "\n").') +;'; + $category_ids = array_from_query($query, 'id'); + if (count($category_ids) > 0) + { + update_category($category_ids); + } + trigger_action('delete_elements', $ids); } |