diff --git a/comment/comment_ajax.php b/comment/comment_ajax.php index 6bbe6a0efac..d40c21612d5 100644 --- a/comment/comment_ajax.php +++ b/comment/comment_ajax.php @@ -24,6 +24,12 @@ require_once($CFG->dirroot . '/comment/lib.php'); $contextid = optional_param('contextid', SYSCONTEXTID, PARAM_INT); list($context, $course, $cm) = get_context_info_array($contextid); +if (!empty($course)) { + $PAGE->set_course($course); +} else { + $PAGE->set_course($SITE); +} + require_login($course, true, $cm); $err = new stdclass; @@ -54,7 +60,9 @@ $page = optional_param('page', 0, PARAM_INT); if (!empty($client_id)) { $cmt = new stdclass; $cmt->contextid = $contextid; - $cmt->courseid = $course->id; + if (!empty($course)) { + $cmt->courseid = $course->id; + } $cmt->area = $area; $cmt->itemid = $itemid; $cmt->client_id = $client_id; diff --git a/comment/lib.php b/comment/lib.php index 528a460d544..8189357f0f6 100644 --- a/comment/lib.php +++ b/comment/lib.php @@ -117,7 +117,7 @@ class comment { if (!empty($options->env)) { $this->env = $options->env; } else { - $this->env = 'embedded'; + $this->env = ''; } if (!empty($options->linktext)) { diff --git a/lib/weblib.php b/lib/weblib.php index df19a1c1af4..4586d1e0613 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -949,7 +949,7 @@ function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL return ''; // no need to do any filters and cleaning } if (!empty($options->comments) && !empty($CFG->usecomments)) { - require_once($CFG->libdir . '/commentlib.php'); + require_once($CFG->dirroot . '/comment/lib.php'); $comment = new comment($options->comments); $cmt = $comment->output(true); } else {