diff options
Diffstat (limited to 'admin/include/functions.php')
-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.' |