mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-68169 user: Add enrolment instance filter
Part of MDL-67743
This commit is contained in:
parent
de83d4357f
commit
fa3d57fe7e
1 changed files with 41 additions and 0 deletions
|
@ -75,6 +75,10 @@ class participants_filter implements renderable, templatable {
|
||||||
$filtertypes[] = $filtertype;
|
$filtertypes[] = $filtertype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($filtertype = $this->get_enrolments_filter()) {
|
||||||
|
$filtertypes[] = $filtertype;
|
||||||
|
}
|
||||||
|
|
||||||
if ($filtertype = $this->get_groups_filter()) {
|
if ($filtertype = $this->get_groups_filter()) {
|
||||||
$filtertypes[] = $filtertype;
|
$filtertypes[] = $filtertype;
|
||||||
}
|
}
|
||||||
|
@ -140,6 +144,43 @@ class participants_filter implements renderable, templatable {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get data for the roles filter.
|
||||||
|
*
|
||||||
|
* @return stdClass|null
|
||||||
|
*/
|
||||||
|
protected function get_enrolments_filter(): ?stdClass {
|
||||||
|
if (!has_capability('moodle/course:enrolreview', $this->context)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->course->id == SITEID) {
|
||||||
|
// No enrolment methods for the site.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$instances = enrol_get_instances($this->course->id, true);
|
||||||
|
$plugins = enrol_get_plugins(false);
|
||||||
|
|
||||||
|
return $this->get_filter_object(
|
||||||
|
'enrolments',
|
||||||
|
get_string('enrolmentinstances', 'core_enrol'),
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
null,
|
||||||
|
array_filter(array_map(function($instance) use ($plugins): ?stdClass {
|
||||||
|
if (!array_key_exists($instance->enrol, $plugins)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (object) [
|
||||||
|
'value' => $instance->id,
|
||||||
|
'title' => $plugins[$instance->enrol]->get_instance_name($instance),
|
||||||
|
];
|
||||||
|
}, array_values($instances)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get data for the groups filter.
|
* Get data for the groups filter.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue