From 21a58e7de8cbe3e4661f1726bb418b1b6e61f6e3 Mon Sep 17 00:00:00 2001 From: Eloy Lafuente (stronk7) Date: Fri, 3 Sep 2010 15:02:47 +0200 Subject: [PATCH] Delete comments centrally on ctx removal --- lib/accesslib.php | 4 ++++ mod/data/lib.php | 4 ---- mod/glossary/lib.php | 4 ---- mod/wiki/locallib.php | 17 ----------------- 4 files changed, 4 insertions(+), 25 deletions(-) diff --git a/lib/accesslib.php b/lib/accesslib.php index 9ef676b..ce495c5 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -1912,6 +1912,10 @@ function delete_context($contextlevel, $instanceid) { $fs = get_file_storage(); $fs->delete_area_files($context->id); + // delete all the comments attached to this context + require_once($CFG->dirroot.'/comment/lib.php'); + comment::delete_comments(array('contextid'=>$context->id)); + // do not mark dirty contexts if parents unknown if (!is_null($context->path) and $context->depth > 0) { mark_context_dirty($context->path); diff --git a/mod/data/lib.php b/mod/data/lib.php index 031ea25..c65a00c 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -909,10 +909,6 @@ function data_delete_instance($id) { // takes the dataid $fs = get_file_storage(); $fs->delete_area_files($context->id, 'mod_data'); - // Delete comments - require_once($CFG->dirroot.'/comment/lib.php'); - comment::delete_comments(array('contextid'=>$context->id)); - // Delete ratings //delete ratings require_once($CFG->dirroot.'/rating/lib.php'); diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index c94f6cc..c201a2f 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -195,10 +195,6 @@ 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 comments - require_once($CFG->dirroot.'/comment/lib.php'); - comment::delete_comments(array('contextid'=>$context->id)); - // delete all files $fs->delete_area_files($context->id); diff --git a/mod/wiki/locallib.php b/mod/wiki/locallib.php index c02ed09..77e0a52 100644 --- a/mod/wiki/locallib.php +++ b/mod/wiki/locallib.php @@ -1144,23 +1144,6 @@ function wiki_delete_comment($idcomment, $context, $pageid) { } -/** - * Delete al comments from wiki - * - **/ -function wiki_delete_comments_wiki() { - global $PAGE, $DB; - - $cm = $PAGE->cm; - $context = get_context_instance(CONTEXT_MODULE, $cm->id); - - $table = 'comments'; - $select = 'contextid = ?'; - - $DB->delete_records_select($table, $select, array($context->id)); - -} - function wiki_add_progress($pageid, $oldversionid, $versionid, $progress) { global $DB; for ($v = $oldversionid + 1; $v <= $versionid; $v++) { -- 1.7.2.2+GitX