MDL-17837 opt limit resultsets returned by some get_xxxx_users() function.
This commit is contained in:
+5
-2
@@ -210,11 +210,14 @@ function search_users($courseid, $groupid, $searchtext, $sort='', $exceptions=''
|
||||
* @uses SITEID
|
||||
* @deprecated Use {@link get_course_users()} instead.
|
||||
* @param string $fields A comma separated list of fields to be returned from the chosen table.
|
||||
* @param string $exceptions A comma separated list of user->id to be skiped in the result returned by the function
|
||||
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
|
||||
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
|
||||
* @return object|false {@link $USER} records or false if error.
|
||||
*/
|
||||
function get_site_users($sort='u.lastaccess DESC', $fields='*', $exceptions='') {
|
||||
function get_site_users($sort='u.lastaccess DESC', $fields='*', $exceptions='', $limitfrom='', $limitnum='') {
|
||||
|
||||
return get_course_users(SITEID, $sort, $exceptions, $fields);
|
||||
return get_course_users(SITEID, $sort, $exceptions, $fields, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
-10
@@ -773,12 +773,13 @@ function get_course_teachers($courseid, $sort='t.authority ASC', $exceptions='')
|
||||
*
|
||||
* @param int $courseid The course in question.
|
||||
* @param string $sort ?
|
||||
* @param string $exceptions ?
|
||||
* @param string $exceptions A comma separated list of user->id to be skiped in the result returned by the function
|
||||
* @param string $fields A comma separated list of fields to be returned from the chosen table.
|
||||
* @return object
|
||||
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
|
||||
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
|
||||
* @todo Finish documenting this function
|
||||
*/
|
||||
function get_course_users($courseid, $sort='ul.timeaccess DESC', $exceptions='', $fields='u.*, ul.timeaccess as lastaccess') {
|
||||
function get_course_users($courseid, $sort='ul.timeaccess DESC', $exceptions='', $fields='u.*, ul.timeaccess as lastaccess', $limitfrom='', $limitnum='') {
|
||||
global $CFG;
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
@@ -803,11 +804,11 @@ function get_course_users($courseid, $sort='ul.timeaccess DESC', $exceptions='',
|
||||
$fields = str_replace('u.', '', $fields);
|
||||
$fields = str_replace('ul.', '', $fields);
|
||||
$fields = str_replace('timeaccess', 'lastaccess', $fields);
|
||||
return get_users(true, '', true, $exceptions, 'lastname ASC', '', '', '', '', $fields);
|
||||
return get_users(true, '', true, $exceptions, 'lastname ASC', '', '', $limitfrom, $limitnum, $fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
return get_users_by_capability($context, 'moodle/course:view', $fields, $sort, '','','',$exceptions, false);
|
||||
return get_users_by_capability($context, 'moodle/course:view', $fields, $sort, $limitfrom, $limitnum,'',$exceptions, false);
|
||||
|
||||
}
|
||||
|
||||
@@ -1223,12 +1224,14 @@ function add_user_to_group($groupid, $userid) {
|
||||
* @uses $CFG
|
||||
* @param int $groupid The group in question.
|
||||
* @param string $sort ?
|
||||
* @param string $exceptions ?
|
||||
* @return object
|
||||
* @param string $exceptions A comma separated list of user->id to be skiped in the result returned by the function
|
||||
* @param string $fields A comma separated list of fields to be returned from the chosen table.
|
||||
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
|
||||
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
|
||||
* @return array array of user objects
|
||||
* @todo Finish documenting this function
|
||||
*/
|
||||
function get_group_users($groupid, $sort='u.lastaccess DESC', $exceptions='',
|
||||
$fields='u.*') {
|
||||
function get_group_users($groupid, $sort='u.lastaccess DESC', $exceptions='', $fields='u.*', $limitfrom='', $limitnum='') {
|
||||
global $CFG;
|
||||
if (!empty($exceptions)) {
|
||||
$except = ' AND u.id NOT IN ('. $exceptions .') ';
|
||||
@@ -1247,7 +1250,8 @@ function get_group_users($groupid, $sort='u.lastaccess DESC', $exceptions='',
|
||||
{$CFG->prefix}groups_members m
|
||||
WHERE m.groupid = '$groupid'
|
||||
AND m.userid = u.id $except
|
||||
ORDER BY $sort");
|
||||
ORDER BY $sort",
|
||||
$limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user