MDL-10888: groupings - added function to get all grouping members, cleaned up some notices
This commit is contained in:
+2
-1
@@ -1329,6 +1329,7 @@ function get_all_instances_in_course($modulename, $course, $userid=NULL, $includ
|
||||
|
||||
foreach ($modinfo as $mod) {
|
||||
$mod->id = $mod->cm;
|
||||
$mod->course = $course->id;
|
||||
if (!groups_course_module_visible($mod)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1363,7 +1364,7 @@ function instance_is_visible($moduletype, $module) {
|
||||
global $CFG;
|
||||
|
||||
if (!empty($module->id)) {
|
||||
if ($records = get_records_sql("SELECT cm.instance, cm.visible, cm.groupingid, cm.id, cm.groupmembersonly
|
||||
if ($records = get_records_sql("SELECT cm.instance, cm.visible, cm.groupingid, cm.id, cm.groupmembersonly, cm.course
|
||||
FROM {$CFG->prefix}course_modules cm,
|
||||
{$CFG->prefix}modules m
|
||||
WHERE cm.course = '$module->course' AND
|
||||
|
||||
+23
-2
@@ -174,19 +174,40 @@ function groups_has_membership($cm, $userid=null) {
|
||||
/**
|
||||
* Returns the users in the specified group.
|
||||
* @param int $groupid The groupid to get the users for
|
||||
* @param int $fields The fields to return
|
||||
* @param int $sort optional sorting of returned users
|
||||
* @return array | false Returns an array of the users for the specified
|
||||
* group or false if no users or an error returned.
|
||||
*/
|
||||
function groups_get_members($groupid, $sort='lastname ASC') {
|
||||
function groups_get_members($groupid, $fields='u.*', $sort='lastname ASC') {
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql("SELECT u.*
|
||||
return get_records_sql("SELECT $fields
|
||||
FROM {$CFG->prefix}user u, {$CFG->prefix}groups_members gm
|
||||
WHERE u.id = gm.userid AND gm.groupid = '$groupid'
|
||||
ORDER BY $sort");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the users in the specified grouping.
|
||||
* @param int $groupingid The groupingid to get the users for
|
||||
* @param int $fields The fields to return
|
||||
* @param int $sort optional sorting of returned users
|
||||
* @return array | false Returns an array of the users for the specified
|
||||
* group or false if no users or an error returned.
|
||||
*/
|
||||
function groups_get_grouping_members($groupingid, $fields='u.*', $sort='lastname ASC') {
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql("SELECT $fields
|
||||
FROM {$CFG->prefix}user u
|
||||
INNER JOIN {$CFG->prefix}groups_members gm ON u.id = gm.userid
|
||||
INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid
|
||||
WHERE gg.groupingid = $groupingid
|
||||
ORDER BY $sort");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns effective groupmode used in activity, course setting
|
||||
* overrides activity setting if groupmodeforce enabled.
|
||||
|
||||
@@ -4733,6 +4733,7 @@ function navmenu($course, $cm=NULL, $targetwindow='self') {
|
||||
break;
|
||||
}
|
||||
$mod->id = $mod->cm;
|
||||
$mod->course = $course->id;
|
||||
if (!groups_course_module_visible($mod)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user