MDL-24590 fixed links to groups on participants page
authorPetr Skoda <skodak@moodle.org>
Sat, 9 Oct 2010 10:26:35 +0000 (10:26 +0000)
committerPetr Skoda <skodak@moodle.org>
Sat, 9 Oct 2010 10:26:35 +0000 (10:26 +0000)
user/view.php

index 2f9b8e9..ab82bf2 100644 (file)
@@ -246,12 +246,23 @@ if ($rolestring = get_user_roles_in_course($id, $course->id)) {
 
 // Show groups this user is in
 if (!isset($hiddenfields['groups'])) {
-    if ($course->groupmode != SEPARATEGROUPS or has_capability('moodle/site:accessallgroups', $coursecontext)) {
-        if ($usergroups = groups_get_all_groups($course->id, $user->id)) {
-            $groupstr = '';
-            foreach ($usergroups as $group){
+    $accessallgroups = has_capability('moodle/site:accessallgroups', $coursecontext);
+    if ($usergroups = groups_get_all_groups($course->id, $user->id)) {
+        $groupstr = '';
+        foreach ($usergroups as $group){
+            if ($course->groupmode == SEPARATEGROUPS and !$accessallgroups and $user->id != $USER->id) {
+                if (!groups_is_member($group->id, $user->id)) {
+                    continue;
+                }
+            }
+
+            if ($course->groupmode != NOGROUPS) {
                 $groupstr .= ' <a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&amp;group='.$group->id.'">'.format_string($group->name).'</a>,';
+            } else {
+                $groupstr .= ' '.format_string($group->name); // the user/index.php shows groups only when course in group mode
             }
+        }
+        if ($groupstr !== '') {
             print_row(get_string("group").":", rtrim($groupstr, ', '));
         }
     }