$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 {
/**
* 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;
}
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);
* @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;
$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
* @return bool success
*/
function glossary_delete_instance($id) {
- global $DB;
+ global $DB, $CFG;
if (!$glossary = $DB->get_record('glossary', array('id'=>$id))) {
return false;
$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);