MDL-78129 core_communication: Add update membership api

This commit is contained in:
Safat
2023-09-21 13:28:20 +08:00
committed by Andrew Nicols
parent 9890e67e6d
commit 3e47253787
8 changed files with 222 additions and 4 deletions
+22
View File
@@ -1645,6 +1645,17 @@ function role_assign($roleid, $userid, $contextid, $component = '', $itemid = 0,
core_course_category::role_assignment_changed($roleid, $context);
// 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(
'core_course',
'coursecommunication',
$coursecontext->instanceid,
);
$communication->update_room_membership([$userid]);
}
$event = \core\event\role_assigned::create(array(
'context' => $context,
'objectid' => $ra->roleid,
@@ -1688,6 +1699,17 @@ function role_unassign($roleid, $userid, $contextid, $component = '', $itemid =
}
}
// 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(
'core_course',
'coursecommunication',
$coursecontext->instanceid,
);
$communication->update_room_membership([$userid]);
}
role_unassign_all(array('roleid'=>$roleid, 'userid'=>$userid, 'contextid'=>$contextid, 'component'=>$component, 'itemid'=>$itemid), false, false);
}