MDL-56138 messaging: Limit course search to enrolled courses.

This commit is contained in:
Adrian Greeve 2016-10-25 14:07:36 +08:00
parent 72c0d69d5c
commit f324957724

View file

@ -196,9 +196,13 @@ class api {
}
// Now, let's get the courses.
// Make sure to limit searches to enrolled courses.
$enrolledcourses = enrol_get_my_courses(array('id', 'cacherev'));
$courses = array();
if ($arrcourses = \coursecat::search_courses(array('search' => $search), array('limit' => $limitnum))) {
if ($arrcourses = \coursecat::search_courses(array('search' => $search), array('limit' => $limitnum),
array('moodle/course:viewparticipants'))) {
foreach ($arrcourses as $course) {
if (isset($enrolledcourses[$course->id])) {
$data = new \stdClass();
$data->id = $course->id;
$data->shortname = $course->shortname;
@ -206,6 +210,7 @@ class api {
$courses[] = $data;
}
}
}
// Let's get those non-contacts. Toast them gears boi.
// Note - you can only block contacts, so these users will not be blocked, so no need to get that