MDL-59977 core: do not directly check 'viewparticipant' capability

This commit is contained in:
Mark Nelson
2017-09-11 12:44:27 +08:00
parent 32f9550e85
commit 93b47710ac
17 changed files with 261 additions and 48 deletions
+4
View File
@@ -199,6 +199,10 @@ class api {
// Make sure to limit searches to enrolled courses.
$enrolledcourses = enrol_get_my_courses(array('id', 'cacherev'));
$courses = array();
// Really we want the user to be able to view the participants if they have the capability
// 'moodle/course:viewparticipants' or 'moodle/course:enrolreview', but since the search_courses function
// only takes required parameters we can't. However, the chance of a user having 'moodle/course:enrolreview' but
// *not* 'moodle/course:viewparticipants' are pretty much zero, so it is not worth addressing.
if ($arrcourses = \coursecat::search_courses(array('search' => $search), array('limit' => $limitnum),
array('moodle/course:viewparticipants'))) {
foreach ($arrcourses as $course) {