Skip to content

Commit

Permalink
"MDL-19118, fixed comments api in format_text function"
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongsheng Cai committed Mar 19, 2010
1 parent c82ed0a commit 08a22be
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion comment/comment_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
$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;
Expand Down Expand Up @@ -54,7 +60,9 @@
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;
Expand Down
2 changes: 1 addition & 1 deletion comment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function __construct($options) {
if (!empty($options->env)) {
$this->env = $options->env;
} else {
$this->env = 'embedded';
$this->env = '';
}

if (!empty($options->linktext)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 08a22be

Please sign in to comment.