Merge branch 'wip-MDL-34530_MASTER' of git://github.com/jason-platts/moodle
authorSam Hemelryk <sam@moodle.com>
Tue, 27 Nov 2012 22:25:24 +0000 (11:25 +1300)
committerSam Hemelryk <sam@moodle.com>
Tue, 27 Nov 2012 22:25:24 +0000 (11:25 +1300)
calendar/lib.php

index 2549493..86ca22f 100644 (file)
@@ -1753,11 +1753,19 @@ function calendar_get_allowed_types(&$allowed, $course = null) {
                 $allowed->courses = array($course->id => 1);
 
                 if ($course->groupmode != NOGROUPS || !$course->groupmodeforce) {
-                    $allowed->groups = groups_get_all_groups($course->id);
+                    if (has_capability('moodle/site:accessallgroups', $coursecontext)) {
+                        $allowed->groups = groups_get_all_groups($course->id);
+                    } else {
+                        $allowed->groups = groups_get_all_groups($course->id, $USER->id);
+                    }
                 }
             } else if (has_capability('moodle/calendar:managegroupentries', $coursecontext)) {
                 if($course->groupmode != NOGROUPS || !$course->groupmodeforce) {
-                    $allowed->groups = groups_get_all_groups($course->id);
+                    if (has_capability('moodle/site:accessallgroups', $coursecontext)) {
+                        $allowed->groups = groups_get_all_groups($course->id);
+                    } else {
+                        $allowed->groups = groups_get_all_groups($course->id, $USER->id);
+                    }
                 }
             }
         }