mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
COMMENT MDL-23585 delete comments when centain contexts are being deleted
This commit is contained in:
parent
a30ec92268
commit
650a0c0a66
@ -518,7 +518,7 @@ EOD;
|
||||
$newcmt->fullname = fullname($USER);
|
||||
$url = new moodle_url('/user/view.php', array('id'=>$USER->id, 'course'=>$this->courseid));
|
||||
$newcmt->profileurl = $url->out();
|
||||
$newcmt->content = format_text($newcmt->content);
|
||||
$newcmt->content = format_text($newcmt->content, $format);
|
||||
$newcmt->avatar = $OUTPUT->user_picture($USER, array('size'=>16));
|
||||
return $newcmt;
|
||||
} else {
|
||||
@ -528,15 +528,20 @@ EOD;
|
||||
|
||||
/**
|
||||
* delete by context, commentarea and itemid
|
||||
*
|
||||
* @param object $param {
|
||||
* contextid => int the context in which the comments exist [required]
|
||||
* commentarea => string the comment area [optional]
|
||||
* itemid => int comment itemid [optional]
|
||||
* }
|
||||
* @return boolean
|
||||
*/
|
||||
public function delete_comments() {
|
||||
public function delete_comments($param) {
|
||||
global $DB;
|
||||
$DB->delete_records('comments', array(
|
||||
'contextid'=>$this->context->id,
|
||||
'commentarea'=>$this->commentarea,
|
||||
'itemid'=>$this->itemid)
|
||||
);
|
||||
$param = (array)$param;
|
||||
if (empty($param['contextid'])) {
|
||||
return false;
|
||||
}
|
||||
$DB->delete_records('comments', $param);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4096,6 +4096,10 @@ function remove_course_contents($courseid, $showfeedback=true) {
|
||||
require_once($CFG->dirroot.'/tag/coursetagslib.php');
|
||||
coursetag_delete_course_tags($course->id, $showfeedback);
|
||||
|
||||
/// Delete comments
|
||||
require_once($CFG->dirroot.'/comment/lib.php');
|
||||
comment::delete_comments(array('contextid'=>$context->id));
|
||||
|
||||
// Delete legacy files
|
||||
fulldelete($CFG->dataroot.'/'.$courseid);
|
||||
|
||||
|
@ -889,7 +889,7 @@ function data_update_instance($data) {
|
||||
* @return bool
|
||||
*/
|
||||
function data_delete_instance($id) { // takes the dataid
|
||||
global $DB;
|
||||
global $DB, $CFG;
|
||||
|
||||
if (!$data = $DB->get_record('data', array('id'=>$id))) {
|
||||
return false;
|
||||
@ -904,6 +904,10 @@ 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));
|
||||
|
||||
// get all the records in this data
|
||||
$sql = "SELECT r.id
|
||||
FROM {data_records} r
|
||||
|
@ -135,7 +135,7 @@ function glossary_update_instance($glossary) {
|
||||
* @return bool success
|
||||
*/
|
||||
function glossary_delete_instance($id) {
|
||||
global $DB;
|
||||
global $DB, $CFG;
|
||||
|
||||
if (!$glossary = $DB->get_record('glossary', array('id'=>$id))) {
|
||||
return false;
|
||||
@ -195,6 +195,10 @@ 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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user