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
This commit is contained in:
plegall 2008-10-06 23:08:11 +00:00
commit 9cfd70474f
5 changed files with 175 additions and 1 deletions

View file

@ -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.'