MDL-41465 reports: In separate group mode, limit to same

This commit is contained in:
Stephan Robotta
2023-12-06 13:52:58 +07:00
committed by Huong Nguyen
parent 9e3ca2a866
commit fbecc7132d
7 changed files with 283 additions and 14 deletions
+11
View File
@@ -168,6 +168,8 @@ class report_loglive_renderable implements renderable {
* @return stdClass filters
*/
protected function setup_filters() {
global $USER;
$readers = $this->get_readers();
// Set up filters.
@@ -178,6 +180,15 @@ class report_loglive_renderable implements renderable {
if (!has_capability('moodle/site:viewanonymousevents', $context)) {
$filter->anonymous = 0;
}
if (groups_get_course_groupmode($this->course) == SEPARATEGROUPS &&
!has_capability('moodle/site:accessallgroups', $context)) {
if ($cgroups = groups_get_all_groups($this->course->id, $USER->id)) {
$filter->groups = [];
foreach ($cgroups as $cgroup) {
$filter->groups[] = (int)$cgroup->id;
}
}
}
} else {
$filter->courseid = 0;
}