From: Petr Skoda Date: Sun, 7 Aug 2011 11:04:04 +0000 (+0200) Subject: MDL-28450 prefer member group for default X-Git-Tag: v2.2.0-beta~589^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=c160da9cb828b3a49d86d0bacc86e50e26fe522b MDL-28450 prefer member group for default --- diff --git a/lib/grouplib.php b/lib/grouplib.php index 120de12347d..708d2427f81 100644 --- a/lib/grouplib.php +++ b/lib/grouplib.php @@ -717,7 +717,7 @@ function groups_course_module_visible($cm, $userid=null) { * @return void */ function _group_verify_activegroup($courseid, $groupmode, $groupingid, array $allowedgroups) { - global $SESSION; + global $SESSION, $USER; // init activegroup array if necessary if (!isset($SESSION->activegroup)) { @@ -742,7 +742,11 @@ function _group_verify_activegroup($courseid, $groupmode, $groupingid, array $al $SESSION->activegroup[$courseid][$groupmode][$groupingid] = 0; // all groups by default if user has accessallgroups } else if ($allowedgroups) { - $firstgroup = reset($allowedgroups); + if ($groupmode != SEPARATEGROUPS and $mygroups = groups_get_all_groups($courseid, $USER->id, $groupingid)) { + $firstgroup = reset($mygroups); + } else { + $firstgroup = reset($allowedgroups); + } $SESSION->activegroup[$courseid][$groupmode][$groupingid] = $firstgroup->id; } else {