aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/functions.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2015-10-09 19:13:30 +0200
committerplegall <plg@piwigo.org>2015-10-09 20:17:27 +0200
commit92224bcbf49d58829988eb0485afc17695f6de0c (patch)
tree1009cfcdb5f1f52f36e56e52a20d970f1ea318f1 /admin/include/functions.php
parent47ebd6c91f630c7b970d5abb9f1451a637afb517 (diff)
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.
Diffstat (limited to 'admin/include/functions.php')
-rw-r--r--admin/include/functions.php18
1 files changed, 18 insertions, 0 deletions
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