group/assign: fixed performance of assigning users to groups
- page would not display on a course with 600 users
This commit is contained in:
@@ -72,6 +72,28 @@ if ($currentmembers) {
|
||||
$currentmembersoptions .= '<option value="'.$group->id.'.">'.format_string($group->name).'</option>';
|
||||
$currentmemberscount ++;
|
||||
}
|
||||
|
||||
// Get course managers so they can be hilited in the list
|
||||
if ($managerroles = get_config('', 'coursemanager')) {
|
||||
$coursemanagerroles = split(',', $managerroles);
|
||||
foreach ($coursemanagerroles as $roleid) {
|
||||
$role = get_record('role','id',$roleid);
|
||||
$managers = get_role_users($roleid, $context, true, 'u.id', 'u.id ASC', true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($potentialmembers != false) {
|
||||
// Put the groupings into a hash and sorts them
|
||||
foreach ($potentialmembers as $user) {
|
||||
if(!empty($managers[$user->id])) {
|
||||
$nonmembers[$user->id] = '#'.$user->firstname.' '.$user->lastname;
|
||||
}
|
||||
else {
|
||||
$nonmembers[$user->id] = $user->firstname.' '.$user->lastname;
|
||||
}
|
||||
$potentialmemberscount++;
|
||||
}
|
||||
natcasesort($nonmembers);
|
||||
} else {
|
||||
$currentmembersoptions .= '<option> </option>';
|
||||
}
|
||||
|
||||
@@ -765,7 +765,7 @@ function get_course_teachers($courseid, $sort='t.authority ASC', $exceptions='')
|
||||
* @return object
|
||||
* @todo Finish documenting this function
|
||||
*/
|
||||
function get_course_users($courseid, $sort='ul.timeaccess DESC', $exceptions='', $fields='') {
|
||||
function get_course_users($courseid, $sort='ul.timeaccess DESC', $exceptions='', $fields='u.*, ul.timeaccess as lastaccess') {
|
||||
global $CFG;
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
@@ -790,7 +790,7 @@ function get_course_users($courseid, $sort='ul.timeaccess DESC', $exceptions='',
|
||||
}
|
||||
}
|
||||
}
|
||||
return get_users_by_capability($context, 'moodle/course:view', 'u.*, ul.timeaccess as lastaccess', $sort, '','','',$exceptions, false);
|
||||
return get_users_by_capability($context, 'moodle/course:view', $fields, $sort, '','','',$exceptions, false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user