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:
@@ -1648,6 +1648,7 @@ function role_assign($roleid, $userid, $contextid, $component = '', $itemid = 0,
|
||||
// Update the room membership and power levels when the user role changes.
|
||||
if (\core_communication\api::is_available() && $coursecontext = $context->get_course_context(false)) {
|
||||
$communication = \core_communication\api::load_by_instance(
|
||||
$coursecontext,
|
||||
'core_course',
|
||||
'coursecommunication',
|
||||
$coursecontext->instanceid,
|
||||
@@ -1765,6 +1766,7 @@ function role_unassign_all(array $params, $subcontexts = false, $includemanual =
|
||||
// Update the room membership and power levels when the user role changes.
|
||||
if (\core_communication\api::is_available() && $coursecontext = $context->get_course_context(false)) {
|
||||
$communication = \core_communication\api::load_by_instance(
|
||||
$coursecontext,
|
||||
'core_course',
|
||||
'coursecommunication',
|
||||
$coursecontext->instanceid,
|
||||
|
||||
Reference in New Issue
Block a user