MDL-31243 access/enrol libs: rename new groups functions

This commit is contained in:
John Beedell 2016-09-27 16:18:24 +01:00
parent 9121bb2d23
commit 905953909f
3 changed files with 8 additions and 9 deletions

View File

@ -1184,7 +1184,7 @@ function get_enrolled_with_capabilities_join(context $context, $prefix = '', $ca
}
if ($group) {
$groupjoin = get_in_group_join($group, $uid);
$groupjoin = groups_get_members_join($group, $uid);
$joins[] = $groupjoin->joins;
$params = array_merge($params, $groupjoin->params);
}

View File

@ -937,13 +937,13 @@ function groups_group_visible($groupid, $course, $cm = null, $userid = null) {
* @param int $groupid
* @return array($sql, $params)
*/
function get_in_group_sql($groupid) {
$groupjoin = get_in_group_join($groupid, 'u.id');
function groups_get_members_ids_sql($groupid) {
$groupjoin = groups_get_members_join($groupid, 'u.id');
$sql = "SELECT DISTINCT u.id
FROM {user} u
FROM {user} u
$groupjoin->joins
WHERE u.deleted = 0";
WHERE u.deleted = 0";
return array($sql, $groupjoin->params);
}
@ -955,7 +955,7 @@ function get_in_group_sql($groupid) {
* @param string $useridcolumn The column of the user id from the calling SQL, e.g. u.id
* @return \core\dml\sql_join Contains joins, wheres, params
*/
function get_in_group_join($groupid, $useridcolumn) {
function groups_get_members_join($groupid, $useridcolumn) {
// Use unique prefix just in case somebody makes some SQL magic with the result.
static $i = 0;
$i++;

View File

@ -177,14 +177,13 @@ class core_grouplib_testcase extends advanced_testcase {
}
public function test_groups_get_in_group_sql() {
public function test_groups_get_members_ids_sql() {
global $DB;
$this->resetAfterTest(true);
$generator = $this->getDataGenerator();
// Create a course category and course.
$course = $generator->create_course();
$student = $generator->create_user();
$plugin = enrol_get_plugin('manual');
@ -200,7 +199,7 @@ class core_grouplib_testcase extends advanced_testcase {
// Enrol the user in the course.
$plugin->enrol_user($instance, $student->id, $role->id);
list($sql, $params) = get_in_group_sql($group->id, true);
list($sql, $params) = groups_get_members_ids_sql($group->id, true);
// Test an empty group.
$users = $DB->get_records_sql($sql, $params);