From 92224bcbf49d58829988eb0485afc17695f6de0c Mon Sep 17 00:00:00 2001 From: plegall Date: Fri, 9 Oct 2015 19:13:30 +0200 Subject: fix #357 make orphans photos more obvious ... and easy to delete them all in one click. The orpans, if any, is shown as an entry in the "Photos" menu (link on Batch Manager). In the Batch Manager, new action "delete_orphans" next to prefilter. --- admin/include/functions.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'admin/include') diff --git a/admin/include/functions.php b/admin/include/functions.php index 7d29f5734..5cd44b31d 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -2775,4 +2775,22 @@ SELECT CONCAT( } return $keys; +} + +/** + * Return the list of image ids associated to no album + * + * @return int[] $image_ids + */ +function get_orphans() +{ + $query = ' +SELECT + id + FROM '.IMAGES_TABLE.' + LEFT JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id + WHERE category_id is null +;'; + + return query2array($query, null, 'id'); } \ No newline at end of file -- cgit v1.2.3