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:
Andrew Nicols
2023-10-04 20:37:57 +08:00
parent 1724362afc
commit 99c1543aa8
20 changed files with 358 additions and 147 deletions
+6 -2
View File
@@ -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');
}