merged fix for MDL-8942, can't delete blog images

This commit is contained in:
toyomoyo 2007-03-19 07:52:29 +00:00
parent 9aa9080756
commit 2878babdb2
2 changed files with 21 additions and 1 deletions

View File

@ -244,7 +244,9 @@ function do_delete($post) {
$status = delete_records('post', 'id', $post->id);
$status = delete_records('blog_tag_instance', 'entryid', $post->id) and $status;
blog_delete_old_attachments($post);
add_to_log(SITEID, 'blog', 'delete', 'index.php?userid='. $post->userid, 'deleted blog entry with entry id# '. $post->id);
if (!$status) {

View File

@ -263,6 +263,24 @@
return make_upload_directory( blog_file_area_name($blogentry) );
}
function blog_delete_old_attachments($post, $exception="") {
// Deletes all the user files in the attachments area for a post
// EXCEPT for any file named $exception
if ($basedir = blog_file_area($post)) {
if ($files = get_directory_list($basedir)) {
foreach ($files as $file) {
if ($file != $exception) {
unlink("$basedir/$file");
notify("Existing file '$file' has been deleted!");
}
}
}
if (!$exception) { // Delete directory as well, if empty
rmdir("$basedir");
}
}
}
function blog_print_attachments($blogentry, $return=NULL) {
// if return=html, then return a html string.