MDL-79581 communication: Context is a mandatory field
The API was incorrectly assuming that all uses of the API were for a course, and that the instanceid of the communication instance was a course id. These assumptions are both entirely wrong. The API is intended to support a range of uses including use at the site, user, and activity levels. Furthermore, if a group were to be used, then the instanceid should be of that group's id, and therefore the contextid would need to be fetched or that group's course instead. The only solution here is to add a new contextid field to the table, and implement it all parts of the API.
This commit is contained in:
@@ -2986,8 +2986,12 @@ class global_navigation extends navigation_node {
|
||||
|
||||
// Add link for configuring communication.
|
||||
if ($navoptions->communication) {
|
||||
$url = new moodle_url('/communication/configure.php', ['instanceid' => $course->id,
|
||||
'instancetype' => 'coursecommunication', 'component' => 'core_course']);
|
||||
$url = new moodle_url('/communication/configure.php', [
|
||||
'contextid' => \core\context\course::instance($course->id)->id,
|
||||
'instanceid' => $course->id,
|
||||
'instancetype' => 'coursecommunication',
|
||||
'component' => 'core_course',
|
||||
]);
|
||||
$coursenode->add(get_string('communication', 'communication'), $url,
|
||||
navigation_node::TYPE_SETTING, null, 'communication');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user