Permalink
Browse files

MDL-29347 core_enrol_get_enrolled_users web service should limit the …

…number of participants - Jerome/Dongsheng
  • Loading branch information...
1 parent c4a12af commit 3ed74dd1d64846999e611dfabab645d9f0f9a593 @dcai dcai committed with mouneyrac Feb 27, 2012
Showing with 15 additions and 2 deletions.
  1. +15 −2 enrol/externallib.php
View
@@ -123,7 +123,13 @@ public static function get_enrolled_users_parameters() {
'name' => new external_value(PARAM_ALPHANUMEXT, 'option name'),
'value' => new external_value(PARAM_RAW, 'option value')
)
- ), 'method options', VALUE_DEFAULT, array()),
+ ), 'Option names:
+ * withcapability (string) return only users with this capability. This option requires \'moodle/role:review\' on the course context.
+ * groupid (integer) return only users in this group id. This option requires \'moodle/site:accessallgroups\' on the course context.
+ * onlyactive (integer) return only users with active enrolments and matching time restrictions. This option requires \'moodle/course:enrolreview\' on the course context.
+ * userfields (\'string, string, ...\') return only the values of these user fields.
+ * limitfrom (integer) sql limit from.
+ * limitnumber (integer) maximum number of returned users.', VALUE_DEFAULT, array()),
)
);
}
@@ -152,6 +158,8 @@ public static function get_enrolled_users($courseid, $options) {
$groupid = 0;
$onlyactive = false;
$userfields = array();
+ $limitfrom = 0;
+ $limitnumber = 0;
foreach ($options as $option) {
switch ($option['name']) {
case 'withcapability':
@@ -168,6 +176,11 @@ public static function get_enrolled_users($courseid, $options) {
foreach ($thefields as $f) {
$userfields[] = clean_param($f, PARAM_ALPHANUMEXT);
}
+ case 'limitfrom' :
+ $limitfrom = clean_param($option['value'], PARAM_INT);
+ break;
+ case 'limitnumber' :
+ $limitnumber = clean_param($option['value'], PARAM_INT);
break;
}
}
@@ -213,7 +226,7 @@ public static function get_enrolled_users($courseid, $options) {
FROM {user} u $ctxjoin
WHERE u.id IN ($enrolledsql)
ORDER BY u.id ASC";
- $enrolledusers = $DB->get_recordset_sql($sql, $enrolledparams);
+ $enrolledusers = $DB->get_recordset_sql($sql, $enrolledparams, $limitfrom, $limitnumber);
$users = array();
foreach ($enrolledusers as $user) {
context_instance_preload($user);

0 comments on commit 3ed74dd

Please sign in to comment.