diff options
author | plegall <plg@piwigo.org> | 2008-10-06 23:08:11 +0000 |
---|---|---|
committer | plegall <plg@piwigo.org> | 2008-10-06 23:08:11 +0000 |
commit | 9cfd70474f67037977f98f0e0e2cb3505f6446f3 (patch) | |
tree | eccc480efefda5a0a4dabe8678137c3956934805 /admin/include/functions.php | |
parent | b0c514745ff0f602a9a04c9a47ae8eb56fc072c0 (diff) |
feature 884 added: ability to delete photos uploaded via web API method
pwg.images.add, ie without storage_category_id. pLoader uses this method and
photos cannot be removed in any other way.
git-svn-id: http://piwigo.org/svn/trunk@2678 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions.php | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/admin/include/functions.php b/admin/include/functions.php index 932578963..4b0713226 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -127,7 +127,7 @@ DELETE FROM '.OLD_PERMALINKS_TABLE.' // - all the comments related to elements // - all the links between categories and elements // - all the favorites associated to elements -function delete_elements($ids) +function delete_elements($ids, $physical_deletion=false) { if (count($ids) == 0) { @@ -135,6 +135,45 @@ function delete_elements($ids) } trigger_action('begin_delete_elements', $ids); + if ($physical_deletion) + { + include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php'); + + // we can currently delete physically only photo with no + // storage_category_id (added via pLoader) + // + // we assume that the element is a photo, with no representative + $query = ' +SELECT + id, + path, + tn_ext, + has_high + FROM '.IMAGES_TABLE.' + WHERE id IN ('.implode(',', $ids).') + AND storage_category_id IS NULL +;'; + $result = pwg_query($query); + while ($row = mysql_fetch_assoc($result)) + { + $file_path = $row['path']; + $thumbnail_path = get_thumbnail_path($row); + $high_path = null; + if (isset($row['has_high']) and get_boolean($row['has_high'])) + { + $high_path = get_high_path($row); + } + + foreach (array($file_path, $thumbnail_path, $high_path) as $path) + { + if (isset($path) and !unlink($path)) + { + die('"'.$path.'" cannot be removed'); + } + } + } + } + // destruction of the comments on the image $query = ' DELETE FROM '.COMMENTS_TABLE.' |