mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-56138 messaging: Limit course search to enrolled courses.
This commit is contained in:
parent
72c0d69d5c
commit
f324957724
1 changed files with 11 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue