mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-57411 groups: Fix tests for MSSQL
This commit is contained in:
parent
0a34838725
commit
8c60d198c2
2 changed files with 15 additions and 7 deletions
|
@ -426,7 +426,10 @@ function groups_has_membership($cm, $userid=null) {
|
|||
function groups_get_members($groupid, $fields='u.*', $sort='lastname ASC') {
|
||||
global $DB;
|
||||
|
||||
return groups_get_groups_members([$groupid], $fields, $sort);
|
||||
return $DB->get_records_sql("SELECT $fields
|
||||
FROM {user} u, {groups_members} gm
|
||||
WHERE u.id = gm.userid AND gm.groupid = ?
|
||||
ORDER BY $sort", array($groupid));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1134,21 +1137,24 @@ function groups_user_groups_visible($course, $userid, $cm = null) {
|
|||
/**
|
||||
* Returns the users in the specified groups.
|
||||
*
|
||||
* This function does not return complete user objects by default. It returns the user_picture basic fields.
|
||||
*
|
||||
* @param array $groupsids The list of groups ids to check
|
||||
* @param int $fields The fields to return
|
||||
* @param array $extrafields extra fields to be included in result
|
||||
* @param int $sort optional sorting of returned users
|
||||
* @return array|bool Returns an array of the users for the specified group or false if no users or an error returned.
|
||||
* @since Moodle 3.3
|
||||
*/
|
||||
function groups_get_groups_members($groupsids, $fields='u.*', $sort='lastname ASC') {
|
||||
function groups_get_groups_members($groupsids, $extrafields=null, $sort='lastname ASC') {
|
||||
global $DB;
|
||||
|
||||
$userfields = user_picture::fields('u', $extrafields);
|
||||
list($insql, $params) = $DB->get_in_or_equal($groupsids);
|
||||
|
||||
return $DB->get_records_sql("SELECT $fields
|
||||
return $DB->get_records_sql("SELECT $userfields
|
||||
FROM {user} u, {groups_members} gm
|
||||
WHERE u.id = gm.userid AND gm.groupid $insql
|
||||
GROUP BY u.id
|
||||
GROUP BY $userfields
|
||||
ORDER BY $sort", $params);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue