Skip to content

Commit

Permalink
MDL-16220 allow deleting of all files attached to context
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Aug 27, 2008
1 parent a1b892c commit fa686bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions mod/assignment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,11 @@ function delete_instance($assignment) {

$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))) {
Expand Down
7 changes: 7 additions & 0 deletions mod/forum/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
8 changes: 2 additions & 6 deletions mod/glossary/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit fa686bc

Please sign in to comment.