MDL-54116 block_comments: warnings when commenting outside of a course

This commit is contained in:
Marina Glancy
2016-05-26 10:20:13 +08:00
committed by Cameron Ball
parent 95b82c9dcf
commit 89fba73a45
2 changed files with 22 additions and 5 deletions
+8 -1
View File
@@ -34,6 +34,11 @@ list($context, $course, $cm) = get_context_info_array($contextid);
require_login($course, true, $cm);
require_sesskey();
if (!$course) {
// Require_login() does not set context if called without a $course, do it manually.
$PAGE->set_context($context);
}
$action = optional_param('action', '', PARAM_ALPHA);
$area = optional_param('area', '', PARAM_AREA);
$content = optional_param('content', '', PARAM_RAW);
@@ -48,7 +53,9 @@ if ($action !== 'add') {
$cmt = new stdClass;
$cmt->contextid = $contextid;
$cmt->courseid = $course->id;
if ($course) {
$cmt->courseid = $course->id;
}
$cmt->cm = $cm;
$cmt->area = $area;
$cmt->itemid = $itemid;