mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
merged fix for MDL-8942, can't delete blog images
This commit is contained in:
parent
9aa9080756
commit
2878babdb2
@ -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) {
|
||||
|
18
blog/lib.php
18
blog/lib.php
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user