mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-16220 allow deleting of all files attached to context
This commit is contained in:
parent
a1b892ccec
commit
fa686bc4e0
@ -391,12 +391,11 @@ class assignment_base {
|
||||
|
||||
$result = true;
|
||||
|
||||
// now get rid of all attachments
|
||||
// now get rid of all files
|
||||
$fs = get_file_storage();
|
||||
if ($cm = get_coursemodule_from_instance('assignment', $assignment->id)) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$fs->delete_area_files($context->id, 'assignment_submission');
|
||||
$fs->delete_area_files($context->id, 'assignment_response');
|
||||
$fs->delete_area_files($context->id);
|
||||
}
|
||||
|
||||
if (! $DB->delete_records('assignment_submissions', array('assignment'=>$assignment->id))) {
|
||||
|
@ -179,6 +179,13 @@ function forum_delete_instance($id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// now get rid of all files
|
||||
$fs = get_file_storage();
|
||||
if ($cm = get_coursemodule_from_instance('forum', $forum->id)) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$fs->delete_area_files($context->id);
|
||||
}
|
||||
|
||||
$result = true;
|
||||
|
||||
if ($discussions = $DB->get_records('forum_discussions', array('forum'=>$forum->id))) {
|
||||
|
@ -172,12 +172,8 @@ function glossary_delete_instance($id) {
|
||||
$DB->delete_records_select('glossary_entries_categories', "categoryid IN ($category_select)", array($id));
|
||||
$DB->delete_records('glossary_categories', array('glossaryid'=>$id));
|
||||
|
||||
// delete attachments
|
||||
if ($attachments = $DB->get_records('glossary_entries', array('glossaryid'=>$id, 'attachment'=>'1'), '', 'id')) {
|
||||
foreach ($attachments as $entryid=>$unused) {
|
||||
$fs->delete_area_files($context->id, 'glossary_attachment', $entryid);
|
||||
}
|
||||
}
|
||||
// delete all files
|
||||
$fs->delete_area_files($context->id);
|
||||
|
||||
glossary_grade_item_delete($glossary);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user